API Gateway 504 timeout

I have a lambda function as backend in my API Gateway and got the timeout error (504) as the lambda function completes longer than 29 seconds. I want to know how to handle this situation.

As per the documentation, this integration timeout limit is a hard limit which means it can’t be increased unfortunately.

However there is a workaround by invoking the backend asynchronously. This means that your lambda function will return a response to API Gateway straight away which will avoid timeout, and your backend can execute for longer than 29 seconds. In your backend you would return HTTP code 202 which means that the request has been accepted for processing, but the processing has not been completed. In the client you can implement polling logic to check the status of the backend. You can find more information on setting up asynchronous invocation of the backend Lambda function from

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html

.

No Comments

Leave a Reply