Session Replication with Hazelcast Enterprise is a container specific module where no application change is required to enable session replication for JEE Web Applications.
Features
In this deployment type, Tomcat instances work as clients to an existing Hazelcast Cluster.
Features:
Configuration:
clientOnly
property as true (optional, default is false).mapName
property (optional, configured map for special cases like WAN Replication, Eviction, MapStore, etc.).hazelcast.client.config
system property or by putting hazelcast-client.xml
into classpath.hazelcast-client-<version>.jar
and hazelcast-sessions-tomcat6-<version>.jar
to $CATALINA_HOME/lib/ folder.Sample Configuration
<Context>
<Manager className="com.hazelcast.session.HazelcastSessionManager" clientOnly="true" mapName="sessionMap"/>
</Context>
This launches embedded Hazelcast Node in each server instance.
Features
This type of deployment is the simplest approach. You can just configure your Tomcat and launch. There is no need for an external Hazelcast cluster.
Configuration
mapName
property (optional, configured map for special cases like WAN Replication, Eviction, MapStore, etc.).hazelcast.config
system property or by putting hazelcast.xml
into classpath.hazelcast-<version>.jar
and hazelcast-sessions-tomcat6-<version>.jar
to $CATALINA_HOME/lib/ folder.Sample Configuration
<Context>
<Manager className="com.hazelcast.session.HazelcastSessionManager" mapName="sessionMap"/>
</Context>
Sticky Sessions (default)
Sticky Sessions are used to improve the performance since the sessions do not move around the cluster.
Request goes always to the same instance where the session was firstly created. By using a sticky session, you eliminate session replication problems mostly, except for the failover cases. In case of failovers, Hazelcast helps you not lose existing sessions.
Non-Sticky Sessions
Non-Sticky Sessions are not good for performance because you need to move session data all over the cluster every time a new request comes in.
However, with Non-Sticky caches, load balancing might be super easy as some load increasing case you can distribute the request to the least used Tomcat instance. Hazelcast supports Non-Sticky Sessions as well.