Skip to main content

How to set up a RabbitMQ cluster

A RabbitMQ cluster is a group of RabbitMQ nodes that share users, queues, exchanges, bindings, and runtime state so they behave as a single logical message broker. Running RabbitMQ as a cluster gives you high availability and room to scale: if one node fails, the others keep accepting and delivering messages. This guide walks through installing, connecting, and testing a multi-node cluster.

Building webhooks?
Svix is the enterprise ready webhooks sending service. With Svix, you can build a secure, reliable, and scalable webhook platform in minutes. Looking to send webhooks? Give it a try!

When you need a RabbitMQ cluster

A single RabbitMQ node is a single point of failure. If it goes down, publishers and consumers lose their broker and messages stop flowing. Clustering spreads users, exchanges, and queue metadata across several nodes so the broker survives the loss of any one machine, and it lets you add nodes to handle more connections and throughput. If you are only running a development instance or a low-volume service, one node is simpler and often enough.

Setting up the cluster

Prerequisites

  • Two or more machines (physical or virtual) running a compatible OS (e.g., Linux/Unix, Windows).
  • RabbitMQ installed on all machines.
  • Network connectivity between all machines.

Step 1: Install RabbitMQ

  1. Install RabbitMQ on all nodes: Follow the official installation guide to install RabbitMQ on all machines that will form the cluster.

Step 2: Configure hostnames

Each node needs a unique hostname, and every machine must be able to resolve the hostnames of all the others. Update /etc/hosts or your DNS so the nodes can reach each other by name:

# Example /etc/hosts entries
192.168.1.101 rabbitmq-node1
192.168.1.102 rabbitmq-node2

Step 3: Set up RabbitMQ nodes

Start RabbitMQ on all nodes:

rabbitmq-server start

Optionally, enable the RabbitMQ management plugin (highly recommended):

rabbitmq-plugins enable rabbitmq_management

Step 4: Form the cluster

Stop RabbitMQ on nodes that will join the cluster (except the first node):

rabbitmqctl stop

Join each node to the cluster. On each node (except the first one), run:

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@rabbitmq-node1
rabbitmqctl start_app

Replace rabbitmq-node1 with the hostname of the node you want to join.

Verify the cluster status:

rabbitmqctl cluster_status

Step 5: Configure high availability

Clustering replicates metadata across nodes, but queue contents live on one node unless you make the queue itself replicated. On modern RabbitMQ (3.8 and later), use quorum queues, which replicate messages across nodes using a consensus protocol and survive a node failure without data loss. Queue type is chosen when the queue is declared, by passing the x-queue-type argument:

rabbitmqadmin declare queue name=orders queue_type=quorum durable=true

Older guides use classic mirrored queues (a ha-mode: all policy), but mirroring is deprecated and removed in RabbitMQ 4.0, so new clusters should use quorum queues instead.

Step 6: Test the cluster

To test the cluster, publish and consume messages to ensure they are correctly routed within the cluster.

To test failover, stop RabbitMQ on one node and observe if the system continues to operate normally.

Keeping the cluster healthy

A cluster is not set-and-forget. Watch node health, memory and disk alarms, and queue depth so a struggling node does not drag down the rest, and put a load balancer in front of the nodes so clients reconnect to a healthy one when a node drops. For most clusters, three nodes is the practical minimum: quorum queues need a majority to stay available, so three nodes tolerate the loss of one.

The steps above adapt to larger clusters, different network setups, and integration with the rest of your stack. If your goal is reliable event delivery to your own users rather than operating broker infrastructure yourself, a managed webhook service like Svix handles the queueing, retries, and monitoring for you.