Frequently Asked Questions - RabbitMQ

This FAQ answers common questions about RabbitMQ architecture, reliability, scaling, performance, and troubleshooting. If you need any support, please visit our support page.

If you’re looking for CloudAMQP-specific questions about plans, billing, security, regions, or managed services, see the CloudAMQP FAQ.

Getting Started

What is RabbitMQ?

RabbitMQ is an open-source message broker that enables applications and services to communicate asynchronously through messages. It supports multiple messaging patterns, including point-to-point, publish/subscribe, request/reply, and event-driven architectures.

Its primary protocol is AMQP 0-9-1, and it supports additional messaging protocols through plugins, making it suitable for a wide range of application architectures.

When should I use RabbitMQ?

RabbitMQ is a good choice when you need asynchronous processing, background jobs and task queues, event-driven architectures, reliable message delivery, microservice communication, and workload buffering during traffic spikes.

Common use cases include order processing, notifications, payment workflows, IoT messaging, and application integration.

RabbitMQ vs LavinMQ: Which should I choose?

RabbitMQ and LavinMQ are AMQP 0-9-1 compatible message brokers, meaning most client applications can connect to either broker without code changes.

RabbitMQ is written in Erlang and has been widely used in production for many years. It has a large ecosystem and extensive deployment options.

LavinMQ is a modern message broker written in Crystal and is designed for simplicity, efficient resource utilization, and operational ease. Unlike RabbitMQ, which uses a dedicated Streams protocol for streaming workloads, LavinMQ uses AMQP for both message queuing and streaming.

Choose RabbitMQ if:

  • You require the dedicated RabbitMQ Streaming protocol.

Choose LavinMQ if:

  • You want a lightweight and resource-efficient broker.

  • You want to use AMQP for both queuing and streaming workloads.

RabbitMQ vs Kafka: Which should I choose?

RabbitMQ and Kafka are both used for asynchronous communication, but they are designed for different messaging patterns.

RabbitMQ is a message broker. It is a good choice when you need task queues, request/reply messaging, complex routing, low-latency delivery, acknowledgements, retries, and dead-lettering.

Kafka is a distributed event streaming platform. It is a good choice when you need a durable event log, long message retention, event replay, stream processing, or very high-throughput data pipelines.

RabbitMQ can also support event streaming through RabbitMQ Streams. Streams provide an append-only log, message replay, offsets, and multiple independent consumers. This makes RabbitMQ a good option when you need both traditional messaging and moderate-scale event streaming in the same broker.

What is a message broker?

A message broker is middleware that enables applications, services, and systems to communicate by exchanging messages. Instead of communicating directly, applications send messages to the broker, which stores, routes, and delivers them to the appropriate recipients.

By acting as an intermediary, a message broker decouples producers and consumers, improves reliability, and enables asynchronous communication between distributed systems.

Common use cases include microservices communication, background job processing, IoT data ingestion, and event-driven architectures.

Popular message brokers include RabbitMQ and LavinMQ.

Core Concepts

What is AMQP?

AMQP (Advanced Message Queuing Protocol) is an open standard messaging protocol used by brokers such as RabbitMQ and LavinMQ to exchange messages between applications.

AMQP defines how clients connect to a broker, publish messages, consume messages, acknowledge deliveries, and route messages between exchanges and queues. Because it is a standardized protocol, applications written in different programming languages can communicate through the same broker.

In short, AMQP is the protocol that defines how messaging clients and brokers communicate, making RabbitMQ applications interoperable across languages and platforms.

What is a queue?

A queue is a buffer that stores messages until a consumer is ready to process them. It is one of the core building blocks of RabbitMQ and enables asynchronous communication between applications.

Queues are FIFO (first in, first out) by default, although priorities, multiple consumers, and message redelivery can affect processing order.

RabbitMQ supports Classic queues, Quorum queues, and Streams. For most new deployments, Quorum queues are the recommended queue type.

What is an exchange?

An exchange is the component that receives messages from producers and routes them to queues based on rules. The producer never sends directly to a queue — it always sends to an exchange first.

RabbitMQ supports four exchange types: direct, fanout, topic, and headers. For simple use cases, RabbitMQ also provides a built-in default exchange that can route messages directly to a queue by name.

What is a routing key?

A routing key is a label attached to a message by the producer that the exchange uses to decide which queue(s) to route the message to.

Think of it like the address on an envelope — the exchange (post office) reads it and decides where the message should go.

How the routing key is used depends on the exchange type:

  • Direct exchanges route messages based on an exact match.

  • Topic exchanges route messages using pattern matching.

  • Fanout exchanges ignore routing keys and send messages to all bound queues.

  • Headers exchanges use message headers instead of routing keys.

Routing keys work together with queue bindings to provide flexible message routing.

What is a connection?

A connection is a TCP connection between an application and a RabbitMQ broker. It provides the underlying communication channel used for publishing, consuming, and managing messaging resources.

Because connections consume resources, applications usually maintain a small number of long-lived connections and create multiple channels within those connections to publish and consume messages.

What is a channel?

A channel is a lightweight virtual connection inside a TCP connection. All RabbitMQ operations—such as publishing messages, consuming messages, and declaring queues—are performed on channels.

Channels are cheaper to create than TCP connections, which allows applications to reuse a single connection and open multiple channels when needed.

Application
  └── Connection (TCP)
        ├── Channel 1 → publish messages
        ├── Channel 2 → consume messages
        └── Channel 3 → declare queues and exchanges
What are virtual hosts (vhosts)?

A virtual host (vhost) is a logical grouping that provides isolation within a RabbitMQ broker. Each vhost has its own queues, exchanges, bindings, and permissions.

Vhosts are commonly used to separate applications, environments (development, staging, production), or teams while sharing the same RabbitMQ broker.

RabbitMQ Broker
├── vhost: /production
├── vhost: /staging
└── vhost: /development

Reliability

What delivery guarantees does RabbitMQ provide?

RabbitMQ can provide different delivery guarantees depending on how it is configured.

  • At-most-once delivery – Messages may be lost if a failure occurs. This provides the lowest overhead and highest throughput.

  • At-least-once delivery – Messages are redelivered if a failure occurs before processing is complete. This is the most common configuration for production systems and is achieved using publisher confirms, durable queues, persistent messages, and manual acknowledgements.

  • Effectively exactly-once processing – RabbitMQ does not provide exactly-once delivery natively. Applications that require it typically combine at-least-once delivery with idempotent consumers and message deduplication.

For most production workloads, at-least-once delivery with idempotent consumers provides the best balance between reliability and complexity.

What happens if RabbitMQ restarts?

What survives a RabbitMQ restart depends on your durability settings.

  • Connections and channels are closed and clients must reconnect.

  • Durable queues, exchanges, and bindings are recovered.

  • Persistent messages in durable queues are recovered.

  • Transient queues and non-persistent messages may be lost.

  • Unacknowledged messages are requeued and may be redelivered.

To ensure data survives a restart, use durable queues and exchanges, publish important messages as persistent, and implement reconnect logic in your applications.

What are acknowledgements (ACKs)?

An acknowledgement (ACK) is a signal from a consumer to RabbitMQ confirming that a message has been successfully processed.

RabbitMQ keeps a message until it receives an ACK. If a consumer crashes before acknowledging the message, RabbitMQ can requeue it and deliver it to another consumer.

For most production workloads, manual acknowledgements are recommended because they help prevent message loss during failures.

What happens if a consumer crashes?

When a consumer crashes or disconnects, RabbitMQ detects the lost connection and automatically requeues any unacknowledged messages that were assigned to that consumer.

These messages can then be delivered to another consumer or to the same consumer when it reconnects.

If the consumer was using automatic acknowledgements (auto-ack), messages that had already been delivered cannot be recovered because RabbitMQ considers them successfully processed as soon as they are sent.

For most production workloads, manual acknowledgements are recommended because they allow RabbitMQ to redeliver messages when a consumer fails before processing is complete.

What are publisher confirms?

When publisher confirms are enabled, RabbitMQ sends an acknowledgement (ACK) back to the producer after accepting a message. If the broker cannot process the message, it sends a negative acknowledgement (NACK), allowing the producer to retry or take corrective action.

Without publisher confirms, a producer cannot know whether a message was successfully received by RabbitMQ or lost due to a network or broker failure.

Producer → Publish message
        ↓
RabbitMQ receives message
        ↓
RabbitMQ sends ACK
        ↓
Producer knows the message was accepted

Publisher confirms are recommended for applications that require reliable message delivery.

How can I avoid losing messages?

To improve message reliability, use durable queues, publish persistent messages, enable publisher confirms, and use manual consumer acknowledgements.

If a consumer fails before acknowledging a message, RabbitMQ can requeue it for another consumer. Dead-letter exchanges (DLXs) can be used to handle messages that cannot be processed successfully.

What is a dead-letter queue?

A dead-letter queue (DLQ) is a queue that receives messages that could not be processed successfully. Common reasons include message expiration, consumer rejection, or queue length limits.

Instead of being discarded, these messages are routed to a dead-letter queue where they can be inspected, retried, or archived for later analysis.

Normal Queue → DLX → Dead-Letter Queue

Dead-letter queues help make failures visible and recoverable, making them a common pattern in reliable messaging systems.

Scaling and Performance

How many messages per second can RabbitMQ handle?

Performance depends on factors such as message size, persistence settings, acknowledgements, routing complexity, and available hardware resources.

A well-configured RabbitMQ deployment can handle tens of thousands to millions of messages per second depending on the workload.

The best way to estimate throughput is to benchmark RabbitMQ using traffic patterns that closely match your production environment.

How do I scale RabbitMQ consumers?

The most common way to scale RabbitMQ consumers is to add more consumer instances to the same queue. RabbitMQ automatically distributes messages among available consumers, allowing workloads to be processed in parallel.

To improve performance and fairness, configure an appropriate prefetch value and monitor queue depth, consumer utilisation, and unacknowledged messages. For larger workloads, consumers can be scaled horizontally using multiple processes, containers, or Kubernetes pods.

Consumer 1 ─┐
Consumer 2 ─┼── Queue
Consumer 3 ─┘

If queue depth is consistently growing, consider adding more consumers or increasing processing capacity.

Should I use one queue or many queues?

Use one queue when messages represent the same type of work and can be processed by the same consumers. This keeps the system simple and easy to manage.

Use multiple queues when different workloads require different processing logic, priorities, consumer groups, or scaling strategies.

A common approach is to start with one queue per logical task type and only introduce additional queues when you need isolation, prioritization, or independent scaling.

How many connections should my application open?

In general, applications should open as few RabbitMQ connections as possible and use channels for concurrency.

A common pattern is to maintain one long-lived TCP connection per application process and create multiple channels within that connection for publishing and consuming messages.

Application
  └── Connection
        ├── Channel 1 (Producer)
        ├── Channel 2 (Consumer A)
        └── Channel 3 (Consumer B)

Connections require operating-system resources such as sockets, memory, and file descriptors, while channels are lightweight virtual connections designed for concurrent work.

Additional connections may be appropriate when running multiple processes, isolating publishers and consumers, or supporting very high-throughput workloads.

As a rule of thumb: use one connection per process and create channels as needed.

What is consumer prefetch?

Consumer prefetch controls how many unacknowledged messages RabbitMQ can send to a consumer at one time.

Once the prefetch limit is reached, RabbitMQ waits for acknowledgements before delivering more messages. This helps balance workload between consumers and prevents slow consumers from being overwhelmed.

For most workloads, a prefetch value between 10 and 50 is a good starting point.

Modern RabbitMQ Features

What are quorum queues?

Quorum queues are RabbitMQ’s modern replicated queue type designed for high availability and data safety. They use the Raft consensus algorithm to replicate messages across multiple nodes in a cluster and are the recommended queue type for most production workloads.

A message is only confirmed once a majority of queue replicas have successfully stored it, helping protect against data loss during node failures.

Node 1 (Leader)    ✓
Node 2 (Follower)  ✓  → Quorum reached → Message confirmed
Node 3 (Follower)  ✓

Compared to classic mirrored queues, quorum queues provide more predictable recovery, stronger consistency guarantees, and improved reliability in clustered environments.

Quorum queues are always durable and support standard messaging features such as acknowledgements, dead lettering, and message redelivery.

For most new RabbitMQ deployments, quorum queues are recommended over classic mirrored queues.

What are streams?

Streams are a RabbitMQ data structure designed for high-throughput, replayable messaging. Unlike queues, messages remain available after they are consumed and can be replayed multiple times.

Streams are optimized for event streaming, analytics pipelines, audit logs, and workloads where multiple consumers need access to the same data.

Should I use streams or queues?

Use a stream when multiple consumers need access to the same data or when message replay is required. For traditional work queues where each message should be processed only once, use a queue instead.

Stream consumers track their position using offsets, allowing them to start reading from a specific message, timestamp, or from the beginning of the stream.

Streams are well suited for event streaming, audit logs, analytics pipelines, and applications that need to replay historical messages.

Producer → Stream → Consumer A (offset 0)
                  → Consumer B (offset 100)
                  → Consumer C (latest)

Unlike queues, consuming a message does not remove it from a stream. Messages are retained according to configurable size or time-based retention policies.

Security

Should RabbitMQ be exposed directly to the internet?

No. RabbitMQ should be accessible only to trusted applications and users on secured networks.

To reduce security risks, use TLS, firewalls, private networking, and strong authentication. Both the AMQP ports and the Management UI should be protected from public access whenever possible.

Does RabbitMQ support TLS?

Yes. RabbitMQ supports TLS for encrypting client connections and protecting data in transit.

RabbitMQ can be configured for both one-way TLS, where the client verifies the broker’s certificate, and mutual TLS (mTLS), where both the client and broker authenticate each other using certificates.

For production deployments, TLS is strongly recommended to protect credentials and message traffic from unauthorized access.

For the certificates CloudAMQP servers use and their root CA, see How do I authenticate the identity of your server? in the CloudAMQP FAQ.

How should credentials be managed?

RabbitMQ credentials should be managed according to standard security best practices. Use a dedicated user for each application, grant only the permissions required, and store credentials securely using a secrets manager or environment variables.

Avoid hardcoding credentials in source code, configuration files, or container images. Credentials should be rotated regularly and transmitted only over encrypted connections such as TLS.

  • Use a dedicated user per application

  • Apply the principle of least privilege

  • Store credentials in a secrets manager or environment variables

  • Rotate passwords regularly

  • Use TLS to protect credentials in transit

  • Disable or restrict the default guest account

For highly sensitive environments, client certificate authentication (mTLS) can be used instead of username and password authentication.

Monitoring and Operations

Which RabbitMQ metrics should I monitor?

The most important RabbitMQ metrics to monitor are queue depth, consumer health, resource usage, and message throughput.

  • Messages ready – messages waiting to be consumed.

  • Messages unacknowledged – messages delivered but not yet acknowledged.

  • Consumer count – ensures consumers are connected and processing messages.

  • Publish and deliver rates – helps identify whether consumers can keep up with incoming traffic.

  • Memory usage – high memory usage can trigger flow control and block publishers.

  • Disk free space – low disk space can prevent RabbitMQ from accepting new messages.

  • Connection and channel count – useful for identifying connection leaks or unusual activity.

For clustered deployments, monitor node availability and network partitions to ensure the cluster remains healthy.

In most production environments, memory usage, disk space, queue depth, and consumer count are the highest-priority metrics to alert on.

Why is my queue growing?

A growing queue usually means messages are being published faster than they are being consumed.

Common causes include:

  • Not enough consumers to keep up with the publish rate

  • Slow consumer processing, such as database queries or external API calls

  • Consumer failures causing messages to be requeued

  • A sudden spike in message volume

  • Broker resource constraints, such as memory or disk alarms

To troubleshoot, compare the publish rate with the delivery and acknowledgement rates, check consumer health, and look for active broker alarms.

If the queue continues to grow over time, consider adding more consumers, increasing consumer throughput, or investigating application bottlenecks.

Why is RabbitMQ using so much memory?

High memory usage is most commonly caused by messages accumulating in queues or consumers holding large numbers of unacknowledged messages. Large message payloads, many queues, and a high number of connections can also increase memory consumption.

Use the RabbitMQ Management UI to review queue depth and the memory breakdown to identify where memory is being used.

Common solutions include scaling consumers, reducing unacknowledged messages, limiting queue growth, and increasing broker resources.

Troubleshooting

Why am I seeing heartbeat timeout errors?

Common causes include:

  • Long-running message processing that blocks the connection thread

  • Network interruptions or firewall timeouts

  • Heartbeat values configured too low

  • An overloaded RabbitMQ broker

  • Client libraries that are misconfigured or not sending heartbeats correctly

To troubleshoot heartbeat timeout errors, verify that your application is processing messages efficiently, check network stability, review heartbeat settings, and monitor broker resource usage.

For most deployments, the default heartbeat value of 60 seconds is sufficient. Applications should also implement automatic reconnection logic to handle unexpected connection failures.

Why are messages being redelivered?

RabbitMQ redelivers messages when they were not successfully acknowledged by a consumer.

This typically happens when a consumer crashes, disconnects, rejects a message for requeueing, or when a channel or connection closes before the message is acknowledged.

Applications should be designed to handle redelivered messages safely, since a message may be delivered more than once.

Why are consumers not receiving messages?

If consumers are not receiving messages, verify that consumers are connected, the queue contains messages, and the consumer has not reached its prefetch limit.

Also check that the consumer is connected to the correct queue and virtual host, and that messages are being routed to the expected queue.

The RabbitMQ Management UI and consumer application logs are usually the best places to start troubleshooting.