- Newest
- Most votes
- Most comments
Hello.
From the log you provided below, the maximum memory is set to 128MB and the memory used is also 128MB.
The size of the CSV file you are trying to read is unknown, but it may be that the memory size is too small to read it, resulting in a timeout.
Try increasing the Lambda memory size.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html
REPORT RequestId: 84fe6515-6c72-4171-ad40-0d09bb5183c8 Duration: 150000.00 ms Billed Duration: 154340 ms Memory Size: 128 MB Max Memory Used: 128 MB Init Duration: 4339.64 ms Status: timeout
Your Lambda function is timing out when reading the second CSV file from S3. This is happening because of several potential issues:
-
Memory allocation: Your Lambda is configured with only 128 MB of memory, which is the minimum allowed. The logs show "Max Memory Used: 128 MB" which indicates you're hitting the memory limit. When working with data processing libraries like pandas and awswrangler, 128 MB is typically insufficient, especially when reading multiple CSV files.
-
Timeout configuration: The default Lambda timeout is 3 seconds, but your function is running for the maximum allowed time (150 seconds) before timing out. This suggests your timeout setting is too short for the operation you're performing.
-
VPC configuration: If your Lambda function is in a VPC, it might be trying to access S3 without proper network configuration. Lambda functions in a VPC need either an S3 VPC endpoint or a NAT gateway to access S3 efficiently.
-
File size: The second CSV file might be larger than the first one, causing the timeout. Large files take longer to download and process.
To resolve this issue:
-
Increase the memory allocation for your Lambda function (at least 1-2 GB for data processing tasks). This will also indirectly improve CPU performance and network bandwidth.
-
Increase the timeout setting to give your function more time to complete.
-
If your Lambda is in a VPC, ensure you have an S3 VPC endpoint configured.
-
Consider implementing streaming reads for large files instead of loading the entire file into memory at once.
-
Check if your error handling in the load_menu_data_from_s3 function is properly logging errors, as you're not seeing any error messages despite the failure.
The fact that commenting out the first CSV read allows the second one to succeed suggests this could be a cumulative memory issue, where the first file's data is still in memory when you try to load the second one.
Sources
Why does my Lambda function timeout when accessing S3, even though permissions are correct? | AWS re:Post
Troubleshoot configuration issues in Lambda - AWS Lambda
Relevant content
- AWS OFFICIALUpdated 3 months ago

Thanks, Riku. My above two files are quite small, 16.2 KB and 8.4 KB. After increasing Lambda memory size, the issue got solved.