Stickiness in Load Balancers


Load balancers play a crucial role in distributing incoming network traffic across multiple servers to ensure optimal resource utilization and prevent server overload. One key feature in load balancing is "stickiness." In this blog post, we'll unravel the concept of stickiness and provide a straightforward guide on configuring it in an Application Load Balancer (ALB).

Understanding Stickiness:

Stickiness, also known as session affinity, is the ability of a load balancer to bind a user's session to a specific server. This ensures that subsequent requests from the same user are directed to the same server that initially handled their request. Stickiness is particularly useful for applications that store session data locally on a server.

Configuration in Application Load Balancer (ALB): Configuring stickiness in an ALB involves a few steps. Let's break it down:

  1. Navigate to the AWS Management Console:
    • Log in to your AWS account and go to the EC2 dashboard.
  2. Select the Load Balancer:
    • Locate your Application Load Balancer in the Load Balancers section.
  3. Configure Stickiness:
    • In the ALB details, find the "Listeners" tab.
    • Edit the listener for which you want to enable stickiness.
  4. Enable Stickiness:
    • Check the box for "Enable Load Balancer Generated Cookie Stickiness."
    • Adjust the "Stickiness Duration" if needed. This determines how long the association between a user and a specific server lasts.
  5. Save Changes:
    • Save your changes, and the ALB will now use stickiness based on the configured settings.

Example Use Case: Let's consider a scenario where an e-commerce application uses stickiness. When a user logs in and adds items to their cart, their session data is stored on the server handling the request. With stickiness enabled, subsequent requests from the same user will be directed to the same server, ensuring a seamless and consistent shopping experience.

Conclusion: In conclusion, stickiness in load balancers is a valuable feature for maintaining session continuity in distributed environments. By following the outlined steps, you can easily configure stickiness in an Application Load Balancer, improving the performance and reliability of your applications.