Three causes behind one growing number#
The alarm usually fires on ApproximateNumberOfMessagesVisible, the number of messages available for retrieval, or on ApproximateAgeOfOldestMessage. Both rise in each of these cases:
- No consumer is receiving. The workers are stopped, scaled to zero, crash-looping before their first poll, or point at a different queue URL. A Lambda event source mapping may be
Disabled. - Consumers receive but do not delete. Each message is handed out, processing fails or the worker dies, and the message becomes visible again after the visibility timeout. A dependency the consumer calls, such as a database or a payments API, is often the real failure.
- Consumers delete, but slower than producers send. Every message is eventually processed, yet the backlog and the oldest age climb because throughput fell (a slower dependency, fewer workers) or the send rate rose.
Available CloudWatch metrics for Amazon SQS
Why they look alike#
The visible count says only that messages are waiting. It does not say whether anyone asked for them. The metrics that do are the activity counters: NumberOfMessagesReceived counts messages returned by ReceiveMessage, including ones that come back after their visibility timeout expires, and NumberOfMessagesDeleted counts successful deletes. ApproximateNumberOfMessagesNotVisible counts in-flight messages: received, not yet deleted, not yet expired. NumberOfEmptyReceives counts receive calls that returned nothing. SQS metrics
The oldest-message age can also mislead. For standard queues, a message that is received three or more times without being deleted is moved to the back of the queue, and ApproximateAgeOfOldestMessage then reports the next message that has not passed that threshold. A few poison messages can therefore hide from the age metric while they keep consuming receives. SQS metrics · Dead-letter queues
Read the queue without touching it#
Start with the queue's attributes. get-queue-attributes returns the current approximate counts and the settings that shape retries: VisibilityTimeout, ReceiveMessageWaitTimeSeconds, MessageRetentionPeriod and RedrivePolicy (the dead-letter target and maxReceiveCount). The counts may lag by about a minute. GetQueueAttributes · get-queue-attributes
aws sqs get-queue-attributes \
--profile PROFILE --region REGION --queue-url QUEUE_URL \
--attribute-names ApproximateNumberOfMessages ApproximateNumberOfMessagesNotVisible \
VisibilityTimeout ReceiveMessageWaitTimeSeconds MessageRetentionPeriod RedrivePolicy \
--output json --no-cli-pager
Then read the activity counters over the incident window, one metric at a time, with the QueueName dimension. Run it for NumberOfMessagesSent, NumberOfMessagesReceived, NumberOfMessagesDeleted and NumberOfEmptyReceives with Sum, and for ApproximateNumberOfMessagesNotVisible with Maximum. get-metric-statistics
aws cloudwatch get-metric-statistics \
--profile PROFILE --region REGION \
--namespace AWS/SQS --metric-name NumberOfMessagesReceived \
--dimensions Name=QueueName,Value=QUEUE_NAME \
--start-time 2026-11-23T13:00:00Z --end-time 2026-11-23T15:00:00Z \
--period 300 --statistics Sum \
--output table --no-cli-pager
Do not use aws sqs receive-message to look at the backlog. It is not a read: every message it returns becomes invisible to your consumers for the visibility timeout and gains one receive, which counts toward maxReceiveCount. ReceiveMessage
If the consumer is a Lambda function, read the event source mapping too. State is one of Creating, Enabling, Enabled, Disabling, Disabled, Updating or Deleting, and StateTransitionReason says whether a user or Lambda made the last change. list-event-source-mappings · EventSourceMappingConfiguration
aws lambda list-event-source-mappings \
--profile PROFILE --region REGION --event-source-arn QUEUE_ARN \
--query 'EventSourceMappings[].{function:FunctionArn,state:State,reason:StateTransitionReason,result:LastProcessingResult}' \
--output table --no-cli-pager
Read the pattern#
| Received | Deleted | In flight | Points to |
|---|---|---|---|
| Near zero | Near zero | Near zero | No consumer is polling |
| High, repeating | Near zero | High | Consumers fail after receiving |
| Steady | Steady, below sent | Near its usual level | Consumers are too slow |
Empty receives help with the first row. If they are also near zero, nothing is calling ReceiveMessage at all. If they are high while messages are visible, something is polling and getting nothing back, which with short polling can happen on a small queue; long polling reduces empty responses. A consumer polling a different queue, for example one named in a new release's configuration, shows its empty receives on that other queue. Short and long polling
For the second row, count receives per sent message. If NumberOfMessagesReceived runs at several times NumberOfMessagesSent and deletes stay low, the same messages are going round. Read the consumer's own logs for the error it hits after receiving, and if it calls another dependency, follow that error. If messages that came back after a failure are also being processed twice, see duplicate processing from visibility timeouts. With a redrive policy, the failing messages move to the dead-letter queue after maxReceiveCount receives: a dead-letter queue that is filling.
A worked example: two backlogs on one queue#
This example is illustrative. The fictional orders service consumes the queue orders-events in account 111122223333. Both incidents start with the same alarm: ApproximateNumberOfMessagesVisible above 5,000 at 14:10 UTC.
In the first incident, the five-minute sums from 14:00 look like this:
| Metric | 13:50 | 14:05 |
|---|---|---|
| NumberOfMessagesSent | 3,000 | 3,100 |
| NumberOfMessagesReceived | 3,020 | 14,800 |
| NumberOfMessagesDeleted | 2,990 | 40 |
| Max messages not visible | 60 | 2,400 |
Receives quadrupled while deletes collapsed, and in-flight messages climbed. The consumers are working and failing. Their logs show connection timeouts to the orders database from 14:02. The queue is a symptom; the database is the dependency to investigate. Connection pool timeout or slow database
In the second incident:
| Metric | 13:50 | 14:05 |
|---|---|---|
| NumberOfMessagesSent | 3,000 | 3,050 |
| NumberOfMessagesReceived | 3,020 | 0 |
| NumberOfMessagesDeleted | 2,990 | 0 |
| NumberOfEmptyReceives | 410 | 0 |
Nothing is receiving, not even empty receives. The consumer service scaled to zero tasks at 14:01 after a failed deployment, and no worker is polling. Fixing the workers ends the incident; the database is fine.
Limits#
Every SQS count here is approximate, and the activity counters include retries and duplicates. NumberOfMessagesDeleted counts each successful delete call, so a message deleted twice is counted twice. Treat the numbers as rates to compare, not exact message counts. SQS metrics
Messages that wait longer than MessageRetentionPeriod are deleted by SQS, so a backlog that stops growing can mean consumers recovered or messages expired. Compare deletes with sends before you call it recovered.
The queue metrics cannot say which part of the consumer failed. They narrow it to "not polling", "failing after receive" or "too slow", and the consumer's logs and the dependency it calls answer the rest. If the backlog started right after a release of the consumer, compare the old and new revisions first. Other dependency failures are covered in diagnosing runtime dependency failures.
Questions#
Is ApproximateNumberOfMessagesVisible the same as the backlog?
It is the number of messages available for retrieval now. Messages that consumers have received but not deleted are counted separately in ApproximateNumberOfMessagesNotVisible, and delayed messages in ApproximateNumberOfMessagesDelayed. Add them together for everything that is still in the queue.
Can I peek at messages in an SQS queue without affecting consumers?
Not through the queue. SQS hands out message bodies through ReceiveMessage, and a receive hides the message from your consumers for the visibility timeout and increases its receive count, which moves it closer to the dead-letter queue. Use the attributes and metrics, and read message contents from consumer logs where they exist.
Why is the oldest message age flat while the backlog grows?
Messages that keep failing are moved to the back of a standard queue after three or more receives and drop out of the age metric. A growing count with a flat age can mean new messages are processed while a set of failing ones circulates.