An application uses an AWS Lambda function to process messages from an Amazon SQS standard queue. The Lambda function has its timeout configured to minutes. During peak traffic, the developer notices that many messages are processed multiple times by parallel Lambda invocations, even though all Lambda executions finish successfully. The SQS queue has a Default Visibility Timeout of seconds. Which configuration change should the developer make to resolve this issue?
- AConfigure the SQS queue as a FIFO queue and enable content-based deduplication.
- BIncrease the Lambda function's timeout configuration to minutes.
- Increase the SQS queue's Default Visibility Timeout to minutes.Answer
- DRedeploy the Lambda function inside a private VPC subnet without a NAT Gateway.
Answer
Increase the SQS queue's Default Visibility Timeout to minutes.
To prevent duplicate message processing when SQS is used as an event source for AWS Lambda, the queue's visibility timeout must be configured to at least times the timeout of the Lambda function. With a Lambda timeout of minutes, the visibility timeout should be set to at least minutes to ensure that the message is not visible to other consumers during execution and retries.
Step-by-Step Solution
Key Concept
SQS Visibility Timeout configuration when integrated with AWS Lambda as an event source.