Tuesday, May 27, 2008

Clustering

Clustering mainly used to support failover.

Facts about web application deployed on clustered environment.

There is one instance of ServletContext, Servlet per JVM.
There is only one instance of HttpSession in distributed application for given user.
Attributes inside session implementing Serializable interface are replicated to different JVM’s.

So interesting thing is how and when session is propogated and
other things that are dependent on this behaviour.

Like how HttpSessionActivationListener comes into picture with all this. What does it mean by session activation and session passivation.

We will see how weblogic goes about implementing this.


Weblogic has the term called Sticky Sessions. This means weblogic takes care that all request of user during session active time are transferred to same instance of the server.

So when does propagation of session occurs.

Session replication happens always when you set attributes to session using setAttribute() method. Whenever attribute is set to using this method container replicates delta in session to the secondary server. So even though Weblogic uses sticky session technique when the instance to which user session is stick is failed container forward request to secondary session where user sessions replica is already maintained.
More details for this technique are available at: http://edocs.bea.com/wls/docs90/cluster/failover.html

So now about HttpSessionActivationListener. This is binding interface that attributes stored in session should implement if they want to be called back by container in case of session activation or passivation. Containers migrate sessions to different JVM's or persists them into database. Attributes implementing this interface will be called by container when it performs these activities.

No comments: