Web tier: servlets, JSP, Web frameworks: How to maintain session information across servers?
Suppose we have more than one server serving the client requests. Say, for a particular client, first time the request goes to one server, but next time the request goes to another server. In such a scenario, how can we maintain the session info created in the first request to be taken to all the other servers as well......
- Posted by: Prashant Gupta
- Posted on: April 11 2001 08:15 EDT
To put simply, how can the session info be shared across the servers when there are more than 1 server to serve the requests?
- How to maintain session information across servers? by Miguel Perez on April 11 2001 09:02 EDT
- How to maintain session information across servers? by Raj Rajen on April 11 2001 10:53 EDT
- How to maintain session information across servers? by Raj Rajen on April 11 2001 10:56 EDT
- How to maintain session information across servers? by Sudhakar k on April 11 2001 14:29 EDT
- How to maintain session information across servers? by Tony Brookes on April 13 2001 15:22 EDT
Session information is server related, there's no way to do it in an easy way. The only option is communicate the session information from one server to the other by the GET or POST methods, replicating session information
The answer to your question depends on what application server you are using. Some of the big name vendors provide "session affinity" as a feature. If you are using such an appserver then I'd suspect that it is a matter of setup and configuration.
If that is not the case, you are faced with the scalability issues surounding "sticky sessions".
I recently came across an article that talks about rolling your own session management technique. Perhaps this can help you. Please be adviced that the article uses the file system (text files?) to persist sessions. This may not be efficient in my opinion, perhaps the approach can be modified to use an RDMS to persist the sessions.
Please take a look at the following threads as well:
Hope this helps.
Some of the appservers save sessions to database. I think
if the appserver supports Servlet clustering and if your
severs are setup to support then there is no action
required from the programmer.
The only interesting thing that arises, if the container is doing the hard work, is how you prevent two frames (which go to two different servers, for the sake of argument) from running one piece of code which you want to ensure single threaded access to.
In the one server world, you can sync on the HttpSession, or something in it.
You can't do this in a multi-server world.
Maybe it's a contrived situation.