
Kafka vs RabbitMQ comes down to one design choice: RabbitMQ is a message broker that routes messages and forgets them, and Kafka is an event log that remembers every event. If you pick the wrong one, your architecture can fight you for years.
This guide explains why these tools exist, how each one works on the inside, where each fits in a real system, and the two mistakes teams keep making. Four ideas carry the whole story: message broker, event log, replay and routing.
- Both tools decouple services so a crash in one doesn't take down the others.
- RabbitMQ routes messages to queues and deletes each one once it's acknowledged.
- Kafka appends events to a partitioned log, keeps them, and lets each consumer track its own offset.
- Only Kafka can replay history, so a new service can learn from past events.
- Rule of thumb: tasks that should vanish after one run go to RabbitMQ. Events that should be kept and replayed go to Kafka.
- 0:00Intro
- 0:22Services that wait together crash together
- 1:02A broker versus a log
- 1:44RabbitMQ: route, deliver, ack, gone
- 2:27Kafka: append, retain, read your offset
- 3:08Kafka can replay history
- 3:47Five differences, side by side
- 4:26One shop, both tools
- 5:09Two mistakes teams keep making
- 5:55Everything in five lines
- 6:18Routing tasks? RabbitMQ. Replaying events? Kafka.
Why do services need a message queue at all?
Services that call each other directly wait together, and they crash together. Every direct call ties two services into one fragile line. Say checkout calls the email service and the email service hangs. Now checkout hangs too, and a customer can't place an order because an email couldn't be sent.
The fix is easy to say: put a queue in between. That gives you two things. The first is decoupling in time. The sender drops a message and moves on. The receiver handles it when it's ready, even minutes later after a restart. The second is failure isolation. If the email worker crashes, its messages wait. Checkout keeps taking orders, and nothing is lost when the worker comes back.
- Direct calls pass failures straight back to the customer
- A queue lets the sender move on right away
- A crashed worker means waiting messages, not lost orders
Message broker vs event log: what's the difference?
Kafka and RabbitMQ solve the same problem with opposite models. Think of a post office versus a ledger. RabbitMQ is the post office. It routes each message into a queue, and once the message is acknowledged, it's gone. The broker keeps track of what has been delivered.
Kafka is the ledger: a distributed, append-only, partitioned event log. Reading an event doesn't remove it. Each consumer tracks its own position. In one line: one delivers messages, the other remembers events. Nearly every difference later in this article follows from that.
Both tools stop your services from waiting on each other. So the useful question isn't which one decouples better. It's what should happen to a message after it has been read.
How does RabbitMQ route and deliver messages?
RabbitMQ does its work in the middle. Messages are routed, delivered, acknowledged, and then they're gone. Producers never write to a queue directly. They publish to an exchange. When the Order service publishes an order, the exchange's routing rules put one copy in the email queue and another in the invoice queue. The Email worker and the Invoice worker each pull from their own queue.
The routing comes from bindings, which match on routing keys or patterns. So one message can fan out to many queues or go to exactly one, and the broker decides which. When a worker finishes a message, it sends an ack and the broker deletes the message. If no ack arrives, the message is redelivered to another worker.
- Producers publish to exchanges, not queues
- Bindings match routing keys or patterns
- Ack means deleted; no ack means redelivered
How does Kafka store events and track offsets?
Kafka works the other way. Nothing is routed, and nothing is deleted when it's read. Events pile up in order, in a log that you only add to and never edit. The Order service appends events to an orders topic, which is split into partitions such as Partition 0, 1 and 2.
Analytics and a search indexer can both read those same events, each at its own pace. Events stay for as long as your retention setting says, so two consumers reading the same event never compete for it. An offset is simply a position within a partition. Each consumer group saves its own offset, so a slow reader never holds back a fast one.
- Retained, not deleted: reading never removes an event
- Own offsets: each consumer group saves its own position
Can Kafka replay old events?
Yes, and this is the feature that sets Kafka apart. Because Kafka keeps events, a brand-new service can read the past. Take a new fraud service launched today. It subscribes to the orders topic, resets its offset to 0, reads every past order, and then catches up to the latest events. It learns from yesterday's orders and then watches new ones as they arrive.
Classic queues can't do this. In RabbitMQ, an acknowledged message is deleted, so a service that shows up later never sees it. Replay also helps you recover from bugs. If you shipped code that wrote bad data, you can fix the code, rewind the offset, and reprocess the events to rebuild the correct state.
- Subscribe to the orders topic
- Reset the offset to 0
- Read every past order
- Catch up to the latest events
Kafka vs RabbitMQ: five differences side by side
Line the two tools up and they disagree on every point. Read each row as a design decision, not a score. RabbitMQ is a smart broker that routes. Kafka is an append-only partitioned log. After a read, RabbitMQ deletes the acknowledged message, while Kafka keeps it for replay.
For tracking, RabbitMQ's broker tracks delivery, while Kafka's consumers track their own offsets. RabbitMQ routes through exchanges, and Kafka organizes data by topic and partition. RabbitMQ fits task queues best, and Kafka fits streaming. There's no overall winner. Each tool is excellent at the job its model was built for and awkward at the other's.
- Model: routing broker vs append-only partitioned log
- After read: deleted once acked vs retained for replay
- Tracking: broker tracks delivery vs consumers track offsets
- Routing: exchanges vs topic and partition
- Best for: task queues vs streaming
Can you use Kafka and RabbitMQ together?
Yes. Many real systems run both, each doing what it does best. Follow one order through an online store. Checkout publishes an order event to Kafka, which streams it to Analytics and to the Fraud model. Checkout also sends tasks to RabbitMQ, which routes them to the Email worker and to invoice PDF generation.
A simple way to split the work: facts go to Kafka, chores go to RabbitMQ. An order placed is a fact that many teams need, now and later, so it suits a retained, replayable stream and event sourcing. "Send this email" and "build this PDF" are chores. Each one runs once, gets acked, and disappears, which is exactly what a task queue with smart routing is for.
Common mistakes when choosing Kafka or RabbitMQ
Both common mistakes come from treating one tool as if it were the other. Each looks fine on day one and causes problems later. The first is using Kafka as a job queue. Per-job retries, priorities and acks don't map cleanly to offsets, and one slow job can stall everything behind it in its partition.
The second is planning to replay from RabbitMQ. Classic queues delete acknowledged messages, so there's no history to rewind. If you need the past, store it yourself or use Kafka. Before you choose, ask one question: after a message is read, should it disappear, or should it stay?
- Kafka isn't a task list
- In RabbitMQ, acked means gone
- Match the tool to what should happen after a read
The bottom line
- Both tools stop services from waiting on each other.
- RabbitMQ routes, acks, then deletes.
- Kafka appends and retains, and consumers track their own offsets.
- Only Kafka can replay history.
- Don't use Kafka as a job queue, and don't plan to replay from RabbitMQ.
- Read once and gone? RabbitMQ. Read, keep, replay? Kafka.
Quick-fire questions
Is Kafka better than RabbitMQ?
Neither is better overall. RabbitMQ is excellent for routing tasks that should run once and disappear. Kafka is excellent for streams of events that should be kept and replayed.
Does RabbitMQ delete messages after they're consumed?
Yes. When a worker acknowledges a message, the broker deletes it. If no ack arrives, the message is redelivered to another worker.
What is an offset in Kafka?
An offset is a position within a partition. Each consumer group saves its own offset, so different readers move at their own pace. Resetting an offset lets a consumer reread past events.
Can I use Kafka as a job queue?
It's a common mistake. Per-job retries, priorities and acks don't map cleanly to offsets, and one slow job can stall everything behind it in its partition.
Should I run both Kafka and RabbitMQ?
Many systems do. A common split is to stream facts like order events through Kafka and send chores like emails and PDF generation through RabbitMQ.