An inventory management application for a retail chain stores real-time stock levels in an Amazon DynamoDB table. The table schema uses `StoreID` as the partition key and `ItemSKU` as the sort key. During a promotional event, a few flagship stores experience a sudden, massive surge in sales, resulting in write requests to those specific store partition keys exceeding writes per second. The application encounters `ProvisionedThroughputExceededException` errors, although the table's total provisioned write capacity is largely underutilized. Which strategy should a solutions architect implement to resolve this database performance bottleneck with minimal impact on latency?
- AEnable DynamoDB Auto Scaling for the table and switch the capacity mode to On-Demand to automatically provision additional capacity during spikes.
- Append a calculated hash or a random integer suffix to the StoreID partition key during write operations, and update the application query logic to read across the sharded partition keys.Cevap
- CRecreate the table using ItemSKU as the partition key, and create a Global Secondary Index (GSI) with StoreID as the partition key to support store-specific queries.
- DMigrate the database to an Amazon Aurora PostgreSQL Multi-AZ cluster, and configure the application to distribute the write load across the reader endpoints.
Cevap
Adjust the write path to append a calculated hash or a random integer suffix to the partition key (write sharding), and query across the sharded keys to distribute the load.
The correct option is to implement write sharding by appending a suffix to the partition key. A single partition key in DynamoDB can only support up to WCUs per second. By appending a suffix (e.g., `StoreID_1`, `StoreID_2`), the writes for a single store are distributed across different physical partitions, resolving the hot partition throttling.
Adım Adım Çözüm
Anahtar Kavram
DynamoDB partition design and write sharding to overcome partition limits.
Tahmini Süre:2m 0s