Kafka vs RabbitMQ
Differences and When to Use Each
RabbitMQ is a message broker that routes messages into queues and deletes each one once a consumer acknowledges it. Kafka is a distributed log that keeps events and lets every consumer group read at its own position. Which fits depends on whether the work is dispatching tasks or sharing a replayable stream of events.
What is the difference between Kafka and RabbitMQ?
RabbitMQ is a message broker built around queues: producers publish to an exchange, bindings route each message into queues, and the broker pushes it to a consumer and deletes it once that consumer acknowledges it. Kafka is a distributed, partitioned log: producers append events to a topic, the events stay for a retention period whatever consumers do, and each consumer group pulls from the log at its own position.
Replay, fan-out to independent consumers, ordering, scaling and retries all work differently, because a queue is consumed and a log is read. Neither tool is better in general.
Kafka vs RabbitMQ at a glance
- Delivery to consumers
- After an ack
- Replay
- Routing
- Order guaranteed
- Scale a consumer group
- Retries and dead letters
- Protocol
- Delivery to consumersBroker pushes
- After an ackMessage deleted
- ReplayStreams only
- RoutingExchanges, bindings
- Order guaranteedPer queue, 1 consumer
- Scale a consumer groupAdd competing consumers
- Retries and dead lettersBuilt in
- ProtocolAMQP 0-9-1 and 1.0
- Delivery to consumersConsumers pull
- After an ackEvent kept
- ReplayBy offset
- RoutingTopics, keys
- Order guaranteedPer partition
- Scale a consumer groupCapped by partitions
- Retries and dead lettersTopics you build
- ProtocolKafka protocol over TCP
Queue vs log: what happens to a message after it is read
In a RabbitMQ queue, a message goes to 1 of the consumers attached to the queue, and once that consumer acknowledges it the message is gone. Without single active consumer the broker dispatches to consumers in round-robin order, so a queue behaves like a shared to-do list: each item is done once, by whoever took it.
A Kafka topic does not delete on read. The Kafka design documentation describes retaining messages for a relatively long period and letting consumers rewind to an older offset and read again. Each consumer group stores its own offset, so groups never affect each other.


Take a partition holding 10 events. A billing group has read all 10 and a search group has read 6, so search is 4 events behind. Both are healthy: the lag is how far that group has to catch up, and a slow group never takes data from a fast one. A group added next week can start at offset 0 and read all 10.
Know Kafka vs RabbitMQ the way the interviewer who asks it knows it.
Routing: exchanges and bindings vs topics and partitions
RabbitMQ's strength is routing at publish time. A producer sends to an exchange, and the exchange type decides where the message goes: a direct exchange matches the routing key exactly, a topic exchange matches it against binding patterns, a fanout exchange copies the message to every bound queue and a headers exchange routes on header values. Adding a consumer with its own filter means declaring a queue and a binding, and no producer changes.
Kafka routing is simpler and sits mostly in the consumer. A producer picks a topic, and a key decides the partition, so events with the same key land in the same partition. Consumers subscribe to topics and filter what they read in their own code or in a stream processor. There is no broker-side pattern matching on message content.
Where the messaging layer owns many varied routing rules, such as sending an order event to different workers by region or priority, an exchange model fits. Where every consumer wants the whole stream of a topic and applies its own logic, a Kafka topic with a consumer group fits.
Ordering and scaling consumers
Kafka's ordering and its parallelism are the same mechanism. Within a consumer group each partition is read by exactly 1 consumer at a time, so order inside a partition is preserved and the number of partitions caps the useful number of consumers in a group. Order isn't guaranteed across partitions, so the key you choose decides which events must stay in sequence. Choosing a key such as a customer id keeps that customer's events ordered and spreads load across customers.
RabbitMQ scales a queue by adding competing consumers, and the prefetch setting limits how many unacknowledged messages each holds. A queue delivers in order, but with several consumers, or after a message is requeued, processing order is no longer the publish order. When strict order matters, single active consumer keeps 1 consumer receiving at a time and fails over to another if it disconnects. To scale beyond one queue, you split the work into several queues, which is the job of the exchange.
The rule of thumb: if you need per-key order at high volume, a partitioned log gives it by design. If you need to add workers freely to drain a backlog of independent jobs and order barely matters, competing consumers on a queue are the more direct fit.
Delivery guarantees, retries and dead letters
Kafka guarantees at-least-once delivery by default, and the design documentation says a transactional producer together with a consumer using read_committed isolation can provide exactly-once processing between Kafka topics. Exactly-once into an outside system still needs that system's cooperation, so write sinks to be idempotent.
RabbitMQ with manual acknowledgements and publisher confirms is also at-least-once, and a message can be redelivered with its redelivered flag set. Its retry tools sit in the broker. A dead letter exchange receives messages that were rejected, expired, pushed out by a length limit or returned past a quorum queue's delivery limit. Since 4.0 that limit defaults to 20, so a poison message stops cycling forever.
A plain Kafka consumer has no per-message acknowledgement or dead letter queue: it commits an offset, so a message it cannot process either blocks the partition or is copied by your code to a retry or dead letter topic. Share groups change that. They track each record's acknowledgement and delivery attempt count, and Kafka states they're intended where records are processed one at a time instead of as an ordered stream. Per-message retry logic is where a queue broker saves the most code, and where share groups narrow the gap.
Replay, streams and share groups: where the two overlap
The gap is narrower than it was. RabbitMQ streams are a persistent, replicated append-only log that consumers can read repeatedly until it expires, with retention by age or size. A consumer can attach at the first or last message, or at an offset or timestamp. Super streams partition a stream to scale out. The documentation notes that streams don't explicitly fsync, so quorum queues offer stronger data safety.
Kafka moved the other way. In Kafka 4.2, share groups from the Queues for Kafka proposal are production-ready, so consumers can share a partition without each partition being tied to one consumer. Kafka 4.0 dropped ZooKeeper, and RabbitMQ 4.0 added native AMQP 1.0 and removed classic queue mirroring.
Durability differs in how it's built. A quorum queue is a Raft-replicated queue: with the default 3 members it tolerates 1 failure, and with 5 members 2. Its documentation lists very long backlogs and large fan-outs as better served by streams. Kafka replicates each partition to followers and counts a write committed once all in-sync replicas have it. Both are replicated, and the choice rests on the access pattern more than on safety.
Which situations fit each tool
- RabbitMQ fits. Task dispatch to workers with per-message acknowledgements and retries, plus priorities and dead letter handling
- RabbitMQ fits. Rich routing by key or pattern, and by header, where producers shouldn't know their consumers
- RabbitMQ fits. Request and reply style messaging and protocols such as AMQP 1.0 between services
- Kafka fits. A durable event backbone that several independent consumers read at their own pace
- Kafka fits. Replaying history to rebuild a table, backfill a new consumer or fix a bug
- Kafka fits. Per-key ordering at high volume, and feeds for stream processing and change data capture
Kafka vs RabbitMQ in data engineering pipelines
Data pipelines usually want the properties of a log. Events from a database or an application land once, and a warehouse loader and a stream processor read them, along with a monitoring job, each at its own pace, with the option to reprocess a day after a bug fix. That is the pattern in Kafka vs Kinesis and in batch vs streaming designs, and it's why Kafka shows up so often in pipeline design rounds.
RabbitMQ shows up in the control plane around a pipeline: triggering jobs, fanning out notifications, handing units of work to a pool of workers with retries and a dead letter path. In a system design answer, name the access pattern first, whether messages are consumed once or read many times, whether order by key matters, and whether replay is needed. Let that pick the tool.
To practice explaining these trade-offs, work through the data pipeline interview questions and the data pipeline practice problems, read the Kafka interview questions, and see how the system design round asks for them.
Kafka vs RabbitMQ FAQ
What is the main difference between Kafka and RabbitMQ?+
Is Kafka a message queue?+
Can RabbitMQ replay messages like Kafka?+
Does Kafka guarantee message ordering?+
Which is better for data pipelines, Kafka or RabbitMQ?+
Does RabbitMQ still need ZooKeeper or mirrored queues?+
Can I use both in the same system?+
The candidate who gets the offer
- 01
Reading a solution is not the same as writing one
Every engineer who has frozen on a query they had read a dozen times knows the gap. The only preparation that closes it is producing the answer yourself, under time, before the interview does it for you
- 02
76% of hiring managers reject on the coding task, not the resume
From HackerRank's 2024 Developer Skills Report. Candidates who look strong on paper still fail the live screen if they haven't done timed, executable practice
- 03
System design comes down to the calls you defend out loud
Ingestion, batch vs streaming, the bronze/silver/gold layers, idempotency, backfill and replay. Sketching the pipeline and naming the failure modes is the signal, not the boxes
Related guides
Data pipeline interview questions
The pipeline design questions interviewers ask
Data pipeline practice problems
Pipeline design problems to practice before the loop
Kafka interview questions
Partitions and consumer groups in Kafka, and its delivery guarantees
Kafka vs Kinesis
How each one scales, orders messages and costs, and when to use it
Kafka Connect vs Debezium
How each one captures database changes into Kafka and when to use it
Batch vs streaming pipelines
When each processing model fits
Compete in the Weekly
Dirty, production-shaped data, scored blind each week.