SAP-C02 Question 444
Single answerAn e-commerce company wants to migrate its monolithic application to a microservices architecture on AWS. The application requires session state to be shared across multiple instances of microservices for user authentication and shopping cart functionality. Which solution is the most cost-effective and scalable for storing session state?
- A
Use Amazon RDS with a Multi-AZ deployment to store session state in a relational database table.
- B
Use Amazon DynamoDB to store session state with DynamoDB TTL enabled for automatic expiration.
- C
Store session state on Amazon EFS and mount the file system across all microservice instances.
- D
Leverage Amazon ElastiCache for Redis to store session state with replication enabled.
Show answer and explanation
Correct answer: B
Explanation
For scalable and cost-effective session state management in a microservices architecture, Amazon DynamoDB is the best option. It provides high availability, low-latency access, and features like TTL for automatic expiration of session data, which suits the requirements of the e-commerce application. While ElastiCache for Redis is also a good option for session state, it is generally more costly and requires additional management, making DynamoDB the optimal choice.
- A. Incorrect.
Amazon RDS is a relational database service and provides high availability with Multi-AZ deployment. However, it is not the most cost-effective or scalable option for session management as relational databases can become a bottleneck under high traffic.
- B. Correct.
Amazon DynamoDB is a fully managed NoSQL database that is highly scalable and cost-effective. With DynamoDB TTL (Time to Live), session state can automatically expire when no longer needed, making it an ideal choice for this use case.
- C. Incorrect.
Amazon EFS is a managed file system for shared storage across instances. While it can be used for storing session state, it is not optimized for high-speed, low-latency access required for session management and would incur higher costs compared to DynamoDB or ElastiCache.
- D. Incorrect.
Amazon ElastiCache for Redis is a highly performant in-memory data store that is well-suited for session state. However, it is typically more expensive than DynamoDB and requires additional management for replication and backups.