A developer is building a logistics tracking application that records real-time updates for delivery packages. The system uses an Amazon DynamoDB table where the partition key is `DeliveryDate` (formatted as `YYYY-MM-DD`) and the sort key is `TransitTimestamp#PackageId`. During peak hours, the application experiences a high volume of package status updates, resulting in frequent `ProvisionedThroughputExceededException` errors, even though the total consumed write capacity is well below the table's overall provisioned capacity. Which approach should the developer implement to resolve the write throttling issue while maintaining the ability to retrieve items by date?
- AIncrease the table's provisioned Write Capacity Units (WCUs) dynamically during peak hours using an Application Auto Scaling policy.
- Append a calculated sharding suffix (such as a random integer between and ) to the `DeliveryDate` partition key when writing items, and query across all sharded partitions to retrieve data for a specific date.Cevap
- CPerform a `Scan` operation on the table using a `FilterExpression` to retrieve items by `TransitTimestamp` rather than querying the `DeliveryDate` partition key.
- DConfigure the application to initialize the DynamoDB client using static AWS access keys and secret keys hardcoded in the codebase to bypass provisioning limits.
Cevap
The approach of appending a calculated sharding suffix (such as a random integer between and ) to the `DeliveryDate` partition key when writing items, and querying across all sharded partitions to retrieve data for a specific date.
The correct approach is to append a calculated sharding suffix to the `DeliveryDate` partition key. This distributes the write operations across multiple partition keys (and therefore physical partitions), successfully avoiding the physical partition limit of WCUs.
Adım Adım Çözüm
Anahtar Kavram
Partition key design and write sharding to prevent hot partitions