A media streaming platform hosts its user profile service on AWS. The application is designed to store user session state locally in the memory of the individual Amazon EC2 instances that host the service. An Auto Scaling group automatically scales the number of EC2 instances out or in based on traffic demand. During off-peak hours, when the Auto Scaling group terminates underutilized instances, active users whose sessions were hosted on those specific instances are suddenly logged out and lose their progress. To align with AWS cloud design principles and prevent session loss, how should the application architecture be modified?
- Store the session state in a centralized, external data store such as Amazon ElastiCache or Amazon DynamoDB, making the web tier stateless.Cevap
- BDisable scale-in actions within the Auto Scaling group so that instances are never terminated once they are launched.
- CConsolidate the service onto a single, high-capacity Amazon EC2 instance to ensure all user session data is held in a centralized local memory space.
- DUse AWS CloudFormation to automatically redeploy the entire application stack whenever a user session is disconnected.
Cevap
Store the session state in a centralized, external data store such as Amazon ElastiCache or Amazon DynamoDB, making the web tier stateless.
Storing the session state in a centralized, external data store (such as Amazon ElastiCache or Amazon DynamoDB) makes the web tier stateless. This aligns with AWS design principles because the EC2 instances become completely interchangeable. When instances scale in or out, or if an instance fails, users are not logged out because their session data is safely retrieved from the external database or cache.
Adım Adım Çözüm
Anahtar Kavram
Statelessness and Decoupling Application State