A developer is building a fitness tracking application that logs daily workout sessions for users. The application needs to import a batch of workout records into an Amazon DynamoDB table. If some records fail to write due to transient issues or throughput throttling, the application must identify and retry writing only those failed records. Which approach should the developer implement to accomplish this requirement with the least operational overhead?
- AUse the Scan API operation to retrieve all existing records, compare them in application memory, and use PutItem to write the missing records.
- Use the BatchWriteItem API operation, inspect the UnprocessedItems parameter in the response, and retry only the failed write requests.Cevap
- CUse the PutItem API operation in a loop, initializing the DynamoDB client with hardcoded AWS access keys to ensure authorization is fast and persistent.
- DUse the TransactWriteItems API operation, and if a ProvisionedThroughputExceededException is returned, double the provisioned write capacity units of the table.
Cevap
Use the BatchWriteItem API operation, inspect the UnprocessedItems parameter in the response, and retry only the failed write requests.
The correct approach is to use BatchWriteItem, which can put or delete multiple items in a single call. If some operations fail, DynamoDB does not fail the entire batch; instead, it returns the failed items in the UnprocessedItems parameter. The developer can then code the application to retry only these specific items, which is highly efficient and minimizes operational overhead.
Adım Adım Çözüm
Anahtar Kavram
Handling partial failures and unprocessed items in DynamoDB BatchWriteItem operations
Tahmini Süre:1m 30s