Skip to content

Response times API Gateway - Lambda in different regions

0

Good afternoon,

I am currently migrating the API Gateway and Lambdas from São Paulo (sa-east-1) to Northern Virginia (us-east-1), and I have encountered issues with response times, as shown in the following image:

For the API Gateway configuration, we exported and imported it from one region to another. As for the Lambdas, they were created using Terraform in both environments. Introduce la descripción de la imagen aquí

Although we are based in Chile, we conducted tests with a person living in Denver (USA), and the results were similar.

Looking forward to your response.

Best regards.

2 Answers
0

API Gateway Configuration:

Verify that the API Gateway settings, including endpoint types and caching configurations, are identical in both regions.

Lambda Function Optimization:

Ensure that the Lambda functions are optimized for performance. Check for cold start issues and consider using provisioned concurrency if needed.

Regional Data:

Data should be stored in the region closest to the end-users to minimize latency. If the backend services or databases are in São Paulo, accessing them from Virginia would add to the delay.

Cross-Region Replication:

If data needs to be accessed across regions, consider using services like Amazon CloudFront for content delivery or setting up cross-region replication for your databases.

Monitoring and Logging:

Utilize AWS CloudWatch for detailed logging and monitoring to identify the exact points of delay. This can help pinpoint whether the latency is due to the API Gateway, Lambda, or network.

Please refer this blog for troubleshooting, and further analysis How do I troubleshoot high latency in my API Gateway requests that are integrated with Lambda?

AWS

answered 2 years ago

0

It's not clear from your question how you are measuring "Time" nor where you are measuring it from. My assumption is that you're using something like (say) curl and timing how long the response takes. If you are doing this, be aware that you're not measuring the time it takes API Gateway to call Lambda.

I mentioned this because a four second integration time for API Gateway in Virginia to be calling a Lambda in Virginia is very strange.

There are also dependencies on what your Lambda function is doing - if it is calling something in another region then that might explain the high latency.

If it were me, I'd be using X-Ray to track how long requests are taking through API Gateway and Lambda - you can get very precise timings for each event as it passes through the AWS services. I'd also be testing from an EC2 instance in various regions - you've done this already by having a user in Denver; but testing from an EC2 instance in Virginia to the API Gateway in Virginia will eliminate the latency of calling the API across the internet which will give you numbers that are better to interpret as you won't be able to control what latency your end-users see as it depends on where they are calling from.

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.