RabbitMQ interview questions: routing, reliability and operations
RabbitMQ interview questions start with the routing model: producers publish to an exchange, bindings decide which queues get a copy, and consumers acknowledge each message when the work is done. From there interviewers probe reliability, meaning durable queues, persistent messages, publisher confirms, manual acks and prefetch, and what happens to a message that keeps failing. Senior rounds add quorum queues, clustering, ordering and when Kafka would fit better.
By Evin JohnPublished 8 min read
Where RabbitMQ questions come from
RabbitMQ shows up in backend, platform, DevOps and integration interviews, often in companies that run background jobs, email and notification pipelines, payment workflows or microservices that talk through events. The questions come in three shapes. Concept questions check the vocabulary. Reliability questions ask how you would make sure an order event is neither lost nor processed twice. Operations questions describe a queue with a million messages and growing and ask what you do first. Kafka comparisons appear in almost every loop, so have a short, honest answer ready; the Kafka interview questions page covers the other side.
The model: exchanges, bindings and queues
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Walk through what happens when a producer publishes a message. | Core model | The producer sends to an exchange with a routing key. The exchange compares the key with its bindings and puts a copy in each matching queue. Consumers subscribed to a queue receive messages and acknowledge them, and only then are they removed. |
| What are the exchange types? | Routing | Direct routes on an exact key match, fanout copies to every bound queue, topic matches dotted keys against patterns, and headers matches on message header values instead of the key. |
In a topic binding, what do * and # mean? | Patterns | * matches exactly one dot-separated word and # matches zero or more. order.*.eu matches order.created.eu but not order.eu; order.# matches both. |
| What is the default exchange? | Shortcut | A nameless direct exchange that every queue is bound to by its own name, so publishing with routing key "invoices" to it lands in the invoices queue. |
| Connection versus channel? | Client design | A connection is a TCP (often TLS) link to the broker; channels are lightweight sessions multiplexed over it. Apps open one or a few long-lived connections and use a channel per thread, never a new connection per message. |
| What is a virtual host? | Isolation | A namespace with its own exchanges, queues, bindings and permissions on the same broker, used to separate apps or environments. |
| What happens to a message no queue is bound for? | Unroutable messages | It is dropped silently unless the publisher sets the mandatory flag, in which case the broker returns it, or the exchange has an alternate exchange that catches it. |
| Which protocols does RabbitMQ speak? | Ecosystem | AMQP 0-9-1 is the classic one that most client libraries use. It also supports AMQP 1.0, MQTT and STOMP, plus a separate binary protocol for streams. |
Reliability: confirms, acks, prefetch and redelivery
- How do you make sure a message is not lost? Declare the queue durable, publish messages as persistent (delivery mode 2), turn on publisher confirms so the producer knows the broker has stored the message, and have consumers ack manually after finishing the work. Missing any one of the four leaves a gap.
- What is a publisher confirm? After
confirm.selecton a channel, the broker acks each published message once it is safely handled (for a quorum queue, once a majority of replicas have it) or nacks it. Producers usually wait in batches or track confirms asynchronously instead of waiting per message. - Auto-ack versus manual ack? With auto-ack the message counts as delivered the moment it is sent, so a consumer crash loses it. With manual ack the broker keeps it until ack, nack or reject, and requeues it if the channel closes first.
- What does prefetch do? basic.qos with a prefetch count limits how many unacknowledged messages a consumer holds at once. Too high and one consumer hoards work while others sit idle and memory grows; too low and throughput drops on network round trips. Tune it from processing time and latency, and set it per consumer, since global prefetch is deprecated in recent versions.
- Why do duplicates happen, and what do you do about them? A consumer can finish the work and crash before its ack arrives, so the message is redelivered with the redelivered flag set. Delivery is at least once, so make the handler idempotent: a unique key in the database, an upsert, or a processed-message table keyed by message ID.
- nack versus reject? Both refuse a message, optionally requeueing it. nack is a RabbitMQ extension that can refuse many deliveries at once with the multiple flag; reject handles one. Requeueing a message that always fails creates a hot loop, which is what dead-lettering is for.
import json
import pika
# charge_once() and TemporaryError come from the billing code (not shown).
params = pika.URLParameters("amqp://billing:CHANGE_ME@rabbit.internal:5672/shop")
connection = pika.BlockingConnection(params)
channel = connection.channel()
# Topology. Declaring it is idempotent: same arguments, no error.
channel.exchange_declare("orders", exchange_type="topic", durable=True)
channel.exchange_declare("orders.dlx", exchange_type="fanout", durable=True)
channel.queue_declare("orders.dead", durable=True, arguments={"x-queue-type": "quorum"})
channel.queue_bind("orders.dead", "orders.dlx")
channel.queue_declare(
"billing.order-created",
durable=True,
arguments={
"x-queue-type": "quorum",
"x-dead-letter-exchange": "orders.dlx",
"x-delivery-limit": 5, # after 5 failed deliveries, dead-letter it
},
)
channel.queue_bind("billing.order-created", "orders", routing_key="order.created.*")
channel.basic_qos(prefetch_count=20) # at most 20 unacknowledged messages here
def handle(ch, method, properties, body):
order = json.loads(body)
try:
charge_once(order["id"], order["total"]) # idempotent, keyed by order id
except TemporaryError:
ch.basic_nack(method.delivery_tag, requeue=True) # retry later
return
except Exception:
ch.basic_reject(method.delivery_tag, requeue=False) # straight to the DLX
return
ch.basic_ack(method.delivery_tag) # only after the work is done
channel.basic_consume("billing.order-created", handle) # manual acks (auto_ack=False)
channel.start_consuming()Queue types, dead-lettering and retries
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Classic queue versus quorum queue? | Queue types | A classic queue lives on one node and is not replicated from RabbitMQ 4.0 onward. A quorum queue replicates across nodes with the Raft consensus algorithm, survives a node loss and adds a delivery limit for poison messages. Use quorum queues for data you cannot lose; classic queues still fit temporary or exclusive queues. |
| What happened to mirrored queues? | Version awareness | Classic queue mirroring was deprecated for years and removed in RabbitMQ 4.0. Clusters upgrading must move mirrored queues to quorum queues or streams and drop the ha-mode policies first. |
| What is a RabbitMQ stream? | Log semantics | An append-only, replicated log. Consuming does not remove messages, so many consumers can read the same data and replay from an offset or timestamp, which brings Kafka-style use cases into RabbitMQ. |
| What is a dead-letter exchange? | Failure handling | An exchange where a queue sends messages that were rejected without requeue, expired by TTL, exceeded a length limit or passed a quorum queue's delivery limit. A queue bound to it collects them for inspection or replay. |
| How do you build retry with a delay? | Retry patterns | Common answers: a retry queue with a message TTL whose dead-letter exchange points back to the work queue, several such queues for growing delays, or the delayed message exchange plugin. Cap the attempts and park the rest. |
| What does a message TTL do? | Expiry | Sets how long a message may wait in a queue, per queue or per message. Expired messages are dropped or dead-lettered. Expired messages are typically discarded only when they reach the head of the queue, so a long-lived message in front can hold back shorter ones behind it, a known surprise with per-message TTLs. |
| How do queue length limits behave? | Back-pressure | x-max-length or x-max-length-bytes caps a queue. The default overflow drops the oldest message from the head; reject-publish refuses new ones instead, which with confirms tells producers to slow down. |
| Can you guarantee message order? | Ordering | A single queue is FIFO, but several consumers, prefetch and requeues reorder processing. For strict order, use one active consumer per queue (the single active consumer setting) or partition work by key across queues. |
| How do you do request and reply over RabbitMQ? | RPC pattern | The client sends with reply_to set to a callback queue (or the direct reply-to pseudo-queue) and a correlation_id, then matches the response by that ID. Mention timeouts, since a missing reply blocks the caller. |
import json
import pika
def publish_order_created(channel, order):
"""Publish with confirms: returns only after the broker has taken the message."""
try:
channel.basic_publish(
exchange="orders",
routing_key=f"order.created.{order['region']}",
body=json.dumps(order).encode(),
properties=pika.BasicProperties(
content_type="application/json",
delivery_mode=2, # persistent
message_id=str(order["id"]), # lets consumers drop duplicates
),
mandatory=True, # tell us if no queue is bound
)
except pika.exceptions.UnroutableError:
raise RuntimeError("no queue bound for this routing key")
except pika.exceptions.NackError:
raise RuntimeError("broker refused the message; retry or alert")
connection = pika.BlockingConnection(pika.URLParameters("amqp://shop:CHANGE_ME@rabbit.internal:5672/shop"))
channel = connection.channel()
channel.confirm_delivery() # turn on publisher confirms once per channel
publish_order_created(channel, {"id": 1042, "region": "eu", "total": 59.9})Clustering, operations and monitoring
- What does a RabbitMQ cluster share? Metadata such as users, vhosts, exchanges, bindings and queue definitions is replicated to every node. Queue contents live only where that queue type puts them: one node for classic queues, a set of replicas for quorum queues and streams.
- How many nodes for quorum queues? An odd number, usually three or five. A queue stays available while a majority of its replicas are up, so three nodes survive one failure and five survive two.
- What happens during a network partition? Nodes may disagree about the state of the cluster. Classic setups chose a partition handling strategy such as pause_minority; quorum queues follow Raft and only the side with a majority keeps accepting writes for each queue.
- What are memory and disk alarms? When a node passes its memory high watermark or drops below its free disk limit, it blocks publishing connections across the cluster until the alarm clears. Producers see blocked connections, not errors, so client code should handle that notification.
- Which metrics do you watch? Queue depth and its trend, messages ready versus unacknowledged, publish and deliver rates, consumer count and utilization, redelivery rate, connection and channel churn, file descriptors, and memory and disk alarms. The management plugin shows them; the Prometheus plugin exports them.
- Federation versus Shovel? Both move messages between brokers, often across data centers. Federation links exchanges or queues so they behave like one loosely coupled system; Shovel is a simpler pump that consumes from one place and republishes to another.
- RabbitMQ versus Kafka? RabbitMQ is a broker that routes and pushes messages to consumers and deletes them after ack, with per-message acknowledgment, priorities and flexible routing. Kafka keeps a partitioned log that consumers pull from by offset, retained for replay and very high throughput. RabbitMQ streams narrow the gap for replay use cases.
Scenario questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| A queue has grown to two million messages and keeps climbing. | Triage | Compare publish and ack rates, check whether consumers are connected, stuck or erroring, and look at unacked counts. Scale consumers if work is just slow; fix the failing dependency if they are erroring. Add a length limit and an alert on queue age, not just size. |
| Thousands of messages sit in unacked and nothing moves. | Stuck consumers | A consumer took a large prefetch and hangs, perhaps on a database call without a timeout. Its messages return to ready only when its channel closes. Lower prefetch, add timeouts, and use consumer timeouts so stuck deliveries are reclaimed. |
| Customers were charged twice after a deploy. | Idempotency | Consumers restarted mid-work and messages were redelivered. Make charging idempotent with a unique payment key and record processed message IDs; acking earlier would trade duplicates for lost payments. |
| Messages vanished after a broker restart. | Durability | Likely a non-durable queue, transient messages or auto-ack consumers. Audit declarations, set persistent delivery and confirms, and move important queues to quorum type. |
| The broker's connection count spikes and CPU follows. | Client misuse | An app opens a connection per request. Reuse long-lived connections and channels, pool them in web workers, and watch connection churn as a metric. |
| Design order processing where billing, email and analytics each need every order event. | Design | A topic exchange for order events, one durable queue per service bound with its own pattern, each service acking independently, dead-letter queues per service, and a stream if analytics needs replay. |
Fictional example
- Interviewer
- Our checkout service publishes an order-created event to RabbitMQ and billing consumes it. How do you make sure an event is never lost and never charged twice?
- Candidate
- Lost and duplicated are two separate problems, so I would answer them separately. For loss, there are four places it can happen. The broker restarting: so a durable quorum queue and persistent messages. The publish itself: so publisher confirms, and the checkout service only marks the order as published after the confirm, ideally through an outbox table so a crash between the database write and the publish does not drop the event. Routing: the mandatory flag or an alternate exchange so an unbound key is noticed. And the consumer: manual acks, sent only after billing has committed the charge. That design gives at-least-once delivery, which means duplicates will happen, for example when billing crashes after charging but before acking. So billing must be idempotent: it charges with the order ID as an idempotency key, and a repeat delivery finds the existing payment and just acks. For messages that keep failing, a delivery limit sends them to a dead-letter queue with an alert, so one bad order does not block the rest.
How to prepare for RabbitMQ interview questions
- Run a broker and watch itStart RabbitMQ in a container with the management plugin, publish to each exchange type and watch where copies land in the UI.
- Lose a message on purposeUse auto-ack, kill a consumer mid-message, restart the broker with a transient queue. Then fix each case and explain which setting saved it.
- Build a retry pathA work queue, a delayed retry queue and a dead-letter queue, with a cap on attempts. Be able to draw it in under two minutes.
- Tune prefetchRun consumers with prefetch 1, 10 and 200 against slow and fast handlers and note throughput and fairness. Interviewers like numbers you measured yourself.
- Prepare the Kafka comparisonTwo or three sentences on routing versus a log, deletion versus retention and push versus pull, plus where streams fit.
For the edge in front of these services, read Nginx interview questions. For the systems view, the notification system design guide uses a queue exactly like this, and Hadoop interview questions covers the batch side where queued events often end up.
Reliability questions reward a structured answer more than a list of settings. Natively, an AI interview assistant on Mac and Windows, can transcribe your mock answer to a design question like the one above, read a queue dashboard or a consumer stack trace from a screenshot, and show a suggested answer while you speak. With Pro or the free trial it also works from your résumé and the job description, and each practice run keeps a transcript and notes to compare against the next one.
Questions people ask
What are common RabbitMQ interview questions?
The exchange types and how bindings route messages, how to avoid losing a message, auto-ack versus manual ack, what prefetch does, classic versus quorum queues, how dead-letter exchanges and retries work, and RabbitMQ versus Kafka.
How do you avoid losing messages in RabbitMQ?
Use a durable queue (a quorum queue for high availability), publish persistent messages with publisher confirms, and have consumers ack manually only after the work is done.
Does RabbitMQ deliver messages exactly once?
No. With manual acks delivery is at least once, so a message can arrive twice after a consumer crash. Make consumers idempotent, for example by recording processed message IDs.
Are mirrored queues still used in RabbitMQ?
No. Classic queue mirroring was removed in RabbitMQ 4.0. Quorum queues and streams are the replicated options now.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
