🔷

Amazon SQS – Message Visibility Timeout

When a message is retrieved from an SQS queue by a consumer, it becomes temporarily invisible to all other consumers. This period, known as the visibility timeout, ensures that only the receiving consumer can process the message. By default, the timeout is 30 seconds, meaning the consumer has that amount of time to complete processing and delete the message. If the message is not deleted within this window, it becomes visible in the queue again and can be delivered to another consumer, which may lead to duplicate processing.
Consumers can use the ChangeMessageVisibility API to extend the timeout dynamically if more processing time is required. Setting the right value is a trade-off: a timeout that is too long delays retries in case of consumer failure, while a timeout that is too short increases the likelihood of duplicate deliveries if processing regularly takes longer than expected.