Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Assuming a cluster of webservers on EC2 with both Elastic Load Balancing and Auto Loading (meaning instances start and die based on demand), can someone tell me what happens to a user's browser's session? Is the load balancer smart enough to track sessions? Or at least smart enough to send a particular user's requests to the same instance consistently? Or do I have to find and manage a solution to this problem myself?

share|improve this question
add comment

3 Answers 3

Need more information, it depends on how you are implementing your sessions. Although some load balancers are 'smart' enough to redirect based on sessions, relying on that really just means your architecture is broken in the first place.

Ideally you want either a centralized or distributed session store. Good options are a centralized database like MySQL, or something distributed like memcached. You probably want to start with the database, and move to memcached if you really start gaining traffic.

What framework or language is your application using?

share|improve this answer
    
The platform is JBoss with MySQL. JBoss supports clustering through multicast (not supported on EC2). Putting the session in the database is an option. Another possible option is having the JBoss instances cluster through the use of a 'gossip' server. My question is to what degree can I rely on EC2 for session handling. –  PrepStyles Aug 17 '09 at 2:02
    
Your framework should be handling the session, not EC2. Configure JBoss to store the session in the database, and you will have no worries :) –  anveo Aug 17 '09 at 20:40
add comment

No, ELB is not a sticky session based load balancer. It is a 'not strict round robin' based load balancer that does not take into account your session scheme. Some details are investigated here: http://clouddevelopertips.blogspot.com/2009/07/elastic-in-elastic-load-balancing-elb.html

If you want to use elb then you need to make sure your session scheme can deal with the requests being routed to any of the servers in the elb pool at any request.

share|improve this answer
add comment

You have two options.

Your best option is to do as anveo said. Using a centralized session store means that they can hit any one of your servers and still have their session. You can spin up and terminate instances without worrying about the effect on the users.

Another option is the use the stickiness option of the ELB. You can create session cookies and the load balancer will route a session cookie to the same instance each time. The problem with this is that you can not freely kill instances because people will lose their sessions (if that matters). The only upside to this method is that it is extremely simple to implement. And losing sessions isn't that bad normally. The user would just log back in again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.