An e-commerce platform’s order processing system mysteriously slows down during peak hours — not because the server is underpowered, but because services are calling each other directly. The payment service waits on the inventory service, which waits on the email service… One bottleneck and the entire chain stalls. RabbitMQ solves exactly that problem: instead of calling directly, you push messages into a queue, and whoever can process them picks them up.
I’ve deployed RabbitMQ on Ubuntu across many different projects — from small services handling a few thousand messages per day to payment pipelines sustaining 80k+ messages per hour at peak. The workflow below is what I actually use; every step earns its place.
Get RabbitMQ Running in 5 Minutes
Just need a quick test environment on Ubuntu 24.04? Here’s the shortest path:
# Install Erlang and RabbitMQ from the official repo
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
sudo apt-get install -y rabbitmq-server
# Start and enable autostart
sudo systemctl enable --now rabbitmq-server
# Enable Web Management UI
sudo rabbitmq-plugins enable rabbitmq_management
# Create admin user (change password before using in production)
sudo rabbitmqctl add_user admin StrongPass123!
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
Open your browser to http://<server-IP>:15672 and log in with the admin user you just created. The dashboard is ready. The next sections explain each step and the reasoning behind it.
Installing the Right Way — Skip Ubuntu’s Default Repo
Ubuntu 24.04 ships rabbitmq-server in apt, but it’s typically several versions behind upstream — enough to miss important improvements to quorum queues and streams. Use the official RabbitMQ team repository so Erlang/OTP versions align correctly.
Step 1: Add GPG Keys and Repository
# Install required tools
sudo apt-get update
sudo apt-get install -y curl gnupg apt-transport-https
# Add RabbitMQ signing key
curl -1sLf 'https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA' | sudo gpg --dearmor -o /usr/share/keyrings/com.rabbitmq.team.gpg
# Add Cloudsmith signing key (mirror)
curl -1sLf 'https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key' | sudo gpg --dearmor -o /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg
curl -1sLf 'https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key' | sudo gpg --dearmor -o /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg
# Add Erlang and RabbitMQ repositories
sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
deb [arch=amd64 signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu noble main
deb [arch=amd64 signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu noble main
EOF
sudo apt-get update
Step 2: Install Erlang First, Then RabbitMQ
# Install Erlang first (compatible version for RabbitMQ 3.13+)
sudo apt-get install -y erlang-base \
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
erlang-runtime-tools erlang-snmp erlang-ssl erlang-syntax-tools \
erlang-tftp erlang-tools erlang-xmerl
# Then install RabbitMQ
sudo apt-get install -y rabbitmq-server
The reason for splitting into two commands: if you let apt resolve everything automatically, it sometimes pulls Erlang from Ubuntu’s repo instead of the one you just added. Installing Erlang explicitly first avoids version conflicts that prevent RabbitMQ from starting — I lost two hours debugging this the first time around.
Step 3: Verify the Service
sudo systemctl status rabbitmq-server
# Expected output: Active: active (running)
# View detailed node information
sudo rabbitmqctl status | head -30
Security Configuration — Do This First
After installation, RabbitMQ comes with a guest user (password: guest), but it can only log in from localhost by default. Before opening any ports externally, delete this user and create dedicated accounts.
# Delete the default guest user
sudo rabbitmqctl delete_user guest
# Create a dedicated vhost for the application (replace 'myapp' with your project name)
sudo rabbitmqctl add_vhost myapp
# Create an application user with restricted permissions
sudo rabbitmqctl add_user appuser SecretPass456!
sudo rabbitmqctl set_permissions -p myapp appuser ".*" ".*" ".*"
# Create a separate admin user for Web UI management
sudo rabbitmqctl add_user admin AdminPass789!
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
sudo rabbitmqctl set_permissions -p myapp admin ".*" ".*" ".*"
Firewall Configuration
# Port 5672: AMQP (application connections)
# Port 15672: Web Management UI
# Only open for trusted IPs — do not expose publicly unless necessary
sudo ufw allow from 192.168.1.0/24 to any port 5672
sudo ufw allow from YOUR_ADMIN_IP to any port 15672
sudo ufw reload
Managing via Web UI — More Powerful Than You Think
Opening http://server:15672 gives you an instant full-featured dashboard — create queues, manage user permissions, monitor message rates in real time, and even publish test messages directly from the browser. For most day-to-day tasks, you won’t need the terminal:
- Overview: Overall message rate, active connections, and channels
- Queues: View pending message counts per queue, manually publish or consume messages for testing
- Exchanges: Manage exchanges and routing rules
- Admin: Add or remove users, vhosts, and permissions
The Queues tab is your first stop when debugging — if Ready keeps climbing while Unacked stays frozen, your consumers are dead or blocked.
Integrating with Python Applications
A basic producer and consumer with pika — the skeleton I use when starting a new project:
pip install pika
import pika
# Connect to RabbitMQ
credentials = pika.PlainCredentials('appuser', 'SecretPass456!')
params = pika.ConnectionParameters(
host='localhost',
virtual_host='myapp',
credentials=credentials
)
connection = pika.BlockingConnection(params)
channel = connection.channel()
# Declare queue (auto-creates if it doesn't exist)
channel.queue_declare(queue='orders', durable=True)
# Send message
channel.basic_publish(
exchange='',
routing_key='orders',
body='Order #12345 - T-shirt size L x2',
properties=pika.BasicProperties(delivery_mode=2) # persistent
)
print('Order sent to queue')
connection.close()
import pika
# Consumer — receive and process messages
credentials = pika.PlainCredentials('appuser', 'SecretPass456!')
params = pika.ConnectionParameters(host='localhost', virtual_host='myapp', credentials=credentials)
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='orders', durable=True)
channel.basic_qos(prefetch_count=1) # Only receive 1 message at a time
def process_order(ch, method, properties, body):
print(f'Processing: {body.decode()}')
# ... order processing logic ...
ch.basic_ack(delivery_tag=method.delivery_tag) # Acknowledge processing complete
channel.basic_consume(queue='orders', on_message_callback=process_order)
print('Waiting for orders...')
channel.start_consuming()
Note that delivery_mode=2 on publish and durable=True on queue declaration are a required pair if you don’t want to lose messages on RabbitMQ restart. Missing either one means your messages vanish.
Practical Tips from Production Experience
Regular Monitoring
# View all queues and message counts
sudo rabbitmqctl list_queues name messages consumers
# View open connections
sudo rabbitmqctl list_connections user vhost state
# Check memory usage (warn if it exceeds 40% of RAM)
sudo rabbitmqctl status | grep -A5 memory
Resource Limit Configuration
Create the file /etc/rabbitmq/rabbitmq.conf:
# Memory limit (default 40% of RAM — reduce for smaller servers)
vm_memory_high_watermark.relative = 0.3
# Disk limit (minimum 1GB free; RabbitMQ will throttle if below this)
disk_free_limit.absolute = 1GB
# Increase maximum file descriptors
handle_limit = 65536
sudo systemctl restart rabbitmq-server
Handling the Dead Letter Queue
When a consumer keeps failing and nacks with requeue=True, the message bounces right back to the front of the queue — received again, failed again. This loop burns through consumer CPU in seconds. DLX stops that: failed messages get routed to a separate queue instead of looping forever:
# Declare the DLX and the dead letter queue
channel.exchange_declare(exchange='dlx', exchange_type='direct')
channel.queue_declare(queue='orders.failed', durable=True)
channel.queue_bind(queue='orders.failed', exchange='dlx', routing_key='orders')
# Attach DLX to the main queue
channel.queue_declare(
queue='orders',
durable=True,
arguments={
'x-dead-letter-exchange': 'dlx',
'x-dead-letter-routing-key': 'orders'
}
)
Any message basic_nack‘d with requeue=False automatically moves to orders.failed instead of disappearing. From there you can inspect it, debug, and reprocess manually via the Web UI.
Configuration Backup
# Export full configuration: vhosts, users, queues, exchanges, and bindings
sudo rabbitmqctl export_definitions /backup/rabbitmq-definitions.json
# Restore when needed
sudo rabbitmqctl import_definitions /backup/rabbitmq-definitions.json
I run that export command every night via cron. Once had to rebuild a server after a disk failure — that JSON file saved an entire afternoon of reconfiguration. Two seconds to back up; you can imagine the alternative.
