Is it possible to run more than one rabbitmq instance on one machine?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Running multiple RabbitMQ instances on a single machine can be useful for a variety of reasons, such as testing, development, partitioning different applications to different instances, or experimenting with cluster configurations. This discussion clarifies how you can achieve such a setup and provides practical examples and considerations.
Multi-Instance Setup on a Single Machine
To run multiple RabbitMQ instances on the same machine, each instance needs to be configured to avoid conflicts in network ports, file paths, and Erlang cookie configurations. The key elements that need to be changed for each instance are:
- Node name
- TCP ports for clients and inter-node connections
- Management plugin ports if used
- Data directory paths
- Log file paths
- Erlang cookie
Step-by-Step Configuration
1. Node Name
Each RabbitMQ instance must have a unique node name. Typically, the node name is rabbit@hostname. For multiple instances, you might name them rabbit1@hostname, rabbit2@hostname, etc.
2. TCP Ports
By default, RabbitMQ listens on port 5672 for client connections and port 25672 for inter-node and CLI tool traffic. You must ensure that each RabbitMQ instance uses different ports. For instance:
- Instance 1: 5672 (client), 25672 (inter-node)
- Instance 2: 5673 (client), 25673 (inter-node)
3. Management Plugin Ports
If you enable the management plugin, it usually runs on port 15672. Similar to TCP ports, each instance should use a different port:
- Instance 1: 15672
- Instance 2: 15673
4. Data and Log Directories
Each instance should have its own directory for storing data and logs to prevent any data corruption or overlap. You set this in the RabbitMQ configuration file.
5. Erlang Cookie
The Erlang cookie is crucial for allowing nodes to communicate with each other in a RabbitMQ cluster. For completely independent instances, you can use different cookies; otherwise, keep it the same for clustering.
Practical Implementation
Here's how you might configure and run two RabbitMQ instances on a Unix-like system:
- Install RabbitMQ and ensure it is in your path.
- Create configuration files for each instance. Let’s call them
rabbitmq1.confandrabbitmq2.conf. Customize the node names, ports, and directory paths according to the details above. - Start each instance with their specific configurations. Using the command-line, you might start an instance like this:
- Verify that both instances are running by using the
rabbitmqctlcommand with the-noption corresponding to the node names you configured.
Use Cases and Benefits
The ability to run multiple instances on the same physical server is particularly beneficial in environments where hardware resources are underutilized, or for developers looking to mock complex architectures on their local machine. Below is a table summarizing the key configurations for running two separate instances:
| Setting | Instance 1 | Instance 2 |
| Node name | rabbit1@hostname | rabbit2@hostname |
| Client port | 5672 | 5673 |
| Inter-node port | 25672 | 25673 |
| Management port | 15672 | 15673 |
| Data directory | /var/lib/rabbitmq1 | /var/lib/rabbitmq2 |
| Log directory | /var/log/rabbitmq1 | /var/log/rabbitmq2 |
| Erlang cookie | Different or Same (depends on clustering requirement) |
Conclusion
Running multiple RabbitMQ instances on a single machine is not only feasible but also quite manageable with careful configuration of node-specific details. This setup is ideal for various scenarios including development and testing, or when segregating different applications’ messaging systems within the same server infrastructure.

