Question

Difficulty: HardAuto Scaling and Elastic Load Balancing (ELB)

An enterprise is migrating a stateful legacy web application to AWS. The application runs on Amazon EC2 instances managed by an Auto Scaling group (ASG) behind an Application Load Balancer (ALB). The application listens on custom port 8080. During testing under load, users experience session loss and are forced to log in repeatedly when the application scales. Additionally, during scale-in events, users whose requests are currently being processed experience immediate connection drops and HTTP 502/504 errors. The network and security teams require strict control over VPC boundaries using both security groups and Network ACLs (NACLs).

Which two actions should a solutions architect take to resolve the session issues and prevent request failures during scale-in? (Select two.)

  1. Enable sticky sessions (session affinity) on the Application Load Balancer target group using duration-based cookies.Answer
  2. Configure a deregistration delay (connection draining) on the Application Load Balancer target group.Answer
  3. C
    Change the target group's health check port to the default HTTP port 80 to prevent health check traffic from saturating the application on port 8080.
  4. D
    Configure stateless Network ACLs on the instance subnets to allow inbound traffic on port 8080, relying on the stateful nature of security groups to permit outbound ephemeral port responses automatically.
  5. E
    Implement an Amazon Route 53 latency routing policy pointing directly to the EC2 instances' public IP addresses to bypass the ALB and enforce session persistence.

Answer

Enable sticky sessions (session affinity) on the target group, and configure a deregistration delay (connection draining) on the target group.
To resolve the session loss issues in a stateful application, sticky sessions (session affinity) must be enabled on the Application Load Balancer target group so that a client is repeatedly routed to the same backend instance. To prevent active connections and requests from being cut off during scale-in operations, a deregistration delay (connection draining) must be configured on the target group to keep the connections alive until the in-flight requests complete.

Step-by-Step Solution

1
Address session loss by binding users to their session-holding instances.
Enabling sticky sessions (session affinity) on the target group ensures that subsequent requests from the same user are sent to the same EC2 instance, avoiding session loss.
Because the application is stateful and stores session data locally, routing requests to different instances causes session drops.
2
Address connection drops during scaling down events by delaying instance termination.
Configuring a deregistration delay (connection draining) ensures that the load balancer keeps active connections open until in-flight requests finish, up to the configured limit, before the ASG terminates the instance.
This prevents HTTP 502/504 errors and immediate session termination when the ASG attempts to scale in.

Key Concept

ELB Sticky Sessions and Deregistration Delay
Rate this question