enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
201 stars 34 forks source link

Distributed sessions #8125

Closed rymsha closed 4 years ago

rymsha commented 4 years ago

Thanks to Hazelcast jetty sessions can be distributed.

Need to cover a few use cases:

rymsha commented 4 years ago

Hazelcast distributed sessions are enabled by storeMode = replicated parameter in com.enonic.xp.web.sessionstore.cfg In this mode all sessions are available on all XP nodes where storeMode = replicated is enabled.

LB sticky sessions are turned off: In order to work correctly sessions must be persisted as soon as they get created and as soon as they are responded:

saveOnCreate = true
flushOnResponseCommit = true

LB sticky sessions are turned on on root context (/):

For performance reasons it may be good idea to minimize session persistence (this is default setting)

saveOnCreate = false
flushOnResponseCommit = false

However any long living request (i.e. long-polling, SSE, websocket?) within a session may not allow session to be persisted and session may be lost when session-initiating server crashes.

LB sticky sessions are turned on on specific path (i.e. /admin):

Is currently not recommended, because XP supports session cookie only on root path. Session cookie can then be created when user visits /admin pages, and stay with user even while she visits other paths.

Anyway to work properly persistence settings should be same as in case of sticky sessions turned off.

saveOnCreate = true
flushOnResponseCommit = true

For configurations without long living requests it may be sufficient to persist sessions only on create

saveOnCreate = true
flushOnResponseCommit = false
sigdestad commented 4 years ago

How does this relate to enabing Hazelcast + controlling which nodes may hold the actual distributed data (aka data=true)

rymsha commented 4 years ago

It doesn't. Why?