DEV Community

Aadit Unni
Aadit Unni

Posted on

Session Stickiness in Application Load Balancer

[27/100] #100DaysOfCloud Today, I learned about Session Stickiness in Application Load Balancer.

I used a CloudFormation template to create the resources needed like VPC, Subnets, Auto Scaling Group, Launch Template, EC2 instances, Application Load Balancing etc automatically.

Stickiness is not enabled in this.
I tested the load balancer distribution and then enabled session stickiness and noticed that it was locked on to one instance.

  • The sticky session feature (also known as session affinity) enables the load balancer to bind a user's session to a specific target. This ensures that all requests from the user during the session are sent to the same target. This feature is useful for servers that maintain state information in order to provide a continuous experience to clients. To use sticky sessions, the client must support cookies.

  • Application Load Balancers support both duration-based cookies and application-based cookies. Sticky sessions are enabled at the target group level. You can use a combination of duration-based stickiness, application-based stickiness, and no stickiness across your target groups.

  • The key to managing sticky sessions is determining how long your load balancer should consistently route the user's request to the same target. If your application has its own session cookie, then you can use application-based stickiness and the load balancer session cookie follows the duration specified by the application's session cookie. If your application does not have its own session cookie, then you can use duration-based stickiness to generate a load balancer session cookie with a duration that you specify.

You can try do it by yourself by following the steps from the link below: GitHub

Top comments (0)