API Gateway latency is nearing timeout
Why do I see this?
One of your API endpoints is taking longer than 25 seconds to respond.
What does this mean?
Amazon API Gateway has a default upper timeout limit of 30 seconds for all HTTP API requests. It is not possible to configure an API endpoint to bypass the upper limit through the configuration settings. This limit ensures that the API integrations are designed to take less than 30 seconds to respond. If an API endpoint tries to take longer than 30 seconds to respond, the API Gateway will throw timeout errors. This event notifies you when one of your API endpoints took longer than 25 seconds to respond in the last 30 minutes.
How do I fix "API Gateway latency is nearing timeout"?
KloudMate uses this event to notify you when the latency goes over 25 seconds in order to give you enough time to investigate and remedy the situation before the API Gateway starts throwing timeout errors. Following are some of the things you can do to reduce the time taken by your API request:
- Make sure that its backend integration only includes the logic needed to send an HTTP response to the client.
- If there is any non-dependent or post-processing logic in the backend integration, consider moving it to any other service such as AWS Lambda.
- Improving the backend integration performance can also help reduce its overall runtime. You can do that by enabling API caching.
Another thing to note is that sometimes components such as DNS servers may generate errors anywhere in the lifecycle of an API request causing the API gateway to throw timeout errors. To avoid this, consider implementing retries in the client application.