Exam SAA-C03 All QuestionsBrowse all questions from this exam
Question 98

An image-processing company has a web application that users use to upload images. The application uploads the images into an Amazon S3 bucket. The company has set up S3 event notifications to publish the object creation events to an Amazon Simple Queue Service (Amazon SQS) standard queue. The SQS queue serves as the event source for an AWS Lambda function that processes the images and sends the results to users through email.

Users report that they are receiving multiple email messages for every uploaded image. A solutions architect determines that SQS messages are invoking the Lambda function more than once, resulting in multiple email messages.

What should the solutions architect do to resolve this issue with the LEAST operational overhead?

    Correct Answer: C

    The users are receiving multiple email messages because the Lambda function is being invoked more than once for the same SQS message. This occurs when the visibility timeout of the SQS queue is too short. If the visibility timeout ends before the Lambda function completes processing the message, the message will become visible again in the queue, leading to its reprocessing and the sending of multiple emails. Increasing the visibility timeout in the SQS queue to a value greater than the total of the function timeout and the batch window timeout ensures that each message is given sufficient time for processing before it can be seen again by another consumer. Therefore, the issue can be resolved by increasing the visibility timeout.

Discussion
Six_Fingered_JoseOption: C

answer should be C, users get duplicated messages because -> lambda polls the message, and starts processing the message. However, before the first lambda can finish processing the message, the visibility timeout runs out on SQS, and SQS returns the message to the poll, causing another Lambda node to process that same message. By increasing the visibility timeout, it should prevent SQS from returning a message back to the poll before Lambda can finish processing the message

Ello2023

I am confused. If the email has been sent many times already why would they need more time? I believe SQS Queue Fifo will keep in order and any duplicates with same ID will be deleted. Can you tell me where i am going wrong? Thanks

MrAWS

I tend to agree with you. See my comments above.

Robrobtutu

Increasing the visibility timeout would give time to the lambda function to finish processing the message, which would make it disappear from the queue, and therefore only one email would be send to the user. If the visibility timeout ends while the lambda function is still processing the message, the message will be returned to the queue and there another lambda function would pick it up and process it again, which would result in the user receiving two or more emails about the same thing.

aadityaravi8

I agree with your answer explanation

Abdou1604

i aggree because the issue is multiple received email for an image uploaded

MutiverseAgent

I agree it seems solution is C, as thought the SQS FIFO makes sense deduplication id would make NO sense as the system who put messages in the queue is S3 events; and as far as I know S3 do not send duplicated events. Also, the question mention that users are complaining about receiving multiple emails for each email, which is different to say they are receiving occasionally a repeated email; so my guess is SQS FIFO is not needed.

JoeGuan

The FIFO SQS is for solving a different problem, where items in the queue require order. You cannot simply switch from a standard queue to fifo queue. Duplicate emails are a common issue with a standard queue. The documentation consistently reminds us that duplicate emails can occur, and the solution is not to create a FIFO queue, but rather adjust the configuration parameters accordingly.

PLN6302

amazon s3 doesn't support fifo queues

brushekOption: C

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html this is important part: Immediately after a message is received, it remains in the queue. To prevent other consumers from processing the message again, Amazon SQS sets a visibility timeout, a period of time during which Amazon SQS prevents other consumers from receiving and processing the message. The default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours.

Ruffyit

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html this is important part: Immediately after a message is received, it remains in the queue. To prevent other consumers from processing the message again, Amazon SQS sets a visibility timeout, a period of time during which Amazon SQS prevents other consumers from receiving and processing the message. The default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours

Solomon2001Option: B

B. Change the SQS standard queue to an SQS FIFO queue. Use the message deduplication ID to discard duplicate messages. Here’s why this option is suitable: SQS FIFO Queue: Amazon SQS FIFO (First-In-First-Out) queues ensure that the order of messages is preserved. Each message in a FIFO queue has a unique message deduplication ID. By using a FIFO queue, you can prevent duplicate messages from being processed. Message Deduplication ID: When sending messages to a FIFO queue, set the message deduplication ID to ensure that identical messages are treated as duplicates. If a message with the same deduplication ID is sent within a 5-minute window, it is considered a duplicate and discarded. https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

Anthony_Rodrigues

This wouldn't work as expected because the issue is not the order or the queue receiving multiple times the same message. The issue is that the Lambda executes the same message multiple times. The FIFO deduplication ID works when the producer sends the message, not when the consumer is receiving the message. (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html) For this to work, the Lambda function would need to know/keep the last N deduplication ID to guarantee that it isn't processing the same message, which goes against Lambda's statelessness. Therefore, for this case, B is the best answer.

ManikRoyOption: C

to all those who are considering option B, Its INCORRECT. Amazon Simple Queue Service FIFO (First-In-First-Out) queues aren't supported as an Amazon S3 event notification destination. https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventNotifications.html

shwelin

I will stick with "B", the correct answer.

ManikRoy

Its INCORRECT Amazon Simple Queue Service FIFO (First-In-First-Out) queues aren't supported as an Amazon S3 event notification destination. https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventNotifications.html

0xE8D4A51000Option: B

All answers are wrong, the answer B

prabhjot

ans B - Option A (long polling), Option C (increasing visibility timeout), and Option D (deleting messages immediately) do not address the root cause of the problem, which is the duplication of messages in the queue.

jaradat02

the correct answer is C, although B and D might also work, C is the one that achieves the least operational overhead condition.

824c449Option: B

B: Directly addresses the issue of duplicates by ensuring exact-once processing and message ordering, which mitigates the risk without requiring adjustments based on anticipated processing times or additional application logic to manage potential duplicates. So, while increasing the visibility timeout could help in managing when messages are available for processing again, it doesn't provide a structural solution to the problem of duplicate processing in the way that using an SQS FIFO queue does, nor does it ensure the operational simplicity and reliability that comes with eliminating duplicates at the source.

UzbekistanOption: B

Given the requirement to resolve the issue of multiple email messages being sent to users with the least operational overhead, the most appropriate solution is: B. Change the SQS standard queue to an SQS FIFO queue. Use the message deduplication ID to discard duplicate messages. Explanation: SQS FIFO Queue: FIFO (First-In-First-Out) queues in SQS ensure that the order in which messages are sent and received is strictly preserved and that each message is processed only once. By switching to an SQS FIFO queue, you can prevent the Lambda function from processing duplicate messages.

ManikRoy

Its INCORRECT Amazon Simple Queue Service FIFO (First-In-First-Out) queues aren't supported as an Amazon S3 event notification destination. https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventNotifications.html

vip2Option: C

'Visibility Timeout' is suitable(better) solution to solve the issue.

awsgeek75Option: C

In this setup the only way to get multiple emails is when same image is processed multiple times. This only happens when another Lambda starts processing while the previous one hasn't finished processing. Increasing the SQS queue timeout to be greater than Lambda timeout will ensure that other Lambda can't see the SQS message before previous Lambda finishes processing or times out. So C is best answer A: Long polling won't fix anything B: FIFO is nice idea but how will the Lambda function know it has got a duplicate message? D: Wrong as in case of Lambda timeout that message is lost without being processed

lqwOption: C

least operational overheads

vijaykamal

Long polling is incorrect...it just means that SQS queue is connected after specific interval instead of looking for messages in queue in very short interval...long polling saves money but does not help to remove duplicate. Correct Answer: C

hieulamOption: A

I think A is correct. https://aws.amazon.com/blogs/developer/polling-messages-from-a-amazon-sqs-queue/#:~:text=When%20disabling,more%20API%20calls.

kwang312

D is an incorrect answer because Lamda automatically deletes message from the queue when finish process