Load balancer and session management
Solution 1
This is where the concept of "Sticky Sessions" or "Session Affinity" comes into play.
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/US_StickySessions.html
You can configure many load balancers to route user sessions to the same machine.
Another approach would be to maintain session information in a datastore accessible by both machines behind the load balancer. If the session exists in your database (or even redis/memcached) it's just a primary key query (or get
) away from being consistent on both machines.
Self promotion: I actually started a project to implement something like a session at Buzzfeed. http://github.com/buzzfeed/phonon
EDIT: updated link to personal project.
Solution 2
This situation depends of the technology, in my experience with .Net there are two concepts called StateServer or SQLServer which are the recommendations to get the session information out of the execution process in the servers, so that's the idea, isolate the sessions in a different server or process, you can read a little bit here:
So additionally read this Read to get the difference between Load Balancing and Clusters, for some platforms is better to select the best option.
Related videos on Youtube
Praveen Kumar
Updated on September 15, 2022Comments
-
Praveen Kumar over 1 year
There is a website run by 2 servers. These 2 servers balances the load using Load Balancer. So, if 1 session is created on 1 server and say load is shift to another server immediately, then how session is maintained?
I am just interested in the concept at a very high abstract level and not real implementation details.