Session Failover - JSP

Session Failover

One issue that needs to be addressed is what happens if your server goes down while sessions are running.What happens to all the objects bound to the session? Imagine visiting your local grocery store with a full cart, and then someone from the store takes your cart away and tells you that you need to start again with an empty cart.You would not want to go back there in a hurry! This is what could happen to your online customers if you do not have a strategy for session failover.

Tomcat does not have any built in session failover support, which is a frustration to many developers (just take a look at some of the newsgroups!). However, if you are developing an application to run on one of the application servers such as Web Logic from BEA, Sun ONE, and so on, there is built in support for session failover.

To be able to have session failover, you really need at least two instances of your server running, ideally on different machines.

What the application servers provide for you is a mechanism by which the session information from one machine is backed up to the other machine throughout the duration of a session. If either machine goes down for some reason, the active sessions can be continued on the other machine using the backed-up data. Figure shows the process.

A typical session failover architecture.

A typical session failover architecture.

In Figure you will note the presence of a load balancer.The load balancer is there to spread the session load across all your servers. Application server vendors will typically provide this for you. In the diagram, the user has been assigned to application server A, and as they are navigating the site, maybe adding products to their shopping cart, that information is being backed up to application server B. If application server A goes down for some reason, application server B can pick up the sessions using the backed up data. This can be seen in Figure which is based upon the same architecture as Figure

Resolving a server crash.

Resolving a server crash.

As you can see from the diagram, the load balancer automatically redirects the client to the appropriate available server, and then picks up the session from the backup information.

In terms of how this facility is achieved, the various application server vendors have adopted differing approaches.

When using a distributed session management solution, objects that are bound to sessions will need to be Serializable because they will need to be streamed to the other server VMs.This can also have performance implications if these objects are large, so you need to consider the size of objects that are going to be bound to sessions to avoid a negative impact on performance.This needs to be taken into account when planning the implementation of a site.

Configuring the distributed session management is done within most servers by either editing XML-based deployment files, or via a browser interface.Figure shows the browser-based interface provided by the ATG Dynamo Application server.

Configuring session backup in the ATG dynamo application server.

Configuring session backup in the ATG dynamo application server.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JSP Topics