ELB - Sticky Sessions
Session Affinity
It is possible to implement stickiness so that the same client is always redirected to the same instance behind a load balancer
This works for Classic Load Balancer, Application Load Balancer, Network Load Balancer
The "cookie" used for stickiness has an expiration date you control
Use case: make sure the user doesn't lose his session data
Enabling stickiness may bring imbalance to the load over the backend EC2 instances
Cookie Names
-
Application-based Cookies:
- Custom cookie: generated by the target - don't use AWSALB, AWSALBAPP, AWSALBTG(reserved for use by ELB)
- Applicaiton cookie: generated by the load balancer - cookie name is AWSALBAPP
Duration-base Cookies: generated by the load balancer. Cookie name is AWSALB (for ALB), AWSEL (for CLB)
Cross-Zone Load Balancing
-
Application Load Balancer
- Enabled by default (can be disabled at the Target Group Level)
- No charges for inter AZ data
-
Network Load Balancer & Gateway Load Balancer
- Disabled by default
- You pay charges ($) for inter AZ data if enabled
-
Classic Load Balancer
- Disabled by default
- No charges for inter AZ data if enabled