DVA-C03 practice question: Architectural patterns and decoupling (2 of 2)
Development with AWS Services A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A quiz app runs on Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer.
Each player's score and current question are kept in the memory of the instance that serves that player. When the group scales in, players lose their progress. The developer must let any instance serve any player while keeping scale-in working.
What should the developer change?
Choose one answer.
AA. Store each player's progress in Amazon ElastiCache, which all instances share.
BB. Turn on sticky sessions on the load balancer so each player stays on one instance.
CC. Increase the instance size so each instance has more memory for player progress.
DD. Write each player's progress to the instance store volume of the instance that serves them.
Show the answer and explanation
Answer: A
A. Right: Correct. Moving progress out of the instances makes the web tier stateless, so any instance can serve any player. Scale-in then removes an instance without removing anyone's progress.
B. Wrong: Sticky sessions keep a player on one instance, but when that instance is deregistered or unhealthy, the load balancer moves the session to another target and the progress on the old instance is lost. Scale-in still loses progress.
C. Wrong: Larger instances still keep progress locally. When scale-in terminates one of them, the progress held there is lost just the same.
D. Wrong: Instance store is local to one instance, and its data does not survive when that instance is terminated. It fails the same requirement as in-memory storage.
Explanation
A stateless design keeps no player state on the compute layer. A shared in-memory store such as ElastiCache lets any instance read any player's progress, so the Auto Scaling group can scale in freely. Sticky sessions, bigger instances and local storage all keep the state on the instance that is about to be removed.
Want more on Architectural patterns and decoupling? The 5 full-length practice sets have 5 more Architectural patterns and decoupling questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →