RideFlow is a ride-sharing platform that logs completed trips to an Amazon DynamoDB table. The table is configured with provisioned write capacity. The table's partition key is CityID and the sort key is TripTimestamp. During peak commute times, the platform experiences a high volume of writes for the city code NYC. As a result, the application logs ProvisionedThroughputExceededException errors, even though the total consumed write capacity units (WCUs) for the entire table are significantly below the provisioned threshold. Which strategy should a developer implement to resolve this throttling issue?
- Modify the write logic to append a random numeric suffix to the CityID partition key, distributing the write workload across multiple partition keys.Answer
- BIncrease the visibility timeout of the upstream Amazon SQS queue that processes trip writes to allow the consumer more time to write to the table.
- CModify the query logic to use a Scan operation with a filter expression on CityID and TripTimestamp to bypass partition level limits.
- DHardcode the AWS credentials and configure a static retry limit of zero in the AWS SDK client configuration to prevent the SDK from retrying throttled requests.
Answer
Modify the write logic to append a random numeric suffix to the CityID partition key, distributing the write workload across multiple partition keys.
The correct solution is to modify the write logic to append a random numeric suffix to the CityID partition key. A single DynamoDB partition is limited to 1,000 WCUs. Since 'NYC' has a high volume of writes during peak times, it exceeds this partition-level limit even if the table's overall provisioned throughput is underutilized. Appending a random suffix distributes the writes across multiple partition keys (e.g., NYC_1, NYC_2) and thus across multiple physical partitions, resolving the hot partition throttling.
Step-by-Step Solution
Key Concept
Resolving hot partition keys and partition throttling via write sharding in DynamoDB.
Estimated Time:2m 0s