DVA-C02 Question 326
Single answerYou are developing a serverless application using AWS Lambda. The application processes images uploaded to an S3 bucket and stores metadata in a DynamoDB table. You notice that under high load, some Lambda functions are failing with 'ProvisionedThroughputExceededException' errors when writing to DynamoDB. What is the best way to resolve this issue?
- A
Enable DynamoDB Auto Scaling for the table.
- B
Use the DynamoDB BatchWriteItem API instead of individual writes.
- C
Increase the provisioned throughput of the DynamoDB table manually.
- D
Add retries with exponential backoff to your Lambda function's code.
Show answer and explanation
Correct answer: A
Explanation
The 'ProvisionedThroughputExceededException' occurs when the DynamoDB table exceeds its provisioned write or read capacity. Enabling DynamoDB Auto Scaling is the best solution as it allows the table to dynamically adjust its capacity based on demand, ensuring the application can handle high loads without manual intervention or suboptimal workarounds.
- A. Correct.
Enabling DynamoDB Auto Scaling allows the table to automatically adjust its read and write capacity based on traffic patterns, which is the best solution for handling high and variable loads.
- B. Incorrect.
Using the BatchWriteItem API is useful for reducing the number of API calls, but it does not address the root issue of throughput being exceeded during high load.
- C. Incorrect.
Manually increasing the provisioned throughput may temporarily resolve the issue, but it is not a scalable or cost-effective solution under fluctuating workloads.
- D. Incorrect.
Adding retries with exponential backoff can help mitigate transient errors, but it does not address the primary problem of insufficient throughput capacity.