DVA-C02 · Question #486
DVA-C02 Question #486: Real Exam Question with Answer & Explanation
The correct answer is B: Increase the visibility timeout of the SQS queue.. When a Lambda function takes longer to process an SQS message than the queue's visibility timeout, SQS makes the message visible again, causing it to be processed twice; increasing the visibility timeout resolves this.
Question
A developer is testing an AWS Lambda function that has an event source of an Amazon Simple Queue Service (Amazon SQS) queue. The developer notices that some of the messages the Lambda function processes re-appear in the queue while the messages are being processed. The developer must correct this behavior. Which solution will meet this requirement?
Options
- AIncrease the timeout of the Lambda function.
- BIncrease the visibility timeout of the SQS queue.
- CIncrease the memory allocation of the Lambda function.
- DIncrease the batch size in the event source mapping.
Explanation
When a Lambda function takes longer to process an SQS message than the queue's visibility timeout, SQS makes the message visible again, causing it to be processed twice; increasing the visibility timeout resolves this.
Common mistakes.
- A. Increasing the Lambda function timeout only extends how long Lambda is allowed to run; it does not affect the SQS visibility timeout, so the message can still become visible again before Lambda finishes.
- C. Memory allocation affects Lambda execution speed for compute-bound tasks but does not change the SQS visibility timeout or prevent messages from reappearing.
- D. Increasing the batch size causes Lambda to process more messages per invocation but does not change the visibility timeout, so all messages in a batch can still reappear if processing takes longer than the timeout.
Concept tested. SQS visibility timeout alignment with Lambda processing time
Community Discussion
No community discussion yet for this question.