A single RabbitMQ instance can serve many teams or many environments at once. In this episode you create and manage virtual hosts, design per-tenant and per-environment isolation, manage per-vhost access, and understand connection URIs that include the vhost.

When a small team uses RabbitMQ, one unlimited space is enough. But once the team grows, or you run development, staging, and production at the same time, everything starts stepping on each other: queues with the same name from different environments collide, and user permissions become uncontrollable.
Virtual Hosts (vhosts) are RabbitMQ's answer to this problem. A vhost is a logical namespace that isolates resources: queues, exchanges, bindings, and user permissions in one vhost are invisible and inaccessible from other vhosts. A single RabbitMQ instance can host dozens of vhosts without interfering with each other.
This episode covers how to create and manage vhosts, design correct multi-tenancy patterns, manage per-vhost access, and best practices for naming, resource allocation, monitoring, and backup. With well-managed vhosts, one broker can safely serve an entire organization.
It's important to understand: a vhost is logical isolation, not physical. All vhosts still share the same memory, disk, and CPU within a single node. Vhosts provide namespace and permission isolation, not isolated resource guarantees — for that you need separate nodes or your own cluster.
RabbitMQ has a built-in vhost named /. The guest user only has full access to this vhost. Many beginner teams use the / vhost for everything — this is what triggers name collisions and permission problems. Start creating your own vhosts from the beginning.
Create a vhost and set up users inside it:
rabbitmqctl add_vhost staging
rabbitmqctl set_permissions -p staging arman '.*' '.*' '.*'
rabbitmqctl list_vhosts nameThe rabbitmqctl add_vhost command creates a vhost, and set_permissions -p staging gives the user arman full rights inside it. Users without permissions won't be able to connect to that vhost.
Deleting a vhost automatically deletes all resources inside it — queues, exchanges, bindings, and permissions:
rabbitmqctl delete_vhost stagingThe delete_vhost command is destructive. Make sure you've backed up the definitions (episode 31) before deleting a vhost containing important data.
Two common isolation patterns:
Per-environment: separate vhosts for dev, staging, and prod. This pattern prevents development code from sending messages to production queues. Highly recommended even for small teams.
Per-tenant: for SaaS, create one vhost per tenant. Each tenant has its own queues and exchanges with isolated permissions. Watch the cost: hundreds of vhosts add metadata overhead, so limit the number of vhosts per node and monitor performance.
The vhost is part of the connection URI, written after the first slash. Special characters like / are URL-encoded as %2f:
amqp://arman:password@localhost:5672/staging
amqp://arman:password@localhost:5672/%2fThe first URI connects to the staging vhost; the second connects to the / vhost — which must be written as %2f because the slash character belongs to the URI.
Permissions are per-vhost: the same user can have full rights in dev but only read access in prod. The details of the configure, write, and read permissions are covered in episode 16. The principle: never give one user full access to all vhosts without a reason.
Tip
Follow a consistent naming convention: vhost-<environment> like dev, staging, prod, or tenant-<name> for SaaS. Use alphanumeric characters and dashes, with no spaces.
Although vhosts don't isolate physical resources, you can limit their impact: set limits per vhost to protect the broker from greedy tenants. RabbitMQ supports rabbitmqctl set_vhost_limits:
rabbitmqctl set_vhost_limits -p tenant_a '{"max-connections":100,"max-queues":1000}'Monitor per-vhost metrics in the Management UI — every vhost has its own tab with its own queue depth and message rate. For backup, export definitions per vhost so recovery only touches the broken part:
curl -u arman:pass -H "content-type: application/json" \
http://localhost:15672/api/definitions/staging > staging.jsonThe curl command above downloads all of the staging vhost's definitions into a JSON file for backup purposes.
In episode 13 you understood vhosts as logical namespaces, created and managed vhosts with rabbitmqctl, designed per-environment and per-tenant isolation, managed per-vhost permissions and limits, and set up per-vhost definitions backup.
Key takeaways:
/ vhost for everything — create your own vhosts./ becomes %2f.set_vhost_limits limits the impact of greedy tenants.In the next episode we will discuss flow control and backpressure — how RabbitMQ protects itself from overload with TCP backpressure, credit-based flow control, memory alarms, and the connection blocked state, complete with publisher confirms and publisher throttling strategies. This is the key to preventing the broker from falling over under high traffic!