Troubleshooting 429 Errors with API Gateway and Lambda | Online Retailer

Troubleshooting 429 Errors

Prev Question Next Question

Question

You are a solutions architect working for an online retailer.

Your online website uses REST API calls via API Gateway and Lambda from your Angular SPA front-end to interact with your DynamoDB data store.

Your DynamoDB tables are used for customer preferences, account, and product information.

When your web traffic spikes, some requests return a 429 error response.

What might be the reason your requests are returning a 429 response? (Select TWO)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answers: A and E.

Option A is correct.

When your traffic spikes, your Lambda function can exceed the limit set on the number of concurrent instances that can be run (burst concurrency limit in the US: 3,000).

Option B is incorrect.

When your table exceeds its provisioned throughput DynamoDB will return a 400 error to the requesting service, in this case, API Gateway.

This will not result in the propagation of a 429 error response (too many requests) back to the Angular SPA service.

Option C is incorrect.

If your Angular service fails to connect to your API Gateway REST endpoint your code will not generate a 429 error response (too many requests).

Option D is incorrect.

Since your Angular SPA code runs in the individual user's web browser, this option makes no sense.

Option E is correct.

When your API Gateway request volume reaches the steady-state request rate and bursting limit, API Gateway throttles your requests to protect your back-end services.

When these requests are throttled, API Gateway returns a 429 error response (too many requests).

References:

Please see the Amazon API Gateway developer guide titled Throttle API requests for better throughput (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html), the Towards Data Science article titled Full Stack Development Tutorial: Integrate AWS Lambda Serverless Service into Angular SPA (https://towardsdatascience.com/full-stack-development-tutorial-integrate-aws-lambda-serverless-service-into-angular-spa-abb70bcf417f), the Amazon API Gateway developer guide titled Invoking a REST API in Amazon API Gateway (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-call-api.html), the AWS Lambda developer guide titled Lambda function scaling (https://docs.aws.amazon.com/lambda/latest/dg/invocation-scaling.html), and the Amazon DynamoDB developer guide titled Error Handling with DynamoDB (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html)

The 429 Too Many Requests error response indicates that the user has sent too many requests in a given amount of time. This error can occur due to various reasons in the given scenario.

A. Your Lambda function has exceeded the concurrency limit: Lambda function concurrency refers to the number of requests being served by a function at any given time. If the concurrency limit is exceeded, any further requests will result in a 429 error. This could happen if the Lambda function is handling a large number of requests simultaneously, and its limit is reached. You can check the concurrency limit for your Lambda function in the AWS Management Console.

B. DynamoDB concurrency limit has been exceeded: DynamoDB also has a concurrency limit that can cause the 429 error if exceeded. This could happen if the number of requests to read or write to DynamoDB exceeds its capacity to handle them. You can check the capacity and utilization metrics for your DynamoDB tables in the AWS Management Console.

C. Your Angular service failed to connect to your API Gateway REST endpoint: If the Angular service fails to connect to the API Gateway REST endpoint, it will not be able to make requests to DynamoDB. This could happen due to various reasons, such as network issues or incorrect configuration.

D. Your Angular service cannot handle the volume spike: If the volume of traffic to your website spikes suddenly, your Angular service may not be able to handle the increased load. This could result in delays or errors, including 429 errors.

E. Your API Gateway has exceeded the steady-state request rate and burst limits: API Gateway has steady-state request rate limits and burst limits, which can be exceeded if there is a sudden spike in traffic to your website. This could result in API Gateway rejecting some requests and returning a 429 error response. You can check the API Gateway usage metrics in the AWS Management Console to identify if this is the issue.

In summary, the two most likely reasons for 429 errors in this scenario are: A. Your Lambda function has exceeded the concurrency limit, and E. Your API Gateway has exceeded the steady-state request rate and burst limits.