EC2 load balancer – difference between “Load Balancer” and “Application” Generated Cookie Stickiness

amazon ec2amazon-web-servicesload balancing

The stickiness of an elastic load balancer can be set to one of three options

  1. Disable Stickiness
  2. Enable Load Balancer Generated Cookie Stickiness
  3. Enable Application Generated Cookie Stickiness

What are the differences between 2) and 3)?

Best Answer

Both options are going to rely on HTTP cookies to make sure that each session continues to hit the same instance.

However, with option 2 (Load Balancer Generated Cookie), the EC2 load balancer will insert it's own cookie into the HTTP transaction with a specified expiration period. With Option 3 (Application Generated Cookie), you can have the load balancer check for cookies that you are already creating with your web app (like a PHP session ID) and the expiration period of the load balancer cookie will match that one.

With the 3rd option, you have some control over how the cookie expires allowing the session to move to a different instance, but with the 2nd option, your application doesn't need to be creating any cookies.

More information on this feature:

  1. http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/US_StickySessions.html
  2. http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateAppCookieStickinessPolicy.html
Related Topic