A solutions architect is designing a database schema for a smart utility grid system that collects hourly electricity usage readings from millions of smart meters. The data is written to an Amazon DynamoDB table. The table is currently configured with a partition key of `ReadingDate` (formatted as `YYYY-MM-DD`) and a sort key of `MeterID#Timestamp` to support daily regional reporting queries. During peak reporting hours, the application experiences write throttling and receives `ProvisionedThroughputExceededException` errors, even though the total consumed Write Capacity Units (WCUs) are far below the table's provisioned limit. Which database design modification will resolve this write throttling and optimize performance?
- Redesign the DynamoDB table to use `MeterID` as the partition key and a composite sort key of `ReadingDate#Timestamp`, and create a Global Secondary Index (GSI) with `ReadingDate` as the partition key to support the daily reporting queries.Answer
- BChange the partition key to `Timestamp` (formatted as `YYYYMMDDHHMMSS`) to ensure that write operations are spread sequentially and chronologically across the table partitions.
- CRetain `ReadingDate` as the partition key, switch the table's capacity mode to Provisioned with Auto Scaling enabled, and configure a high maximum Write Capacity Units (WCU) threshold.
- DMigrate the smart meter database to Amazon RDS for PostgreSQL and configure multiple Read Replicas in different Availability Zones to handle the high write throughput and act as failover targets.
Answer
Redesign the DynamoDB table to use MeterID as the partition key and a composite sort key of ReadingDate#Timestamp, and create a Global Secondary Index (GSI) with ReadingDate as the partition key to support the daily reporting queries.
Redesigning the table to use a high-cardinality attribute like the meter identifier as the partition key distributes the write workload evenly across all partitions. By pairing it with a composite sort key containing the date and timestamp, and setting up a global secondary index with the date as the partition key, the application can distribute writes to avoid throttling while still enabling efficient daily reporting queries.
Step-by-Step Solution
Key Concept
DynamoDB partition key design and hot partition prevention
Estimated Time:2m 0s