A developer is troubleshooting an AWS Lambda function that processes large CSV data exports uploaded to an Amazon S3 bucket. The function is currently configured with of memory and a timeout of . During initial testing with small files, the function executes successfully. However, when processing larger files, the function consistently fails, and Amazon CloudWatch Logs show a `Task timed out after 10.00 seconds` error. Which action should the developer take to resolve this execution timeout issue?
- Increase the Lambda function's timeout configuration to allow more execution time, and allocate more memory to proportionally scale the CPU performance.Answer
- BDeploy the Lambda function in a public VPC subnet and assign a public IP address to the function's network interface to speed up S3 data transfer.
- CMove the file download and buffer arrays to the global execution context outside the handler to automatically persist state and bypass the execution timeout on subsequent runs.
- DEnable Provisioned Concurrency for the Lambda function to keep warm execution environments active and prevent the execution from timing out.
Answer
Increase the Lambda function's timeout configuration to allow more execution time, and allocate more memory to proportionally scale the CPU performance.
The correct action is to increase the Lambda function's timeout setting and allocate additional memory. Increasing the timeout directly extends the allowed run time of the function. Additionally, since AWS Lambda allocates CPU power proportionally to the configured memory size, increasing the memory allocation will speed up CPU-bound tasks like file parsing, preventing the function from timing out.
Step-by-Step Solution
Key Concept
AWS Lambda resource allocation and execution limits
Estimated Time:1m 30s