Code Monkey home page Code Monkey logo

Comments (10)

gregw avatar gregw commented on June 12, 2024 1

I've done some testing with the session_affinity and it appears to work fine. It does not trigger off the JSESSION_ID, rather it set's it's own GCLB cookie.
The normal default in memory session should work OK with this setup, but if the affinity is not entirely sticky (if the GCLB cookie is lost, a node shuts down etc.) then session data will be lost. So a better setup would be to have an in memory cache fronting the gcloud datastore. This can be achieved with the following in your app.yaml:

env_variables:
    JETTY_MODULES_ENABLE: session-cache-hash,gcp-datastore,session-store-gcloud

This will avoid hitting the datastore on every request, sessions will only be written when dirty. I can see in my tests that objects in the sessions are coming back with the same value and same hashcode (so they have not been serialized deserialized)!

I will add this to the doco!

from jetty-runtime.

gregw avatar gregw commented on June 12, 2024 1

Pull request #260 documents this

from jetty-runtime.

Petikoch avatar Petikoch commented on June 12, 2024

+1 from me

from jetty-runtime.

gregw avatar gregw commented on June 12, 2024

Note also that if session affinity is available, we can add a more efficient memory cache for sessions in each instance that will reduce the load on the shared session store and improve semantics for co-located requests. The image can easily be modified to take advantage of affinity.

from jetty-runtime.

Petikoch avatar Petikoch commented on June 12, 2024

Just dicovered this
https://cloud.google.com/blog/products/application-development/introducing-websockets-support-for-app-engine-flexible-environment
and this
https://cloud.google.com/appengine/docs/flexible/java/using-websockets-and-session-affinity
(see bottom of this page)

It looks like in order to offer WebSockets on the flex environment "they" implemented session-affinity

app.yaml:

network:
  session_affinity: true

from jetty-runtime.

gregw avatar gregw commented on June 12, 2024

@Petikoch Thanks for that - I'll test that out (probably next week) and if it works will see what session options should be turned on in the image to best make use of that.

from jetty-runtime.

Petikoch avatar Petikoch commented on June 12, 2024

Excellent, thanks a lot @gregw

from jetty-runtime.

menulis avatar menulis commented on June 12, 2024

Should it be enough to set session_affinity to true in app.yaml to enable session affinity or is there a specific Jetty module that also needs to be enabled with JETTY_MODULES_ENABLE? Does the GCP Load Balancer needs to be set up too? Documentation does not say anything about that and I cannot see any additional cookies (like the GCLB cookie mentioned by @gregw before) set in the response after having enabled session_affinity. Or is it just websockets for which App Engine flex supports session affinity?

from jetty-runtime.

gregw avatar gregw commented on June 12, 2024

If you set session_affinity to true, you will get session affinity implemented by the Google load balancer using its own additional cookie. This will work with no changes to Jetty.

However, one of the main points of session affinity is to allow efficient session management from an in memory session cache, so if you have affinity, you can turn this on with the session-cache-hash module. It's not necessary, but it's kind of the point!

from jetty-runtime.

menulis avatar menulis commented on June 12, 2024

Thanks for the clarification, @gregw. This was exactly how I thought. However, as I wrote, basic session infinity does not seem to work in my case. I set session_affinity under network: in app.yaml, but do not see any additional (GCLB or other) cookies added to the HTTP responses. This is why I thought that I may be missing one or another Jetty module or the Load Balancer has to be configured in some way (I do not have configured it at all, so as I understand, all App Engine Flex defaults should be functioning).

from jetty-runtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.