Generic Web Session ReplicationWeb Session Replication is replicating web session to other members of the cluster each time there is a change in the session data. With session replication, session-failover is automatic. If an application server goes offline, the load balancer simply sends incoming requests to another server. The user can be sent to any server, since all servers have a copy of the user’s session.
Hazelcast Open Source Generic Session ReplicationWith Hazelcast® Open Source Generic Session Replication, you can easily store your user sessions in Hazelcast. Let’s say you have more than one web server (A,B,C) with a load balancer. And when a server goes down, you don’t lose user sessions. Users will be routed to other servers (B or C) but they will continue their transactions: users don’t notice whether A is up or down. You can also scale your web servers. You can add new servers to your cluster or shut down servers from cluster. You will not lose any sessions. Tomcat or Jetty, consider using Hazelcast IMDG® Native Session Replications over the Open Source Session Replication Module. Native Modules are more development operations friendly and better integrated into Tomcat and Jetty for better performance.
RequirementsThe following are required for enabling Hazelcast Session Clustering.
- The target application or web server should support Java 1.5+
- The target application or web server should support Servlet 2.4+ spec
- The session objects that need to be clustered have to be serializable
Easy to Set UpYou don’t change anything in your application. You only need to perform some configuration to easily attach Hazelcast Session Replication to your web applications. Put the
hazelcast-wmjars in your
WEB-INF/libdirectory. Optionally, if you wish to connect to a cluster as a client, add
hazelcast-clientas well. Put the following XML into the
web.xmlfile. Make sure Hazelcast filter is placed before all the other filters, if there are any: for example, you can put it at the top.
<Server> ... <Listener className="com.hazelcast.session.P2PLifecycleListener"/> ... </Server>
- Put a
<Manager>element into the file
$CATALINA_HOME$/conf/context.xmlas shown below.<Context> ... <Manager className="com.hazelcast.session.HazelcastSessionManager"/> ... </Context>