Hi, I was going through session management chapter in HFJS. It talks about the session migration. Why are we migrating the session object, and keeping only one session object for the client across all the VMs of a distributed app? Cant we just duplicate it, like it does for the servlet context and servlet config objects? it says the container does load balancing by taking the client requests and forwarding it to another VM. so we have the request, and we wil be able to get the session from this. im not able to understand why we need to keep the single session object copy.
the session management built-in into Tomcat effectively does replicate sessions as far as I know. If a node in a cluster fails it would surely be too late to try to migrate a session to another node. So it makes sense that sessions are always replicated to all other nodes of a cluster. The thing that's really "migrating" is the user connection which migrates to another node in case of a failure. I think migration and replication can be used synonymously here.
Marco [ November 04, 2008: Message edited by: Marco Ehrentreich ]
Thank you Marco. Is this the case for Tomcat alone? or for every container? Could you please explain user connection also? is it similar to forwarding the user request to the next available node, in case of failures?
Unfortunately I don't know if it's the same for other containers. I don't even know how exactly it works for Tomcat. But I'm pretty sure it must works similarly for every container who natively supports clustering (HTTP) sessions. It should be save to forward subsequent user requests belonging to the same HTTP session (this is what I meant with user connection ) to another node of the cluster in case of a failure or intentionally with a load balancer for example. As I already said it wouldn't make sense to wait until a node fails and then try to migrate a session from this dead host.
Of course there are other possibilities to handle user sessions in a cluster like a common database etc. And I can imagine that this internal cluster support of Tomcat (or other containers) won't be the best way if you have more than just a few hosts because replicating all session data immediately to all other nodes will cause lots of traffic.