I would like to know, How HttpSession works on Load balancer? How Load balancer knows for the particular request need to send the respective Web Server?

Here's what I would guess:
1. load-balancer works based on user's region like county, state.
2. load-balancer works based on user IP address range
3. load-balancer works based on Cookies management.

  • How do you want it to work? You say that the session is stored in a web container, but is it a) stored in a shared database, or b) replicated or otherwise available to other nodes using a mechanism such as EHCache, or c) not replicated. – Cameron Kerr May 6 '15 at 11:07
  • And what middleware solution are you using? – Cameron Kerr May 6 '15 at 11:08
  • Why can't you put your sessions in a key-value store shared by all your app servers ? – user186340 May 7 '15 at 5:10

If the web application requires that a user stay connected to the same server, then the load balancer has to understand the session management method of the web application. For example, the load balancer can inject its own cookie in to the session that says which backend server to connect to. The load balancer can also read a cookie placed by the web app. If that's not an option, then the load balancer can maintain an IP address table.

  • I really appreciate your answer. Could you plz help to get understand, how does Facebook or Google manage – Premraj May 6 '15 at 11:15
  • The first part would be using Global Server Load Balancing (GSLB) or such to determine which region the user is coming from. Then, I suspect that the session data may remain within that region, and likely be replicated to some extent. A cookie would very likely be used to steer the user to the same processing node within a cluster (if possible). – Cameron Kerr May 6 '15 at 11:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.