An online multiplayer gaming application uses AWS Lambda behind an Amazon API Gateway to process game lobby updates. The application stores game session states in an Amazon DynamoDB table. During peak hours, a small number of extremely popular game lobbies experience rapid, successive read and write operations (multiple updates per second), resulting in frequent 'ProvisionedThroughputExceededException' errors. How should the developer modify the architecture to resolve these throttling errors most effectively?
- Migrate the session state storage to an Amazon ElastiCache for Redis cluster, configuring the application to read and write session updates directly to the in-memory cache.Answer
- BDeploy an Amazon DynamoDB Accelerator (DAX) cluster in front of the DynamoDB table to cache session data, leveraging the write-through capability of DAX to automatically offload both read and write traffic.
- CIncrease the provisioned write capacity units (WCUs) on the DynamoDB table and enable DynamoDB Auto Scaling to dynamically adjust the capacity during peak hours.
- DCache the active session states in the local memory or the /tmp directory of the AWS Lambda execution context to reuse them across subsequent invocations.
Answer
Migrate the session state storage to an Amazon ElastiCache for Redis cluster, configuring the application to read and write session updates directly to the in-memory cache.
Migrating the session state storage to Amazon ElastiCache for Redis is the correct solution because it is designed to handle high-throughput, low-latency in-memory reads and writes. This removes the write-intensive session updates from the relational or DynamoDB database completely, resolving the hot partition bottleneck.
Step-by-Step Solution
Key Concept
Caching strategies and session state management for write-heavy hot-key workloads using ElastiCache vs DAX vs DynamoDB.