- Newest
- Most votes
- Most comments
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?
answered 2 years ago
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.
Relevant content
asked 5 years ago
