AWS Lambda Timeout scenarios When Invoked from API Gateway with Large Payloads
Hey everyone, I'm running into an issue that's driving me crazy. I'm dealing with I'm maintaining legacy code that I'm stuck on something that should probably be simple. I'm working with a timeout behavior when invoking an AWS Lambda function from API Gateway when the payload size exceeds a certain limit. The Lambda function processes a JSON object that can grow quite large, sometimes reaching around 6 MB. When I'm testing this with smaller payloads (around 1 MB), it works perfectly fine, but as soon as I increase the size, I get a `504 Gateway Timeout` behavior. I increased the timeout for both the API Gateway and the Lambda function to 30 seconds, but the scenario continues. Hereβs the basic setup of my Lambda function in Node.js: ```javascript exports.handler = async (event) => { // Simulate processing a large payload console.log('Received event:', JSON.stringify(event)); // Process logic here... return { statusCode: 200, body: JSON.stringify({ message: 'Success' }), }; }; ``` In the API Gateway configuration, I've set the integration timeout to 30 seconds, which is the maximum allowed. The API Gateway also has the payload size limit set to 10 MB, so that shouldn't be the scenario. When I look at the CloudWatch logs for the Lambda function during these timeouts, it doesn't appear to be executing for long enough to even log any events for larger payloads. Additionally, Iβve tested the function directly using the AWS Lambda console with the large payloads, and they execute without any issues. Could there be some limitation or configuration in API Gateway that Iβm overlooking? Is there a recommended pattern for handling large payloads effectively in this architecture? Any insights would be greatly appreciated. Thanks! For context: I'm using Javascript on Ubuntu. Has anyone else encountered this? For context: I'm using Javascript on Linux. Thanks, I really appreciate it! I'm on Debian using the latest version of Javascript. Is there a simpler solution I'm overlooking? Thanks for taking the time to read this!