Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the AWS API Gateway timeout higher than 30 seconds?

Tags:

I read here that I can set my Lambda function timeout for 15 minutes (https://aws.amazon.com/about-aws/whats-new/2018/10/aws-lambda-supports-functions-that-can-run-up-to-15-minutes/)

However, when I try to set API Gateway inside the Integration Request settings, it does not allow me to set it higher than 29seconds:

Timeout max is 29 seconds

How can I have a function that lasts 15 minutes, but a Gateway that time outs after 30 seconds?

like image 538
Kamilski81 Avatar asked Jan 22 '19 01:01

Kamilski81


People also ask

Can we increase AWS gateway timeout?

If it's an HTTP API, you can try increasing your maximum integration request timeout parameter. Note: API Gateway REST API's default maximum integration timeout is 29 seconds. For HTTP API the timeout can be configured for up to the maximum value of 30 seconds.

Can API gateway timeout be increased?

You can now customize the timeout value for API integrations in Amazon API Gateway. You can set the maximum amount of time an integration will run before it returns without a response.

How do I increase my API gateway limit?

To request a quota increase, you can use Service Quotas or contact the AWS Support Center . When authorization is enabled on a method, the maximum length of the method's ARN (for example, arn:aws:execute-api:{region-id}:{account-id}:{api-id}/{stage-id}/{method}/{resource}/{path} ) is 1600 bytes.


1 Answers

Unfortunately there isn't a way to increase the API Gateway timeout to longer than 29 seconds. This is a limitation of the gateway. The reason you can set the lambda function longer is because this can be plugged into other AWS resources that allow a higher threshold for timeout processing.

Here's some options you could explore to get around this and/or work with the limitation:

  1. Split your function out into smaller functions and chain those together to see if you get a performance increase. Before doing so you could use AWS X-Ray to debug the function and see what part is taking the most time to target what needs to be split out.

  2. Increase the memory used by the function. Higher memory allocation could result in faster execution. I have used this option before and was able to work around timeout limits.

  3. Instead of using API Gateway you could just use AWS SDK to call 'invoke()' which will invoke your lambda function. This will bypass the timeout threshold.

Hopefully one or a mix of those will help out :)

like image 152
bspeagle Avatar answered Sep 19 '22 05:09

bspeagle