SAA-C03 practice question: EC2 Auto Scaling (3 of 3)
Design Resilient Architectures A free question from our original SAA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A travel booking website runs on Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer.
Login sessions and shopping baskets are held in each instance's memory. When the group scales in at night, or replaces an instance that fails its health checks, the customers on that instance are logged out and lose their baskets.
Sessions must survive the removal of any instance without adding noticeable latency to each request.
Which change meets these requirements?
Choose one answer.
AA. Turn on duration-based sticky sessions on the target group, so that each customer is always routed to the same instance.
BB. Increase the target group's deregistration delay, so that instances finish serving their customers before they are removed.
CC. Move session and basket data into an Amazon ElastiCache cluster with replicas, and have the application read sessions from it.
DD. Turn on instance scale-in protection for every instance in the group, so that Auto Scaling cannot terminate instances that hold sessions.
Show the answer and explanation
Answer: C
A. Wrong: Stickiness keeps a customer on one instance, but the session still lives only in that instance's memory. When the instance is deregistered or becomes unhealthy, the load balancer sends the customer to a new target, where the session does not exist. Learn more: Sticky sessions for your Application Load Balancer (opens in a new tab)
C. Right: Correct. Moving session state off the instances makes the web tier stateless, so any instance can serve any customer and instances can be removed at will. An in-memory cache keeps session lookups fast, and the replicas hold a second copy of the session data. Learn more: REL05-BP06 Make systems stateless where possible (opens in a new tab)
The root cause is session state held on individual instances, which Auto Scaling must be free to remove. Storing sessions in a shared, fast store such as ElastiCache makes instances interchangeable. Sticky sessions, deregistration delay and scale-in protection all leave the session on the instance, so it is still lost when the instance goes.
Want more on EC2 Auto Scaling? The 5 full-length practice sets have 10 more EC2 Auto Scaling questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →