Glossary · Q

Queue Depth

The number of messages, jobs or requests waiting in a queue to be processed at a given moment.

By Obseria Editorial TeamUpdated

Definition

Queue depth is the number of items, such as messages, jobs, requests or I/O operations, that are waiting in a queue at a given moment. Combined with the arrival or drain rate, it tells you how long new work will wait, and a steadily growing queue depth is a direct sign that consumers cannot keep up with producers.

What is queue depth?

Queue depth, also called queue length or backlog, is the number of items waiting in a queue to be processed. The items can be messages in Kafka, RabbitMQ or Amazon SQS, jobs in a worker queue, requests waiting for a free thread, or I/O operations queued at a disk. Wherever producers and consumers are decoupled by a buffer, queue depth is the most direct measure of how far the consumers are behind.

Queue depth is a saturation signal in the sense of the golden signals: a queue that is usually close to empty means spare capacity, while a queue that grows means demand exceeds the capacity to process it.

Queue depth and wait time: Little's Law

The link between queue depth and waiting time is Little's Law from queueing theory:

L = λ × W

L = average number of items in the system (queue depth)
λ = average arrival rate (items per second)
W = average time an item spends in the system

The law holds for any stable system over a long enough period, regardless of the arrival distribution. Rearranged as W = L / λ, it lets you turn a queue depth into an expected wait. In steady state the arrival rate equals the departure rate, so you can also use the consumers' processing throughput.

Illustrative example: a queue holds 12,000 messages and consumers process 400 messages per second. New messages will wait roughly 12,000 / 400 = 30 seconds before they are picked up. If your end-to-end target is 10 seconds, you need either three times the consumer throughput or a smaller backlog.

Why queues grow so fast near capacity

Queueing theory also explains why backlogs appear suddenly. As consumer utilization approaches 100 percent, average wait time does not grow linearly but sharply: in the simple M/M/1 model, the expected time in the system is 1 / (μ − λ), where μ is the service rate. Going from 80 to 95 percent utilization roughly quadruples the wait. If arrivals stay above the service rate for any length of time, the queue grows without bound. This is why a system that looks fine at 80 percent can fall far behind after a modest traffic increase.

What to measure

MetricWhat it tells youExamples
Queue depth / backlogHow much work is waitingSQS ApproximateNumberOfMessagesVisible, RabbitMQ ready messages
Consumer lagHow far consumers are behind the latest offsetKafka lag per partition and consumer group
Age of oldest itemHow long the worst-case item has waitedSQS ApproximateAgeOfOldestMessage
Arrival and drain rateWhether the backlog is growing or shrinkingMessages in vs. messages acknowledged per second
Dead-letter queue depthHow many items failed permanentlyDLQ message count

Depth alone is ambiguous: 50,000 messages is harmless for a consumer group that drains 20,000 per second and critical for one that drains 50. Always read depth together with the drain rate or the age of the oldest message.

Alerting and autoscaling on queue depth

  • Alert on time, not count. Age of the oldest message or estimated wait (depth / drain rate) maps directly to user impact and to your SLO.
  • Alert on trend. A backlog that has grown continuously for 15 minutes is more meaningful than a short spike after a burst.
  • Scale consumers on backlog. Tools such as KEDA in Kubernetes scale workers on queue length or consumer lag. Divide the backlog by the per-worker throughput to get a target replica count.
  • Respect downstream limits. More consumers increase load on the database or API they write to. Scale within the capacity of the slowest dependency.
  • Bound the queue. Unbounded queues hide overload until memory runs out. A bounded queue with backpressure or rate limiting fails visibly and early.

Common mistakes

  • Treating a deep queue as a consumer problem when the real bottleneck is a slow downstream dependency. Traces across producer, queue and consumer show where time is spent.
  • Monitoring the total lag of a topic but not per partition, so one hot partition stays hidden.
  • Ignoring the dead-letter queue until it holds days of failed orders.
  • Using fixed depth thresholds although normal backlog varies strongly by time of day. A baseline or anomaly detection handles seasonality better.

How Obseria helps

Obseria collects broker and consumer metrics such as depth, lag and message age, and links them to the traces of producers and consumers, so you see whether a backlog comes from a traffic burst, slow consumers or a failing dependency. Queue monitoring in Obseria covers brokers such as Kafka, and anomaly detection learns normal backlog patterns. Read more about Kafka monitoring.

Frequently asked questions

There is no universal value. A good queue depth is one where the resulting wait time (depth divided by drain rate) stays within your latency target. For most online workloads the queue should be close to empty most of the time and drain quickly after bursts.

Queue depth counts the items waiting in a queue. Consumer lag, used for log-based brokers such as Kafka, is the difference between the latest offset and the consumer group's committed offset per partition. Both express backlog; lag is per consumer group because several groups can read the same topic.

Yes. For a stable queue over a sufficiently long period, average depth equals arrival rate times average time in the system. It is a good tool to estimate wait time from depth and rate, but it describes averages, not worst-case delays.

For storage, queue depth is the number of outstanding I/O requests at a device. Higher queue depth can increase throughput on SSDs and NVMe drives, but a persistently high value with rising latency indicates that the device is saturated.

Put these concepts into practice

Try Obseria free for 14 days, with OpenTelemetry and no proprietary agents.