AWS Certified Developer - Associate

Load Balancing AutoScaling

Sticky sessions

In this lesson, we explore Sticky Sessions—also known as Session Affinity—a feature that enables Elastic Load Balancers to bind a user's session to a specific instance. This ensures that all subsequent requests from that user are consistently processed by the same instance, which enhances session continuity and improves overall user experience.

Without Sticky Sessions enabled, the Load Balancer distributes incoming requests randomly across available instances. For example, a user's first request might be processed by instance A, the second by instance B, and the third by instance C, leading to a potentially inconsistent session experience.

Session Affinity Benefit

Enabling Sticky Sessions ensures that if a user's initial request is handled by a particular instance (e.g., instance A), then every subsequent request from that user will be routed to instance A. This consistent routing is vital for applications where session data must persist across multiple requests.

The image illustrates the concept of sticky sessions, comparing request distribution without sticky sessions (requests go to different instances) and with sticky sessions (all requests go to the same instance).

This behavior is applied on a per-user basis. For instance, if one user’s traffic is continuously routed to instance A, traffic from another user might be consistently sent to instance B. Each user’s session remains isolated and consistently served by the designated instance.

For further insights on load balancing and session management, refer to the related AWS Documentation.

Watch Video

Watch video content

Previous
Application Loadbalancer Demo