A developer is designing a stateful web application that will be hosted on Amazon ECS across multiple Availability Zones. The application requires a shared, external session store to maintain user shopping carts. The session store must support sub-millisecond read/write latency, accommodate complex data structures such as lists and hashes for cart items, and automatically expire session records after 2 hours of inactivity to control costs. Additionally, the solution must survive cache node failures without losing user session data.
Which solution should the developer implement to meet these requirements?
- Use Amazon ElastiCache for Redis with Multi-AZ and automatic failover enabled, and configure the application to store shopping cart data in Redis hashes with a Time-To-Live (TTL) of 7200 seconds.Cevap
- BUse Amazon DynamoDB to store shopping cart data, and write a scheduled background worker that runs a weekly Scan operation on the table to identify and delete inactive shopping carts older than 2 hours.
- CUse Amazon DynamoDB to store shopping cart data, configuring a single static string value as the partition key and the user session ID as the sort key to keep all active carts grouped in a single partition for rapid retrieval.
- DUse AWS Systems Manager Parameter Store to store user session data as SecureString parameters, and apply a Parameter Policy with a TTL of 120 minutes to automatically delete expired sessions.
Cevap
Use Amazon ElastiCache for Redis with Multi-AZ and automatic failover enabled, and configure the application to store shopping cart data in Redis hashes with a Time-To-Live (TTL) of 7200 seconds.
The correct solution uses Amazon ElastiCache for Redis because it supports sub-millisecond latencies, provides advanced data structures (like Redis hashes) to represent shopping cart items, and offers high availability through replication groups, Multi-AZ, and automatic failover. Setting a TTL of 7200 seconds ensures that keys expire automatically after 2 hours of inactivity.
Adım Adım Çözüm
Anahtar Kavram
Selecting ElastiCache for Redis for high-availability session state management with complex data structures and automatic key eviction (TTL).