An agricultural IoT application named 'CropSense' collects hourly soil moisture data from thousands of sensors in a region. The sensor data is written to an Amazon DynamoDB table. The table is configured with a partition key of `SensorType` (which has only three distinct values: 'Moisture', 'Temperature', and 'Acidity') and a sort key of `Timestamp`. During peak reporting windows, the application experiences a high volume of `ProvisionedThroughputExceededException` errors, even though the total read/write capacity units consumed are well below the table's allocated capacity. Which of the following actions is the most appropriate way to resolve this throttling issue?
- AIncrease the table's provisioned write capacity units (WCUs) to scale up the overall write throughput limit of the table.
- BIncrease the visibility timeout of the upstream Amazon SQS queue to allow more time for the application to process each write request.
- Redesign the partition key schema by appending a random or calculated numeric suffix to the partition key (e.g., Moisture_N, where is a random integer between and ) to distribute write operations across multiple partition keys.Cevap
- DHardcode the AWS access keys directly within the SDK client initialization configuration to eliminate credential provider chain lookup latency.
Cevap
Redesign the partition key schema by appending a random or calculated numeric suffix to the partition key (e.g., Moisture_N, where is a random integer between and ) to distribute write operations across multiple partition keys.
The throttling is caused by a hot partition key because the partition key (SensorType) has low cardinality (only three values). This concentrates writes on a small number of physical partitions, exceeding the partition-level throughput limits. Appending a random or calculated numeric suffix to the partition key distributes the write operations across a larger number of logical keys, solving the partition-level bottleneck.
Adım Adım Çözüm
Anahtar Kavram
Write sharding (appending a suffix to partition keys) to distribute highly skewed workloads in Amazon DynamoDB.