wood burning stoves*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Load balancing and session states Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Load balancing and session states" Watch "Load balancing and session states" New topic
Author

Load balancing and session states

Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
Guys, I'm trying to understand how a web server manages user sessions in a clustered environment. Regarding this, my questions are:

1) How would a load balancer manage web server user sessions in a clustered environment?

2) Would HTTPS be treated differently to HTTP?

Your thoughts are much appreciated.
Jacek Ostrowski
Greenhorn

Joined: Feb 09, 2007
Posts: 23
Hi,

I've used Cisco CSS 15001 and it had two modes for maintaining server affinity:

A) via Cokies - load-balancer adds is own cookie to served content
B) via IP ranges - admin has to manually define IPs of clients served by each server in a cluster.

Method A doesn't work if load-balancer uses HTTPS to connect to the servers.

If load-balancer is equipped with encryption module it is possible to use method A with HTTPS. Load-balancer uses HTTP to connect to servers, adds cookie and then sends content to a client via HTTPS. This way servers don't waste CPU for HTTPS handling.

Method B doesn't support automatic failover.

Jacek
[ April 30, 2007: Message edited by: Jacek Ostrowski ]

SCEA, SCWCD, SCJP, OCA AS10g
Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
Hi Jacek,

Interesting and important points, thank for sharing! But I'm still a bit curious about session management.

For example, if the user adds an item to his shopping cart (on a new session) consider that at latter time he/she adds another item. [1] In this case, what's the behavior on a clustered environment? Would the user be forced to maintain a conversation to that web server who served him/her the first time in order to have access to the session? [2] And in this case, what roles does the load-balancer play? [3] Would HTTP or HTTPS behave differently in this scenario?

Your thoughts on this matter are much appreciated.

Regards,
Filipe
Jacek Ostrowski
Greenhorn

Joined: Feb 09, 2007
Posts: 23
Hi Filipe,

If load-balancer uses predefined IP ranges (I think that this is called sticky IP) to maintain server affinity then all request from given client goes always to same server. So from client's perspective there is only one server in a cluster. No problem with sessions here. Works regardless of used protocol.

If load-balancer uses cookies, then for first request it chooses server for a client, forwards request to chosen server and adds to response his own cookie with server ip (or anything that could be used to find this server). On following requests load-balancer finds its own cookie, then it forwards requests to server based on info from the cookie. This works only with HTTP.

All this is far beyond requirements for SCEA part 1. For exam you need to know that load-balancer needs to maintain client sessions.

Jacek
Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
Everything makes more sense now. Thanks, Jacek!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Load balancing and session states
 
Similar Threads
Load Balancer
clustered environment?
How to control jobs in a clustered environment?
Oracle 10G Clustering
Session Affinity