Web Session Clustering: No Session Left Behind
Web session clustering provides freedom of load balancing user sessions to any app server without losing intermediate user session data. Why? Because underneath it takes advantage of in-memory distributed caching technology which ensures that user sessions are available in memory regardless of which server is hit. With this approach fault tolerance comes automatically - if a server crashes, simply go to another server and your session will still be available. All of this happens transparently to user who simply continues to browse and add items to the shopping cart as if nothing happened.
As an example, diagram below illustrates how web session clustering works in GridGain:
With GridGain In-Memory Database technology (IMDB) web sessions will be either replicated to all servers or partitioned across the cluster, where every cluster node will serve as a primary node for a particular web session. In case of partitioned strategy, it is possible to configure any number of backup copies within the cluster to ensure fault tolerance. All sessions will be eagerly removed from cache whenever they expire in the app server to free up memory space for others.
Configuration is as easy as adding a few lines into your web.xml file, like so:
... <!-- Declare listener for web sessions caching. --> <listener> <listener-class> org.gridgain.grid.cache.websession.GridWebSessionServletContextListener </listener-class> </listener> <!-- Specify GridGain configuration (relative to GRIDGAIN_HOME). --> <context-param> <param-name>GridGainConfigurationFilePath</param-name> <param-value>/examples/config/spring-cache.xml</param-value> </context-param> <!-- Specify the name of GridGain cache for web sessions. --> <context-param> <param-name>GridGainWebSessionsCacheName</param-name> <param-value>session-cache</param-value> </context-param> ...Once configured, simply bring up as many instances of your favorite app server and web sessions will be automatically clustered and cached in memory.