Visibility Timeout

5 minutes 5 Questions

Visibility Timeout is the time period during which a message is invisible to other consumers after being picked up by a consumer from an SQS queue. The purpose of this feature is to ensure that consumers have sufficient time to process a message, preventing other consumers from processing the same message simultaneously. If the consumer does not delete the message within the specified timeout, the message becomes visible again and can be processed by another consumer. The default visibility timeout is 30 seconds, with a maximum of 12 hours.

Understanding and Answering Questions on Visibility Timeout in Amazon SQS

The Visibility Timeout in Amazon SQS is a time duration during which Amazon SQS prevents other consuming components from receiving and processing the message. It functions after a message is read by a consumer from the queue, and during the timeout, the message is considered to be 'in flight'.

This is essential as it helps in maintaining the integrity and flow of messages, especially if the consumer fails to process the message within the specified time, the message will be available to be received again.

Understanding how it works:
- When a consumer reads a message from the queue, the visibility timeout commences.
- It makes a message inaccessible to other consumers until the timeout expires.
- If a message processing fails, the message becomes available again after the timeout.
- If processing is successful, the consumer should delete the message from the queue.
- The visibility timeout can be modified using ChangeMessageVisibility function.

For exam questions, remember:
- Visibility timeout is between 0 seconds to 12 hours, and can be extended while a message is 'in-flight' by up to 12 hours beyond the maximum time the message can stay in the queue.
- The default visibility timeout is 30 seconds.
- Messages left unprocessed after the visibility timeout are requeued.
- A high volume of 'in-flight' messages could signify consumers that can't finish in time or too short visibility timeouts.
- Exam tip: Carefully read questions related to message lifespan, delays, long-polling and in-flight status.
Test mode:

AWS Certified Solutions Architect - Visibility Timeout Example Questions

Test your knowledge of Visibility Timeout

Question 1

Your company is using an Amazon SQS queue to distribute tasks among multiple processing instances. It is noticed that some tasks are taking a longer time to complete, and the visibility timeout is too short for those tasks. How could the application processing those tasks ensure the message does not become visible to other consumers during processing?

Question 2

You are designing an application to process messages from an SQS standard queue. A few messages take longer to process, but you start losing message visibility after 5 minutes. Which approach would best ensure that messages remain in the queue and are completed?

Question 3

Visibility timeout in your SQS queue is set to the default value. However, you found out that some messages take much longer to process than the default visibility timeout. What is the best solution to ensure these messages do not become visible to other consumers again?

More Visibility Timeout questions
28 questions (total)