An HTTP API in API Gateway invokes a Lambda function that performs several independent tasks. The tasks can take up to 10 minutes in total. Users report the endpoint sometimes returns an HTTP 504 status, although the Lambda invocations succeed. What change will prevent the endpoint from returning HTTP 504 errors?
Choose an answer
Tap an option to check your answer.
Correct answer: Refactor the Lambda function so it starts an AWS Step Functions state machine to perform the long-running tasks..
Why this is the answer
The correct solution is to refactor the Lambda function to start an AWS Step Functions state machine. API Gateway has a maximum integration timeout of 29 seconds. If the backend Lambda function takes longer than this, API Gateway will return an HTTP 504 (Integration Timeout) error, even if the Lambda function eventually succeeds. Step Functions are designed for orchestrating long-running workflows. The Lambda function can initiate the state machine and return an immediate success to API Gateway, allowing the longer tasks to complete asynchronously. Increasing the Lambda function timeout value is incorrect because API Gateway's timeout limit is independent of the Lambda function's timeout. Increasing reserved concurrency or memory allocation will improve performance or capacity but will not address the 29-second API Gateway integration timeout.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed