SAA-C03 practice question: Decoupling with queues (4 of 6)
Design Resilient Architectures A free question from our original SAA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A media company uses Amazon EC2 workers to transcode video clips from an Amazon SQS standard queue.
Each clip takes between 2 and 4 minutes to process, after which the worker deletes the message. The queue still uses its default settings.
The operations team notices that many clips are transcoded two or three times, which wastes compute, even though no worker has crashed.
Which change will MOST effectively stop the repeated processing?
Choose one answer.
AA. Turn on long polling by setting the queue's receive message wait time to 20 seconds, so workers make fewer empty receive calls.
BB. Set a delivery delay of 5 minutes on the queue, so that each new message stays hidden for longer before workers can receive it.
CC. Add a dead-letter queue with a maximum receive count of 1, so that any message received a second time is moved aside.
DD. Raise the queue's visibility timeout to about 6 minutes, so that a message stays hidden until its clip is finished.
Show the answer and explanation
Answer: D
A. Wrong: Long polling reduces empty responses and the cost of polling an empty queue. It does not change how long a received message stays hidden, so clips would still reappear after 30 seconds and be picked up again. Learn more: Amazon SQS short and long polling (opens in a new tab)
B. Wrong: A delivery delay only hides a message when it is first added to the queue. Once a worker receives it, the 30-second visibility timeout applies as before, so the message still reappears while the clip is being processed. Learn more: Amazon SQS delay queues (opens in a new tab)
C. Wrong: This would stop the second transcode, but only by moving clips that are still being worked on into the dead-letter queue once the visibility timeout expires. Those clips would then need manual handling. It hides the symptom instead of fixing the timeout. Learn more: Using dead-letter queues in Amazon SQS (opens in a new tab)
D. Right: Correct. The default visibility timeout is 30 seconds, so a message becomes visible again long before a 2-to-4-minute job finishes, and another worker picks it up. Setting the timeout above the longest processing time keeps the message hidden until the worker deletes it. Learn more: Amazon SQS visibility timeout (opens in a new tab)
Explanation
When a worker receives an SQS message, it is hidden only for the visibility timeout, which defaults to 30 seconds. Because each clip takes 2 to 4 minutes, messages reappear and are processed again. Setting the timeout longer than the maximum processing time (or extending it per message with ChangeMessageVisibility) stops the duplicates. Long polling and delivery delays do not affect in-flight messages.
Want more on Decoupling with queues? The 5 full-length practice sets have 15 more Decoupling with queues questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →