Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is maintaining a multiplayer online game that stores player state in an Amazon DynamoDB table. The table primary key consists of a partition key Region (e.g., 'US-East', 'EU-West') and a sort key PlayerID. During a peak tournament, players in the 'US-East' region experience latency and receive ProvisionedThroughputExceededException errors. CloudWatch metrics indicate that the table's overall consumed write capacity is well below the provisioned limit. Which action should the developer take to resolve this issue and prevent it from recurring?

  1. Redesign the primary key to use a partition key with higher cardinality, such as a combination of Region and a hashed suffix of PlayerID, to distribute write requests evenly across partitions.Cevap
  2. B
    Increase the overall provisioned Write Capacity Units (WCUs) of the DynamoDB table to accommodate the peak write throughput of the application.
  3. C
    Modify the query operations to perform a table-wide Scan operation with a filter expression on Region to bypass the partition-level bottlenecks.
  4. D
    Hardcode an IAM user access key and secret key with full DynamoDB access directly in the application code initialization to ensure the SDK has permissions to bypass throughput limits.

Cevap

Redesign the primary key to use a partition key with higher cardinality, such as a combination of Region and a hashed suffix of PlayerID, to distribute write requests evenly across partitions.
Redesigning the primary key with higher cardinality (e.g., sharding/salting) distributes requests across multiple physical partitions, which prevents exceeding the 1,000 WCU limit on any single partition.

Adım Adım Çözüm

1
Analyze the exception and metrics
Identify that the ProvisionedThroughputExceededException occurs even though the overall consumed capacity is below the limit, indicating a partition hotspot.
DynamoDB partitions have individual throughput limits (1,000 WCUs and 3,000 RCUs). If a single partition key receives traffic exceeding this limit, throttling occurs regardless of overall table settings.
2
Evaluate schema design
Determine that using 'Region' as a partition key leads to low cardinality, as many players will share the same region, creating a hot partition.
Good partition key design requires high cardinality to distribute read and write operations uniformly across all available partitions.
3
Implement write sharding (salting)
Add a random or hashed suffix to the partition key (e.g., 'US-East-1', 'US-East-2') to distribute the load across multiple physical partitions.
This strategy, known as write sharding or salting, ensures that writes to a single region are spread across different partitions, avoiding the 1,000 WCU per-partition limit.

Anahtar Kavram

DynamoDB partition key design and sharding to avoid hot partitions
Bu soruyu puanla