You have built a web API in AWS using API Gateway, AWS Lambda, and DynamoDB.
For the DynamoDB table, the read and write capacities have been provisioned as 100
Recently, you found ProvisionedThroughputExceededException for some client requests, which mainly happens when the traffic is high during the daytime.
Which of the following actions can help to reduce the number of exceptions? (Select TWO)
Click on the arrows to vote for the correct answer
A. B. C. D. E.Answer - A, C.
In this scenario, to reduce the number of ProvisionedThroughputExceededException, there are two approaches.
One is to enlarge the capacities of the DynamoDB table.
The other is to reduce the traffic.
Option A is CORRECT: Because DynamoDB supports auto-scaling, can be used to enlarge capacity.
Take the below snapshot as an example:
Option B is incorrect: Because adding retires can potentially increase the traffic, and it does not help reduce the number of exceptions.
Option C is CORRECT: Because the SQS queue can control the requests made to the DynamoDB table through asynchronous processing and it acts as a cache that controls the rate of requests to the table.
Option D is incorrect: Because CloudFront does not work with DynamoDB.
Instead, Elasticache can be used as a caching layer for DynamoDB.Option E is incorrect: Because users can directly enable DynamoDB auto scaling rather than configure it manually.
The ProvisionedThroughputExceededException occurs when the provisioned capacity of a DynamoDB table is exceeded. In this case, the table is provisioned with 100 read and write capacities. However, during high traffic periods, this capacity may not be sufficient to handle the requests, which causes the exception.
To reduce the number of ProvisionedThroughputExceededExceptions, the following actions can be taken:
A. Enable auto-scaling for the read and write capacities in the DynamoDB table: Auto-scaling allows the read and write capacities to increase or decrease automatically based on the traffic to the table. This ensures that the table can handle the traffic during peak periods and reduces the likelihood of the ProvisionedThroughputExceededException.
B. Add retries to the AWS Lambda function: When a ProvisionedThroughputExceededException occurs, retries can be added to the AWS Lambda function. This will ensure that the request is retried after a certain amount of time. If the capacity issue is resolved during this time, the request will be successful.
C. Configure an SQS queue to control the traffic to the DynamoDB table asynchronously: This involves putting extra messages in an SQS queue before they reach the DynamoDB table. The messages can be processed by the table at a pace that it can handle. This approach can help reduce the likelihood of ProvisionedThroughputExceededExceptions.
D. Configure AWS CloudFront as a caching layer in front of DynamoDB: CloudFront can cache frequently accessed data from the DynamoDB table, reducing the number of requests to the table. This can help reduce the likelihood of ProvisionedThroughputExceededExceptions.
E. Create a CloudWatch alarm for ProvisionedThroughputExceededException and enlarge the provisioned capacities if the alarm is triggered: A CloudWatch alarm can be set up to monitor the number of ProvisionedThroughputExceededExceptions. If the alarm is triggered, the provisioned capacities can be increased to handle the traffic.
In summary, to reduce the likelihood of ProvisionedThroughputExceededExceptions for a DynamoDB table in AWS, it is recommended to enable auto-scaling, add retries to the AWS Lambda function, use an SQS queue to control the traffic, configure AWS CloudFront as a caching layer, and create a CloudWatch alarm for monitoring the issue.