Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Gateway timeout

I'm using a lambda function to process a large amount of data (which exceeds 30s) and I am receicing a message from AWS Gateway:

Endpoint request timed out

I understand this is obviously because of the default timeout with AWS Gateway, however my Lambda function is set to run for up to 15 minutes.

What is the best way to increase this timeout? Surely this can be done considering lambdas can be set to execute for a much longer time.

Thanks

like image 497
red house 87 Avatar asked Oct 18 '25 14:10

red house 87


2 Answers

API Gateway has a hard limit of 30 seconds. If your lambdas regularly take over 30 seconds (and you really need to use an API endpoint instead of a schedule, SQS or other source), you should use the lambda behind the gateway to trigger another lambda that does the actual work and give a response something like { "file_id": "some_id", "status": "in_progress"}. Then fetch the result of the work from another API endpoint. And ideally you should also have another endpoint to check the status of the work so the user of the API knows when it is done and results are ready for download.

like image 184
r.delic Avatar answered Oct 21 '25 02:10

r.delic


API gateway times out after 30 seconds, have you tried using scheduled events to trigger the lambda instead of going through API gateway?

like image 40
Michael Goodrum Avatar answered Oct 21 '25 03:10

Michael Goodrum