What does visibility Timeout mean for AWS SQS
Asked Answered
C

4

32

What is the meaning of "Visibility Timeout" for Amazon SQS service ? What factors determine an ideal value for this field ?

I have looked at http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Welcome.html

Colpin answered 25/2, 2015 at 7:22 Comment(0)
K
61

When using sqs as queuing service, when you read the message off the queue it does not automatically delete the message off the queue. So when you are processing the message, sqs will wait for the time period defined as visibility timeout before other consumers will get the same message again.

The best time value to set for the visibility timeout will be at least the timeout value for the consumer process. If the consumer is able to successfully complete the processing then it would delete the message off the queue else if it times out then the message reappears in the queue for other consumer to pick it again.

Khosrow answered 25/2, 2015 at 18:23 Comment(4)
Can this be considered the "retry" interval for a failed message? That is, if a consumer fails to process a message, it will not try again until the visibility timeout has elapsed?Parik
@TheUnknownDev This would be the minimum time before it can be retried. Since the first attempt failed to process the message, no other consumer will get this message to process it again.Khosrow
can we change visibility timeout and then later delete from SQS using same receiptHandle?Poleax
does this "ill wait before other consumers get the message" only apply to pub-sub? If I am not wrong, w.r.t a queue, only one (among many) consumers can consume a message so there is no question of other consumers receiving the same message, is there?Casa
S
11

Visibility timeout is the time-period or duration you specify for the queue item which when is fetched and processed by the consumer is made hidden from the queue and other consumers.

The main purpose is to avoid multiple consumers (or the same consumer), consuming the same item repetitively.

The key factor to be considered while arriving at this value is the time & effort taken by the consumer(s) to process a single queue item.

Segal answered 25/2, 2015 at 8:35 Comment(0)
M
2

Basically the time taken by the consumer to process the message. And during the same time the message is unvailable for any other consumer (since this is a distributed system). Although the time priod is configurable, the default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours.

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html

Mckim answered 3/8, 2019 at 13:26 Comment(0)
R
-3

Visibility Timeout is an important functionality of Amazon SQS. It helps to ensure the integrity and reliability of message processing in distributed systems.

You can know more about it here https://link.medium.com/u3A8aId0Swb

Romeo answered 25/1, 2023 at 21:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.