0
0
DynamoDBquery~20 mins

Write sharding in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Write Sharding Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of write sharding in DynamoDB?

Write sharding is used in DynamoDB to:

ADistribute write requests across multiple partitions to increase write throughput
BEncrypt data at rest for security
CAutomatically backup data to S3
DReduce read latency by caching data
Attempts:
2 left
💡 Hint

Think about how DynamoDB handles many writes at once.

query_result
intermediate
1:30remaining
What is the output count of items after applying write sharding with 3 shards?

Suppose you have a table with 9 items and you apply write sharding with 3 shards by adding a shard key with values 0, 1, or 2. How many total items will be in the table after sharding?

A3
B9
C27
D0
Attempts:
2 left
💡 Hint

Each original item is duplicated across shards with different shard keys.

📝 Syntax
advanced
2:00remaining
Which DynamoDB update expression correctly increments a shard counter?

Given a DynamoDB item with attribute shardCount, which update expression correctly increments it by 1?

DynamoDB
UpdateExpression = ?
ASET shardCount = shardCount + :inc
BADD shardCount :inc
CINCREMENT shardCount BY 1
DSET shardCount += 1
Attempts:
2 left
💡 Hint

DynamoDB uses ADD to increment numeric attributes.

optimization
advanced
2:00remaining
How does write sharding improve DynamoDB write capacity usage?

Choose the best explanation for how write sharding optimizes write capacity in DynamoDB.

AIt caches writes in memory before sending to DynamoDB
BIt compresses data to reduce storage size
CIt batches writes into a single request to reduce network calls
DIt spreads writes across multiple partition keys to avoid hot partitions and throttling
Attempts:
2 left
💡 Hint

Think about how DynamoDB partitions data internally.

🔧 Debug
expert
2:30remaining
Why does this write sharding implementation cause throttling errors?

You implemented write sharding by adding a random shard key from 0 to 4 to each item. However, you still get throttling errors on writes. What is the most likely cause?

Code snippet:

shard_key = random.randint(0, 4)
item['shard'] = shard_key
put_item(item)
AThe shard key is not part of the partition key, so writes still go to the same partition
BRandom shard keys cause duplicate items and data corruption
CThe code does not batch writes, causing network overhead
DThe shard key values are too small, causing uneven distribution
Attempts:
2 left
💡 Hint

Check how DynamoDB partitions data based on keys.