Consider a DynamoDB table named Users with primary key UserId. You run the following BatchWriteItem request to insert two new users:
{
"RequestItems": {
"Users": [
{"PutRequest": {"Item": {"UserId": {"S": "u1"}, "Name": {"S": "Alice"}}}},
{"PutRequest": {"Item": {"UserId": {"S": "u2"}, "Name": {"S": "Bob"}}}}
]
}
}What will the response contain if both writes succeed?
If all writes succeed, DynamoDB returns an empty UnprocessedItems map.
The BatchWriteItem response includes an UnprocessedItems field listing any items not processed due to throttling or errors. If all writes succeed, this field is empty.
When using BatchWriteItem in DynamoDB, which of the following is a true limitation?
Check the official AWS DynamoDB limits for batch writes.
BatchWriteItem allows up to 25 Put or Delete requests per call, with a maximum total size of 16 MB. It does not support conditional writes and can target multiple tables.
Identify the valid JSON syntax for a BatchWriteItem request that deletes an item with UserId 'u3' from the Users table.
Remember the structure: RequestItems maps table names to lists of write requests.
The correct syntax uses RequestItems as a map from table name to a list of write requests. Each write request is an object with either PutRequest or DeleteRequest keys.
After calling BatchWriteItem, some items are returned in UnprocessedItems. What is the best practice to handle these unprocessed items?
Think about how to avoid throttling and ensure all writes succeed.
DynamoDB returns unprocessed items when throttling occurs. The recommended approach is to retry these items with exponential backoff to reduce load and avoid repeated throttling.
You run this BatchWriteItem request to put two items into the Products table:
{
"RequestItems": {
"Products": [
{"PutRequest": {"Item": {"ProductId": {"S": "p1"}, "Price": {"N": "20"}}}},
{"PutRequest": {"Item": {"ProductId": {"S": "p2"}, "Price": 15}}}
]
}
}Why does this request cause a ValidationException?
Check the attribute value formats for DynamoDB items.
In DynamoDB JSON format, attribute values must specify their data type. The second item's Price attribute is given as a raw number 15 instead of {"N": "15"}, causing a validation error.