<- Back to blog archive
RabbitMQ Guides

What's the easiest way to run RabbitMQ?

What's the easiest way to run RabbitMQ?
The easiest way to run RabbitMQ is to let someone else take care of it. With a managed RabbitMQ instance on the CloudAMQP free plan, you have a broker running in seconds, with nothing to install.

You sign up, create an instance, copy its connection URL into your code, and start sending messages. CloudAMQP handles the servers, the Erlang runtime, upgrades, and monitoring.

New to RabbitMQ? It’s a message broker: your applications send messages to it, and it holds them in queues until another application is ready to handle them, or keeps them in streams that can be read again and again. RabbitMQ for beginners explains it from the start.

We know this path well. Developers have created about 72,000 free RabbitMQ instances on CloudAMQP in the last 12 months. Almost half of the free instances created in our console send and receive messages within their first month.

This post shares what we’ve learned from watching them get started and answering their questions when they got stuck.

Why we built the easy way

CloudAMQP started in 2012 because running RabbitMQ was harder than it should be. Our founder, Carl Hörberg, was a consultant trying to get RabbitMQ to work with Heroku and AppHarbor. He wanted hosted queues that just worked. They didn’t exist, so he built them.

The idea was simple: developers should write the code that makes their product special, not patch brokers and handle outages at 3 a.m. Fourteen years later, we still run RabbitMQ that way, for thousands of teams.

Which option fits you?

There are four common ways to run RabbitMQ. Here’s how they compare.

Hosted RabbitMQ in the cloud (CloudAMQP)

Setup: just seconds on the free plan.
Maintenance: none on your side.

You get a RabbitMQ instance with a hostname, TLS, and the RabbitMQ management interface. Start on the free plan, and move to a dedicated cluster with more nodes and resources when you need it.

RabbitMQ in Docker

Setup: one command, if Docker is already installed.
Maintenance: small for local development, larger in production.

Docker is a great way to try RabbitMQ on your own laptop. The RabbitMQ team keeps the command on their download page.

RabbitMQ then runs only on your computer, and your messages are lost when you remove the container. For production, you still need to handle hosting, storage, security, upgrades, and monitoring yourself.

Install RabbitMQ on your own server

Setup: under an hour for a single node, longer for a cluster.
Maintenance: you handle all of it.

RabbitMQ runs on Erlang, so you install a supported Erlang version first and then RabbitMQ, from packages for Debian, Ubuntu, RHEL, Windows or macOS. The RabbitMQ installation guides cover each platform. From then on, you run upgrades for both RabbitMQ and Erlang, security patches, backups, monitoring, and clustering.

RabbitMQ on Kubernetes

Setup: an afternoon, if you already run Kubernetes.
Maintenance: you own the cluster and the operator.

The RabbitMQ Cluster Kubernetes Operator creates and manages RabbitMQ clusters inside Kubernetes. It’s a good fit for teams that already run everything on Kubernetes. If you’re new to both RabbitMQ and Kubernetes, it can be a lot to learn at once.

Run RabbitMQ in the cloud for free, in seconds

Here is the full path from nothing to your first message, on the free plan.

1. Sign up

Create a CloudAMQP account. No credit card is needed for the free plan.

2. Create an instance

Click Create New Instance, give it a name, choose RabbitMQ and the free plan, Little Lemur, and pick the cloud region closest to your application. Your instance is ready within seconds.

3. Copy the AMQP URL

Open your instance. The overview page shows the hostname, the username, the password, and the AMQP URL. The URL is all your application needs to connect:

amqps://username:password@hostname/vhost

Treat it like a password and keep it out of your code, for example, in an environment variable.

4. Connect a client

RabbitMQ has client libraries for most languages. Install the one for your language and pass it the AMQP URL. Our docs show how, with code you can copy:

5. Publish and consume your first message

Declare a queue, publish a message to it, and start a consumer that reads it. Our beginner guide walks you through the Node.js, Python, and Ruby code.

Open the RabbitMQ management interface from the console to watch the message arrive in the queue and leave it again. Part 3 of RabbitMQ for beginners explains what you see there.

Day 30, not day 1

Getting RabbitMQ running is easy with every option on this page. The questions come later, once your app has been running for a few weeks.

These are the problems we help developers with most often, and how to avoid them from the start.

Your message quota runs out faster than expected

A message counts once when it’s published and once when it’s consumed. A message that fails and is redelivered over and over counts every time, and that adds up quickly.

Send messages that keep failing to a dead letter exchange instead of retrying forever. And use basic.consume rather than polling with basic.get: RabbitMQ then pushes messages to your consumer, which is faster and lighter. Read more in basic.consume vs basic.get.

A new connection for every message

Opening a connection, publishing one message and closing it again is slow, and on a shared server, connections start to get refused. Open one connection when your app starts, keep it open, and reuse it. Our RabbitMQ best practice guide explains why.

The app stops after a restart

Servers restart for upgrades and maintenance, and every connection is closed when they do. If your client doesn’t reconnect, your app quietly stops sending and receiving. Turn on automatic reconnect in your client, or add a few lines that reconnect with a short delay.

Heartbeats are turned off

Heartbeats let your client and RabbitMQ notice a connection that has died. On CloudAMQP, TCP keepalives close dead connections on the server side even without heartbeats, but your client might not notice, and a consumer can sit waiting on a connection that’s gone.

Keep heartbeats on. The default of 60 seconds suits most apps. Our post on missed heartbeats in RabbitMQ explains how heartbeats and TCP keepalives work.

The free instance is deleted

A free instance that hasn’t sent or received a message in 2 months is deleted. We email you before that happens, but it’s easy to miss. Once an instance is gone, you create a new one, so keep anything you care about on an instance you use.

Production runs on the free plan

You can, but Little Lemur is a shared server without an SLA. When other people depend on your app, move it to a dedicated plan with its own servers and a 99.95% uptime guarantee.

What the free plan includes

Little Lemur is a shared RabbitMQ instance made for development and testing. It includes:

  • 1 million messages per month
  • 20 connections
  • 100 queues
  • 10,000 messages waiting in queues at a time

That’s plenty to learn RabbitMQ, build a prototype or test an idea for your business.

When your application goes to production, pick a dedicated plan. You get your own servers, a cluster of up to three nodes, and support from the team that has run RabbitMQ in production for over a decade.

Learn RabbitMQ while you build

Running RabbitMQ is the easy part. Using it well is where it pays to learn a little more. We’ve made three free resources for that:

  • RabbitMQ for beginners explains what RabbitMQ is, how messages move through exchanges and queues, and how to write your first producer and consumer.
  • The CloudAMQP RabbitMQ training is a free course, from beginner to advanced, that you can take at your own pace and finish with a certificate.
  • The Optimal RabbitMQ Guide is our free ebook, from what RabbitMQ is to best practices for high performance and high availability.

FAQ

What is the easiest way to run RabbitMQ?

A managed RabbitMQ service. On CloudAMQP, you sign up, create a free instance, and connect using the AMQP URL, no installation required.

Is RabbitMQ free?

Yes. RabbitMQ itself is open source and free to run on your own servers. If you don’t want to run servers, the CloudAMQP free plan gives you a hosted RabbitMQ instance at no cost.

What is the easiest way to test RabbitMQ for my business?

Start on the free plan and connect the application you want to test. You don’t need to set up servers, and you can move to a dedicated plan when you go live.

Should I use Docker or a managed RabbitMQ?

Docker is great for running RabbitMQ on your own machine during development. For anything other people depend on, a managed instance saves you the hosting, upgrades, and monitoring.