- Newest
- Most votes
- Most comments
The discrepancy between the decreasing "Messages available" number on the SQS Queues dashboard and the increasing "ApproximateNumberOfMessagesVisible" metric in CloudWatch could be explained by how Amazon SQS samples its servers when reporting these metrics.
When you view the "Messages available" count on the SQS dashboard, this metric is based on a sampling of SQS servers. Amazon SQS samples a subset of its servers (based on a weighted random distribution) when reporting metrics, especially for standard queues. This sampling behavior means that at any given moment, the dashboard might not be showing the complete picture of all messages in the queue.
The CloudWatch metric "ApproximateNumberOfMessagesVisible" is also an approximate count, as the name suggests, but it's typically more comprehensive as it aggregates data over time. If this metric is consistently increasing, it suggests that messages are indeed accumulating in your queue.
Several factors could explain why the "Messages available" count might decrease even without consumers:
-
Short polling behavior: When metrics are gathered using short polling, SQS samples only a subset of its servers, potentially missing messages on other servers.
-
Server distribution: Messages in SQS are distributed across multiple servers. The sampling might hit different servers at different times, causing fluctuations in the reported count.
-
Visibility timeout expiration: If messages were previously in flight but their visibility timeout expired, they would become visible again, potentially causing fluctuations in the count.
-
Message expiration: If your queue has message retention limits set, older messages might be expiring and getting deleted automatically.
For a more accurate understanding of your queue's state, it's generally better to rely on CloudWatch metrics over a period of time rather than point-in-time observations from the dashboard.
Sources
Amazon SQS short and long polling - Amazon Simple Queue Service
Troubleshoot messages not returned for an Amazon SQS ReceiveMessage API call - Amazon Simple Queue Service
Hello.
By default, messages that haven't been processed for four days will be deleted.
As a result, it's possible that thousands of messages are disappearing all at once.
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html
Amazon SQS automatically deletes messages that have been in a queue for more than the maximum message retention period. The default message retention period is 4 days. However, you can set the message retention period to a value from 60 seconds to 1,209,600 seconds (14 days) using the SetQueueAttributes action.
Relevant content
asked 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 5 years ago
