A developer is managing a high-throughput ticketing application where transaction records are stored in an Amazon DynamoDB table. The table uses EventId as the partition key and TransactionId as the sort key. During a flash sale for a highly anticipated concert, the application experiences a surge in write requests for that specific concert, resulting in ProvisionedThroughputExceededException errors. However, CloudWatch metrics indicate that the table's overall consumed write capacity is far below the total provisioned write capacity. Which approach should the developer take to resolve this throttling issue?
- AReplace the query operations with a parallel Scan operation and apply a FilterExpression on EventId to distribute the read and write load across all table partitions.
- Implement write sharding by appending a randomized suffix to the EventId partition key value, and adjust the query logic to aggregate results across these sharded partitions.Cevap
- CIncrease the provisioned write capacity units (WCUs) of the table to accommodate the peak write volume during the flash sale.
- DInitialize the AWS SDK client by hardcoding IAM credentials with administrative access to bypass DynamoDB throughput limits.
Cevap
Implement write sharding by appending a randomized suffix to the EventId partition key value, and adjust the query logic to aggregate results across these sharded partitions.
The correct option is to implement write sharding by appending a randomized suffix to the partition key. Because the throttling is caused by a hot partition key (high volume of writes to a single EventId), distributing the writes across sharded keys (e.g., EventId_1, EventId_2) allows DynamoDB to utilize multiple physical partitions. The application must then query all sharded partition keys to retrieve the full dataset.
Adım Adım Çözüm
Anahtar Kavram
Mitigating hot partition keys in DynamoDB using write sharding