0
0
DynamoDBquery~10 mins

Batch limits and retries in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the maximum number of items allowed in a single batch write request.

DynamoDB
max_items = [1]
Drag options to blanks, or click blank then click option'
A25
B50
C100
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number higher than 25 causes the batch request to fail.
Confusing batch write limits with batch get limits.
2fill in blank
medium

Complete the code to retry unprocessed items after a batch write operation.

DynamoDB
if response.get('UnprocessedItems'):
    retry_items = response['[1]']
Drag options to blanks, or click blank then click option'
AProcessedItems
BUnprocessedItems
CItems
DFailedItems
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ProcessedItems' which contains items already handled.
Assuming all items are processed without checking this key.
3fill in blank
hard

Fix the error in the code to correctly handle batch write retries with exponential backoff.

DynamoDB
import time

retry_count = 0
while retry_count < 5:
    response = client.batch_write_item(RequestItems=batch)
    unprocessed = response.get('UnprocessedItems')
    if not unprocessed:
        break
    batch = unprocessed
    time.sleep([1])
    retry_count += 1
Drag options to blanks, or click blank then click option'
Aretry_count
Bretry_count * 2
C5
D2 ** retry_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using a constant or linear wait time causes inefficient retries.
Not increasing wait time can lead to repeated throttling.
4fill in blank
hard

Fill both blanks to create a batch write request with a limit and handle unprocessed items.

DynamoDB
batch_items = items[:[1]]
response = client.batch_write_item(RequestItems=[2])
Drag options to blanks, or click blank then click option'
A25
B{'MyTable': batch_items}
C50
D{'TableName': batch_items}
Attempts:
3 left
💡 Hint
Common Mistakes
Using more than 25 items in a batch write.
Incorrect dictionary key for RequestItems.
5fill in blank
hard

Fill all three blanks to implement a retry loop with batch write, exponential backoff, and unprocessed items handling.

DynamoDB
max_retries = [1]
retry = 0
while retry < max_retries:
    response = client.batch_write_item(RequestItems=[2])
    unprocessed = response.get('UnprocessedItems')
    if not unprocessed:
        break
    [3](2 ** retry)
    retry += 1
Drag options to blanks, or click blank then click option'
A5
B{'OrdersTable': batch}
Ctime.sleep
Dclient.batch_write_item
Attempts:
3 left
💡 Hint
Common Mistakes
Not using exponential backoff in retries.
Passing incorrect structure to RequestItems.
Forgetting to sleep between retries.