Bird
0
0

You want to design a write sharding strategy for a DynamoDB table with very high write traffic on user data. Which approach best balances write load and allows efficient reads?

hard🚀 Application Q15 of 15
DynamoDB - Access Patterns and Query Optimization
You want to design a write sharding strategy for a DynamoDB table with very high write traffic on user data. Which approach best balances write load and allows efficient reads?
AWrite all data to a single partition key and batch writes
BUse user ID as partition key without sharding; rely on DynamoDB auto-scaling
CAdd shard ID to sort key and keep partition key as user ID
DAdd a random shard ID (0-9) to the partition key and store user data in each shard; aggregate reads by querying all shards
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate write sharding options

    Adding a random shard ID (0-9) to partition key spreads writes across 10 partitions.
  2. Step 2: Consider read strategy

    Reads require querying all shards and aggregating results, which is manageable for balanced load.
  3. Step 3: Compare other options

    Using no sharding risks throttling; shard ID in sort key does not distribute writes; single partition causes hot spots.
  4. Final Answer:

    Add a random shard ID (0-9) to the partition key and store user data in each shard; aggregate reads by querying all shards -> Option D
  5. Quick Check:

    Shard ID in partition key + aggregate reads = balanced writes [OK]
Quick Trick: Shard in partition key, aggregate reads from all shards [OK]
Common Mistakes:
MISTAKES
  • Not sharding partition key causing hot partitions
  • Adding shard ID to sort key only
  • Ignoring read complexity after sharding

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes