- Newest
- Most votes
- Most comments
Thanks for all the detail - I can't see anything there that would be a problem but needed to check.
You don't say what runtime language you're using in Lambda. I'm going to guess that you're using Node.js. If that's the case, you may be using an asynchronous function to transfer the data to S3. That may be the problem here - for small files, the async function completes before the Lambda function is suspended and therefore it works.
But for larger files, the the transfer function may still be running but hasn't returned yet; but the mainline code has completed. The Lambda control plane doesn't know this so will suspend the function. The trick here is to ensure that the transfer has completed before the mainline code exits.
Of course, I'm guessing. But it seems to fit the circumstances.
Thanks for your response. There may be a point there. Unfortunately, it wouldn't be as straightforward though. I'm using Swift for the runtime language. Furthermore, the function that transfers the data is performed via a HTTP request, and the default request processing logic — and perhaps all — provided by the language is asynchronous. However, in my case I faced the problem you mentioned in your answer beforehand so I made the function synchronous by using a semaphore.
This appeared to resolve all issues where the Lambda was completing execution before all the endpoint's logic had been executed. I could place a log statement in it, this time specifically looking for it being printed to the console before the log statement that is ran on the lambda's completion. However, I did already litter the Lambda with log statements in the past, particularly in the HTTP request we're talking about here, and suspect I would've noticed if that were the case; but maybe not.
I may just bite the bullet in this case and use a second Lambda just for dealing with S3. A bit more straightforward than trying to debug this problem when I have very limited access to the hardware experiencing the issue, and the only error I'm getting is a "RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period".
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 9 months ago
What's the networking configuration in the VPC? Also, what memory size and timeout have you configured for Lambda?
I updated the question. Currently the lambda has a 5 minute timeout and 512MB ram, but I've attempted with the max of 10240MB ram and 5 minute timeout, and still no difference.
I ask about the networking configuration of the VPC because it might be something there that is affecting the transfer. Try creating a S3 Gateway Endpoint in the VPC - that means that the traffic to S3 from the Lambda function doesn't traverse any NAT or Internet Gateways.
Tried the S3 Gateway Endpoint option, but still facing the issue. I updated the question to include details on my network configuration.