By using AWS re:Post, you agree to the AWS re:Post Terms of Use

AWS Application Load Balancer, sticky sessions, and failover

0

Current configuration is an Application Load Balancer with cookie-based sticky sessions, and a few application servers behind it.

Our issue is that sticky sessions don't seem to transfer from one server to another if one of the servers fails the health check. What happens is that the ALB will continue to send sessions that were "stuck" to the server to it, even though it has failed the health check.

is there any way around this?

asked 3 months ago241 views
2 Answers
1
  1. Check ALB Health Check Configuration: Verify the health check path and settings. Adjust health check intervals and thresholds for quicker detection of failures.
  2. Enable "Stickiness Cookie Expiration": Set a cookie expiration time to periodically re-evaluate sticky sessions.
  3. Use a Custom Stickiness Cookie: Consider using a custom stickiness cookie for more control over session routing.
  4. Session Timeout Handling: Ensure the application can handle session timeouts and re-establish sessions on new servers.
  5. Application-Level Session Management: Use a centralized session store (e.g., Amazon ElastiCache) to manage sessions across servers.
  6. Deploy More Resilient Instances: Ensure sufficient instances in the target group to handle failover.
  7. Automated Instance Replacement: Use AWS Auto Scaling to automatically replace unhealthy instances.
profile pictureAWS
EXPERT
answered 3 months ago
profile picture
EXPERT
reviewed 3 months ago
  • Thanks for your reply. Regarding your points:

    1. Health checks are working correctly, and they show an application server down when it is down, and up when it is up.
    2. Stickiness cookie expiration is set to 1 day.
    3. We do this already.
    4. This is working correctly. Server timeout settings are less than ALB timeout values.
    5. We use a localized halzelcast for session replication for latency reasons.
    6. This is working correctly.
    7. This is what we are working towards, and this is the first part of it.
1

Hi there,

Based on the documentation, both duration & application based stickiness will route the traffic to a new target if the existing target becomes unhealthy. Can you check if your ALB health check is properly configured? It can be caused by properties like HealthCheckIntervalSeconds and UnhealthyThresholdCount to cause delays in switching to the new target.

"If the cookie is present but cannot be decoded, or if it refers to a target that was deregistered or is unhealthy, the load balancer selects a new target and updates the cookie with information about the new target."

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/sticky-sessions.html#duration-based-stickiness

answered 3 months ago
profile picture
EXPERT
reviewed 3 months ago
profile pictureAWS
EXPERT
reviewed 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions