Note: Please go to to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > Dashboard Users Guide > Clouds > AWS Regions > Load Balancing (Legacy) > Actions > Create a New Sticky Session Policy

Create a New Sticky Session Policy


To create a new Sticky Session policy for an AWS Elastic Load Balancer (ELB).

Table of Contents


  • A created ELB and two or more front end Servers that have registered with the ELB.
  • There is a AWS imposed limit of 20 policies per ELB.


By default, AWS ELB distributes requests to Instances running your application based on the lowest load.  However, you can create a Sticky Session Policy so that a request is bound to the same Instance for the length of the entire session.  Sticky sessions are based on either load balancer or application generated HTTP cookies.   This tutorial will step you through how to create a Sticky Session Policy for your ELB.


  • Navigate to CloudsAWS RegionLoad Balancing
  • Click the ELB name link you want to create a Sticky Session for
  • Click the Sticky Sessions Policies tab
  • Click the New action button.  You will be presented with a form similar to the one below.  You will need to fill out the following fields:
    • Policy Name: Enter the name of your Sticky Session Policy
    • Cookie Type: Select either 'App Cookie' or 'Lb Cookie' from the drop down menu.
      • App Cookie - Allow the application to set the session lifetime
      • Lb Cookie - Allow the Load Balancer (ELB) to set the session lifetime.  If you specify Lb Cookie, you are prompted for a Cookie Expiration Period (in seconds).  You cannot leave this field blank.
    • Cookie Name: Enter the name of the Cookie
    • Listeners:  A Sticky Session Policy can be associated only with HTTP/HTTPS Listeners.  Listeners are created when you create and configure your ELB.  Select one of the Listeners from the drop-down menu.



Additional ELB Information

The following is an excerpt from the AWS ELB Developer Guide (Sept 2010), where it speaks to the Cookie Type:

"Load Balancer-Generated HTTP Cookies

The load balancer uses a special load balancer-generated cookie to track the application instance for each request. When the load balancer receives a request, it first checks to see if this cookie is present in the request. If so, the request is sent to the application instance specified in the cookie. If there is no cookie, the load balancer chooses an application instance based on the existing load balancing algorithm. A cookie is inserted into the response for binding subsequent requests from the same user to that application instance. The policy configuration defines a cookie expiry, which establishes the duration of validity for each cookie.

For more information about the policy configuration for load balancer-generated HTTP cookies, see CreateLBCookieStickinessPolicy.

Application-Generated HTTP Cookies

The load balancer uses a special cookie to associate the session with the original server that handled the request, but follows the lifetime of the application-generated cookie corresponding to the cookie name specified in the policy configuration. The load balancer only inserts a new stickiness cookie if the application response includes a new application cookie. If the application cookie is explicitly removed or expires, the session stops being sticky until a new application cookie is issued.

For more information about the policy configuration for application-generated HTTP cookies, see CreateAppCookieStickinessPolicy.

Post Tutorial Steps

Delete a Sticky Session Policy

  • Navigate to the Load Balancer
  • Click the Sticky Session Policies tab
  • Click the Delete action icon for the policy you want to remove

Test a Sticky Session Policy

The following steps outline a basic scenario for testing ELB's in general, including Sticky Sessions.  Click the hyperlinks below if you need additional information on a specific step.

  1. Create a new Deployment
  2. Add two web Servers to your Deployment (for a basic testing example, consider an Apache Server or use our Mephisto all-in-one ServerTemplate.  For the test, make sure they are in the same Availability Zone.)
  3. Launch your Servers.  Once operational, access the public DNS address from your browser (confirm web pages are being served ok)
  4. Create a new Elastic Load Balancer
  5. Register your two Servers with the ELB 
    1. Note: It can take a few minutes to progress from 'queued' status). 
    2. Remember to check the "Register Now" if your Servers are already running and operational.
  6. Navigate to your ELB in the browser
    1. You should see an Apache home page, or Mephisto, etc. depending on what type of Server you launched.
    2. Refresh your browser several times, and/or even start another browser and visit your ELB several times
  7. SSH into both of your Servers and view your web access logs.  Over time, the requests should be evenly distributed by the load balancer
  8. Create a Sticky Session Policy
    1. Allow the Load Balancer to generate cookies
    2. Revisit your ELB in your browsers. 
      1. Requests should remain with a particular Server for the life of the session
      2. View web access logs.  Over time, they will no longer be split by one Server should be taking on additional requests, as the session should "stick".
You must to post a comment.
Last modified
22:22, 16 May 2013



This page has no classifications.



© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.