AWS Developer DVA-C02 · Troubleshooting and Optimization · medium

An Amazon SQS standard queue has its default VisibilityTimeout set to 30 seconds. A worker EC2 instance polls the queue, receives a video-transcoding message, and takes 75 seconds to finish transcoding the video before calling DeleteMessage. Because 75s > 30s, every video is transcoded two or three times by other workers! Which two solutions prevent duplicate processing while handling messages that occasionally take longer than expected? (Select two.)

Published · Last updated · checked before publication — how we verify questions

Options

  • AIncrease the SQS queue's VisibilityTimeout to exceed the 75-second processing timeCorrect answer
  • BIncrease the SQS ReceiveMessage WaitTimeSeconds (Long Polling) parameter to 20s
  • CCall the ChangeMessageVisibility API from the worker to extend the timeoutCorrect answer
  • DSet the SQS DelaySeconds attribute to 900 seconds on the dead-letter queue

Answers: A. Increase the SQS queue's VisibilityTimeout to exceed the 75-second processing time; C. Call the ChangeMessageVisibility API from the worker to extend the timeout

To prevent a message from becoming visible again while a consumer is still actively processing it, you should (B) increase the queue's VisibilityTimeout above the maximum expected processing time (e.g., 120–300 seconds, up to 12 hours) (A), and/or (C) have the worker call the ChangeMessageVisibility API heartbeat dynamically to extend the timeout for individual long-running messages while still in flight (C).

Why the other options are wrong

  • B. Increase the SQS ReceiveMessage WaitTimeSeconds (Long Polling) parameter to 20s — WaitTimeSeconds controls how long ReceiveMessage waits for an empty queue to receive a message, not how long an in-flight message stays hidden.
  • D. Set the SQS DelaySeconds attribute to 900 seconds on the dead-letter queue — DelaySeconds delays initial visibility of newly enqueued messages; it does not stop an in-flight message's 30s visibility timer from expiring.

All Troubleshooting and Optimization questions and the topic overview →

AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.