Configuring Non-Sticky Sessions
This section describes the configuration of non-sticky sessions
Why use non-sticky sessions?
Some situations require that sessions be ‘non-sticky’, which means that client requests are directed to any server in a cluster of application servers rather than returning to the same server with each request for a given client. Non-sticky sessions allow for more effective load balancing as a client operating in a model using sticky session replication will return to the same server each time regardless of load. To achieve a non-sticky session model, you must configure your deployment as described for the following modules/topologies.
Note: Non-sticky sessions affect performance because sessions need to be re-created every time a request hits a different server. This may not be noticeable when the session attributes are small, but may become more evident as the session attributes increase in size and/or number.
Configuring Non-Sticky Session Replication for Tomcat and TC Server
Peer-to-Peer
For peer-to-peer topologies, apply the following settings to enable non-sticky sessions to work correctly:
- Java system property
gemfire.loadClassOnEveryDeserialization=true
. Set this property by editing thebin/setenv.sh
file. -
prefer.deserialized.form=false
. Set this property inconf/catalina.properties
.
Client-server
- The Java system property
gemfire.loadClassOnEveryDeserialization=true
must be set, in thebin/setenv.sh
file. - The local client cache must be empty. Ensure that the
gemfire.cache.enable_local_cache
property is set to false. This effectively sets the local client cache to be a PROXY cache. - If the local client cache is a PROXY cache, then expiration must be configured to notify the client via callback, which can be done by setting
gemfire.EXPIRE_SENDS_ENTRY_AS_CALLBACK
to true. This allows the client cache to retrieve and expire the actual session object, resulting in more consistent behavior.
Configuring Non-Sticky Session Replication for WebLogic
Peer-to-Peer
No additional configuration is required.
Client-Server
- The local client cache must be empty. Ensure that the
gemfire.cache.enable_local_cache
property is set to false. This effectively sets the local client cache to be a PROXY cache. - If the local client cache is a PROXY cache, then expiration must be configured to notify the client via callback, which can be done by setting
gemfire.EXPIRE_SENDS_ENTRY_AS_CALLBACK
to true. This allows the client cache to retrieve and expire the actual session object, resulting in more consistent behavior.