File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes session maintenance across two web-servers with loadbalancer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "session maintenance across two web-servers with loadbalancer " Watch "session maintenance across two web-servers with loadbalancer " New topic

session maintenance across two web-servers with loadbalancer

lavanya muthu

Joined: Oct 21, 2008
Posts: 3

I have two web-servers, both the web-server has its own load balacer, now my problem is when i move from server1 to server2 and back to server1 session is not getting maintained, rather it creates a new session, hence all my session values are lost.

Eg.. I move from weblogic to iplanet server and from iplanet whn am returning back to weblogic i dont see the initial session values, rather it goes null. it works perfectly if there is no load balacer.

Why there is an issue with load balancer? how to fix it? please advise
[ October 21, 2008: Message edited by: lavanya muthu ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Sessions are objects that exist within a Java Virtual machine. Any time you're load balancing, you're going to be dealing with 2 different Java Virtual Machines, and what's in the memory of JVM 1 is totally invisible to JVM 2 and vice versa.

When you use a clustering system like WebLogic provides, the sessions are serialized out to a common resource where whichever machine needs the session can go and serialize the session into its JVM. However, there's no standard mechanism or format for exporting/importing sessions, so when you mix vendors like iPlanet and WebLogic, you are almost certainly not going to be able to exchange them.

Even when you're dealing with a single vendor, you will have to configure the server to share sessions, since that's an expensive operation that's normally turned off for performance reasons.

Also pay attention to the requirement that anything in a session that you want to be clusterable MUST be serializable! The compiler won't warn you if you include non-serializable objects, and usually neither will the server. You'll only discover it when the serialized session is imported and the non-serializable items are missing.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: session maintenance across two web-servers with loadbalancer
It's not a secret anymore!