1

I'm using PHP sessions without an expiration period, using Amazon EC2 Elastic Load Balancing with Sticky Sessions.. What happens to the generated application sticky session on the load balancer? When will the stickiness expire?

Will
  • 1,147
  • 10
  • 26
  • That really depends and you don't provide sufficient information for a good answer. What loadbalancer, which loadbalancing method (for instance based client IP-address or is the preferred node set in a cookie, just TCP/IP, HTTPS or not, maybe terminated at loadbalancer?) Are your PHP sessions shared between nodes, etc.? – HBruijn Nov 25 '15 at 13:38

1 Answers1

0

From the documentation:

The load balancer uses a special cookie to track the instance for each request to each listener. 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 instance specified in the cookie. If there is no cookie, the load balancer chooses an 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 instance. The stickiness policy configuration defines a cookie expiration, which establishes the duration of validity for each cookie. The cookie is automatically updated after its duration expires.

If an instance fails or becomes unhealthy, the load balancer stops routing request to that instance, and chooses a new instance based on the existing load balancing algorithm. The request is routed to the new instance as if there is no cookie and the session is no longer sticky.

If a client switches to a different listener, stickiness is lost.

So, it depends on your ELB configuration and depends what you set the Expiration Period for session stickiness.

(Optional) In Expiration Period, enter the cookie expiration period, in seconds. After this period, the cookie is considered stale. If you do not specify an expiration period, the sticky session lasts for the duration of the browser session.

So, if you don't specify an expiration period, it will last as long as the PHP session lasts.

Will
  • 1,147
  • 10
  • 26