A developer is configuring an AWS Lambda function to process user upload notifications from an Amazon SQS standard queue. The Lambda function timeout is configured to seconds. However, the SQS queue's default visibility timeout is set to seconds. During performance tests, the developer notices that some upload messages are processed multiple times by different Lambda instances. Which action should the developer take to resolve this duplication issue?
- ADecrease the default visibility timeout of the Amazon SQS queue to seconds.
- BIncrease the Lambda function's timeout configuration to seconds while leaving the queue's visibility timeout at seconds.
- Increase the default visibility timeout of the Amazon SQS queue to at least seconds.Answer
- DHardcode temporary AWS credentials directly in the Lambda function's code to initialize the Amazon SQS SDK client and delete the message immediately upon invocation.
Answer
Increase the default visibility timeout of the Amazon SQS queue to at least seconds.
Increasing the SQS visibility timeout to at least 6 times the Lambda function's timeout ( seconds) ensures the Lambda function has enough time to finish processing the message and delete it from the queue before the message becomes visible to other concurrent Lambda invocations.
Step-by-Step Solution
Key Concept
SQS Visibility Timeout configuration when integrated with AWS Lambda
Estimated Time:1m 0s