A developer is troubleshooting an application where an AWS Lambda function processes batch orders from an Amazon SQS standard queue. The Lambda function is configured with a timeout of 45 seconds and a batch size of 10 messages. The SQS queue is configured with a visibility timeout of 60 seconds and a redrive policy targeting a Dead-Letter Queue (DLQ) with a maxReceiveCount of 3. During peak hours, the developer observes that some messages are processed multiple times by different Lambda invocations, and the DLQ receives an increased number of messages, even though no errors are logged by the function code. CloudWatch Logs indicate that some executions time out at 45 seconds under heavy database load, while others complete in under 5 seconds. Which of the following changes should the developer make to resolve these issues?
- Enable 'Report Batch Item Failures' on the Lambda event source mapping, modify the function to return a list of failed message IDs in the response, and increase the SQS queue's visibility timeout to 270 seconds.Answer
- BDeploy the Lambda function in a VPC with private subnets, configure an interface VPC Endpoint for Amazon SQS, and update the function's IAM execution role to allow SQS DeleteMessage actions.
- CDecrease the SQS queue's visibility timeout to 15 seconds to trigger faster retries when the database is congested, and increase the Lambda function memory size to 3008 MB.
- DImplement a global SQS client helper outside the Lambda handler to manually delete processed messages from the queue, and increase the Lambda function timeout to 90 seconds.