
Answer-first summary for fast verification
Answer: Extend the visibility timeout in the SQS queue beyond the Lambda function's timeout and batch window timeout combined.
The correct answer is C. The issue of receiving multiple email messages arises because the SQS messages are being processed multiple times by the Lambda function before the visibility timeout expires. This results in multiple invocations for the same SQS message. By increasing the visibility timeout in the SQS queue to a value greater than the total of the function timeout and the batch window timeout, you ensure that the message remains hidden from other consumers until the Lambda function has processed it completely. This prevents duplicate processing and minimizes operational overhead.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A web application uploads images to an Amazon S3 bucket, triggering an event that sends object creation notifications to an Amazon SQS standard queue. This queue triggers a Lambda function to process images and email results to users. Users complain of receiving duplicate emails for a single image upload. The issue is identified as the Lambda function being invoked multiple times per message. What is the least operational overhead solution for this?
A
Enable long polling in the SQS queue by setting the ReceiveMessage wait time to 30 seconds.
B
Switch to an SQS FIFO queue and utilize message deduplication to prevent duplicates.
C
Extend the visibility timeout in the SQS queue beyond the Lambda function's timeout and batch window timeout combined.
D
Alter the Lambda function to remove messages from the SQS queue right after they are received, prior to processing.