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
# 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_countFixes
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.
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.
Related reading
- How to monitor Heroku: How to monitor apps on Heroku: H12 timeouts and other router errors, dyno memory (R14), response time, Postgres and Redis add-ons, uptime checks and alerts.
- Go panic: invalid memory address or nil pointer dereference: Fix Go panic: runtime error: invalid memory address or nil pointer dereference. Read the stack, spot unchecked errors, nil maps and typed nil interfaces.
- Redis monitoring: metrics that matter: Monitor Redis with INFO: memory and evictions, hit rate, clients, latency, persistence and replication, with thresholds and the alerts to set.
- Why is my website slow? A step-by-step diagnosis: Diagnose a slow website in order: server, loading, stability and responsiveness. Use real-user data, lab tests and traces to find what to fix first.
- How to find a Node.js memory leak: Detect a Node.js memory leak from heap metrics, compare heap snapshots to find what retains memory, fix the usual causes and alert before a crash.
- PHP "Allowed memory size exhausted": how to fix it: Fix PHP Fatal error: Allowed memory size exhausted. Read the error correctly, raise memory_limit for the right SAPI and stop loading big data into arrays.
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.