Skip to content

Troubleshooting guide

RabbitMQ queue backlog: how to diagnose and clear it

A growing queue means messages arrive faster than they are acknowledged. Whether they are ready or unacked tells you where to look.

3 min read10 sectionsUpdated

On this page

Key points

  • Ready messages: not enough consumers.
  • Unacked messages: consumers took them but have not finished.
  • Memory or disk alarms block publishers, stalling producers.
  • Queues are not databases: keep them short.

Reading the two counters

messages_ready waits for a consumer. messages_unacknowledged has been delivered and awaits an ack. A high ready count points to capacity. A high unacked count points to consumers that are stuck, slow, or holding too much at once.

Common causes

  • Consumers down or too few.
  • A slow dependency inside the handler.
  • A high prefetch, letting one consumer hoard messages.
  • Forgotten acks, so messages stay unacked until the channel closes.
  • Requeue loops where a failing message returns immediately.

Diagnose it

Use rabbitmqctl, or the management UI, which shows the publish, deliver and ack rates.

bash
# Depth, consumers and memory per queue
rabbitmqctl list_queues name messages_ready messages_unacknowledged consumers memory

# Node alarms (memory or disk)
rabbitmq-diagnostics alarms

# Consumers and their prefetch
rabbitmqctl list_consumers queue_name channel_pid prefetch_count

Fixes

Add consumers to clear ready messages. Set a modest prefetch, such as 10 to 50, so work spreads evenly. Fix handlers that forget to ack. Use a dead-letter exchange for failures instead of requeueing forever. Protect the broker with x-max-length and a message TTL for data that loses value with age. Use quorum queues for durability, and lazy-style storage for genuinely long backlogs.

When publishers hang

If memory passes vm_memory_high_watermark or free disk falls below disk_free_limit, RabbitMQ blocks publishing connections across the node. Producers then appear to hang on publish, and this can freeze web requests that publish synchronously, turning a queue problem into a site outage. Publish with a timeout, and have a fallback path for critical events. Clearing a backlog also needs care: scaling consumers instantly can overload the database behind them, so raise concurrency in steps while watching the downstream.

Catch it automatically

Alert on age of the oldest message or on sustained growth, and on any alarm. RabbitMQ monitoring shows rates per queue, and a heartbeat check confirms consumers are still doing work.

Frequently asked questions

What prefetch should I use?

Start low for slow work, about 10, and higher for fast handlers. Measure throughput and adjust.

Can I purge a queue?

Yes, but the messages are permanently gone. Move them to another queue if they might matter.

Why are unacked messages stuck?

Consumers received but did not ack them. They return to the queue when the channel closes.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.