An enterprise applications developer is troubleshooting a batch processing pipeline. An Amazon SQS standard queue receives transaction messages, which trigger an AWS Lambda function. The Lambda function's timeout is set to seconds. Under heavy load, the developer observes that several messages are being processed multiple times by concurrent Lambda executions, resulting in duplicate database entries. Analysis of the logs shows that the Lambda function is executing successfully without timing out or throwing errors.
Which configuration change should the developer implement to resolve the duplicate processing issue?
- AConfigure the SQS queue's visibility timeout to 90 seconds to match the Lambda function's timeout exactly.
- BDeploy the Lambda function in a private VPC subnet without a NAT Gateway to isolate network connectivity.
- Increase the SQS queue's visibility timeout to at least 540 seconds.Answer
- DDecrease the Lambda function's timeout to 15 seconds and store transaction logs in global variables to optimize execution context reuse.
Answer
Increase the SQS queue's visibility timeout to at least 540 seconds.
Increasing the SQS queue's visibility timeout to at least 540 seconds is correct because AWS best practices dictate that the visibility timeout of the source queue must be at least 6 times the timeout of the triggering Lambda function. For a -second function timeout, this is calculated as seconds. This safety window allows the Lambda function to safely complete its processing and delete the message without the message becoming visible to other concurrent consumers.
Step-by-Step Solution
Key Concept
SQS Visibility Timeout vs Lambda Function Timeout
Estimated Time:2m 0s