Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
Kafka vs RabbitMQ: a log, or a queue?
These both "move messages between services", which is exactly why teams pick the wrong one. Underneath they’re opposite designs: Kafka is a durable, replayable log where consumers remember their place; RabbitMQ is a smart broker that routes each message and forgets it once acknowledged. That difference decides almost everything.
The core difference: remember vs forget
Kafka is an append-only log. Messages are written to partitions and kept (for days, or forever); each consumer tracks its own offset — its position in the log. Many consumers read the same messages independently, and anyone can rewind and replay history. RabbitMQ is a message broker: a producer sends to an exchange, the broker routes it to queues by rules, a consumer takes it, acknowledges, and it’s deleted. The broker does the thinking; the message is transient.
Want an event history many services replay and reprocess — a stream of what happened? That’s Kafka. Want to hand tasks to workers with flexible routing, priorities, and per-message delivery — a job distributor? That’s RabbitMQ.
Head to head
| Dimension | Kafka | RabbitMQ |
|---|---|---|
| Model | Distributed append-only log | Smart routing broker + queues |
| After consumption | Message stays (consumers track offsets) | Message deleted on ack |
| Replay | Yes — rewind to any offset | Not in classic/quorum queues — gone once acked (streams, since 3.9, can replay) |
| Throughput | Very high (millions/sec) | High, but lower than Kafka |
| Routing | Simple (topic + partition) | Rich (direct, topic, fanout, headers) |
| Ordering | Guaranteed within a partition | Per-queue, weakens with competing consumers |
| Multiple consumers | Each reads the whole stream independently | Compete for messages (work-sharing) |
| Best fit | Event streaming, logs, analytics, CDC | Task queues, RPC, complex routing |
When to use each
Reach for Kafka
- Event streaming many services subscribe to
- You need replay / reprocessing of history
- Very high throughput (logs, metrics, clicks)
- Change-data-capture, event sourcing
- Strict ordering within a key/partition
Reach for RabbitMQ
- Distributing tasks to a pool of workers
- Complex routing (priorities, topics, fanout)
- Request/reply and RPC patterns
- Per-message TTL, dead-letter queues
- Lower operational weight for modest scale
Big systems run both: Kafka as the durable event backbone (the source of truth for what happened) and RabbitMQ where flexible task routing and low-latency work distribution matter. Pick by the job in front of you, not by which is "better".
Why Kafka's throughput ceiling is so much higher
The throughput gap isn't an implementation detail — it falls directly out of the two systems' core designs. RabbitMQ's broker does real work per message: it evaluates routing rules against an exchange, decides which queue(s) a message belongs in, tracks per-message acknowledgment state, and often persists to disk per-message for durability. That's real CPU and I/O work, multiplied by every single message, and it's exactly what makes RabbitMQ's routing so flexible.
Kafka sidesteps almost all of that. A producer writes to a partition, which is nothing more than an append to a sequential log file — the cheapest possible disk operation, and one modern disks (especially SSDs) handle at extraordinary rates. Kafka doesn't inspect message content to route it (the producer already picked the partition), doesn't track per-message state (consumers track their own offset, not the broker), and batches aggressively — grouping many messages into one disk write and one network round-trip. The result is a system built almost entirely around sequential I/O and batching, which is why a modest Kafka cluster can sustain millions of messages per second while a comparably-sized RabbitMQ cluster tops out dramatically lower. The lesson generalizes: RabbitMQ's intelligence lives in the broker per-message; Kafka pushes that intelligence to the edges (producers choose partitions, consumers choose what to read) and keeps the hot path as close to "just append to a file" as possible.
RabbitMQ's per-message routing intelligence costs throughput ceiling. Kafka's throughput ceiling costs per-message routing intelligence — you get a topic and a partition key, not a rules engine.
A worked scenario: order events across five services
Say an e-commerce checkout needs to notify five downstream services when an order completes: inventory, billing, shipping, analytics, and fraud review. With RabbitMQ, you'd publish one message to a fanout (or topic) exchange, and RabbitMQ copies it into five separate queues — one per consumer. Each service processes and acknowledges independently; once all five have acked their copies, the message's job is done and it's gone. If a sixth service launches next quarter needing the same event, you bind a new queue to the exchange going forward — but it only sees events from the moment it started listening. There's no "replay the last 30 days of orders" without a separate mechanism.
With Kafka, the order-completed event is appended once to an orders topic partition. All five services subscribe independently and each tracks its own offset into that same, single copy of the log — Kafka doesn't duplicate the message per consumer the way RabbitMQ's fanout does. When fraud review ships a new ML model next quarter and needs to re-score the last 90 days of orders, it simply resets its consumer offset to 90 days ago and re-reads the same log everyone else is still consuming live from — no special replay infrastructure, because replay is just "read from an earlier offset," the same operation as normal consumption.
Anywhere "add a new consumer of history we've already produced" is a real requirement — audit logs, ML feature backfills, debugging a production incident by replaying the events that led to it — Kafka's retained log is a structural fit. Anywhere the requirement is "deliver this once, to whoever's listening right now, with rich routing," RabbitMQ's transient queue model is the simpler tool.
Common mistakes
| Mistake | Why it bites |
|---|---|
| Using Kafka as a task queue for one-off jobs | Kafka has no per-message acknowledgment, no built-in retry-with-backoff for a single failed item, and no priority queues — semantics RabbitMQ was built for. Forcing Kafka into "distribute this job to exactly one worker" reinvents machinery RabbitMQ ships natively. |
| Assuming more Kafka partitions always means more throughput | Partitions are also the unit of parallelism for consumers and the unit of ordering guarantee — over-partitioning fragments ordering-sensitive keys across too many partitions and adds real overhead (open file handles, replication traffic) with no throughput benefit past what your consumers can actually parallelize. |
| Expecting global ordering from Kafka | Kafka only guarantees order within a partition, not across the whole topic. Two events for different customers, or even the same customer if not keyed consistently, can arrive out of order relative to each other across partitions — the producer's partition key is what determines what stays ordered. |
| Running RabbitMQ with unbounded queues under a slow consumer | Unlike Kafka's log (which just keeps growing on cheap disk), a RabbitMQ queue backing up behind a stalled consumer consumes broker memory directly and can bring the broker down — queue length limits, TTLs, or dead-lettering are not optional at any real scale. |
The picture: route-and-delete vs append-and-read
Cost and trade-offs: what each design charges you
Here Time is the effect on latency, throughput or effort. Space is what the broker has to store or track. Each row is a job both systems can do, and what each one costs.
| Case | Time | Space | Why |
|---|---|---|---|
| One more service wants the events | RabbitMQ: bind a new queue, and the broker routes every message into it as well. Kafka: start a new consumer group; nothing changes on the write path. | RabbitMQ: one more queue entry per message, tracked and acked separately. Kafka: one more stored offset. | Fan-out costs RabbitMQ work on every message. Kafka only pays network out for the extra reads. |
| Replay 90 days of history | Kafka: reset the group’s offset to a timestamp. Classic or quorum queues: impossible after ack. | Kafka at 1,000 orders/s × 1 KB × 90 days × replication 3 ≈ 23 TB. RabbitMQ queues hold only what is unacked. | RabbitMQ streams (a separate queue type since 3.9) do keep a replayable log, so “RabbitMQ cannot replay” is only true of its queues. |
| A consumer stops for an hour | Kafka: lag grows; the consumer catches up later at its own rate. RabbitMQ: the queue grows and the broker tracks every waiting message. | At 1,000/s, 3,600,000 messages, about 3.6 GB at 1 KB each, held in that one queue | Kafka’s risk is different: if lag outlives retention, records are deleted before they are read, and nothing tells the consumer. |
| Retry one failed message later | RabbitMQ: reject it to a dead-letter exchange, with a TTL for the delay. Kafka: publish it to a retry topic and move on. | RabbitMQ: one dead-lettered entry. Kafka: a copy in another topic, plus code to consume it. | Retrying inline on Kafka blocks the whole partition behind one bad record. |
| Urgent work jumps the line | RabbitMQ: priority queues. Kafka: a separate topic for urgent work, read by consumers that check it first. | RabbitMQ: a sub-queue per priority level. Kafka: one more topic. | A Kafka partition is read strictly in offset order, so there is no way to reorder inside it. |
| Order with parallel workers | RabbitMQ: competing consumers on one queue lose order, and single active consumer keeps order with one reader. Kafka: parallelism equals the partition count. | Kafka: order per key, for free, as long as the key picks the partition | RabbitMQ makes you choose between order and parallelism for each queue. Kafka lets you have both, split by key. |
| Send only some events to a reader | RabbitMQ: topic exchange patterns (order.*.eu) evaluated by the broker. Kafka: each consumer reads everything and discards what it does not need. | Kafka: wasted reads on the network, or an extra topic per subset | Filtering on the broker is RabbitMQ’s strength, and it is exactly the per-message work Kafka skips to go fast. |
| Run the cluster | Kafka: brokers plus a KRaft controller quorum (ZooKeeper was removed in Kafka 4.0). RabbitMQ: a cluster of nodes, with quorum queues replicated by Raft. | Kafka: disks sized for retention × replication. RabbitMQ: memory and disk sized for the worst backlog. | Both need replicas on separate machines. What you plan capacity around is different: days of history for Kafka, the size of a stall for RabbitMQ. |
| Make every write durable | RabbitMQ: publisher confirms with durable or quorum queues. Kafka: acks=all with a replication factor of 3. | Both keep several replicas on disk | Both make you wait for replicas. The difference is batching: Kafka groups many records into one write. |
The pattern is the page’s rule in cost form. RabbitMQ charges for each message as it passes through: routing, copying, tracking and deleting. That buys rich routing and cheap per-message retries, and it means storage stays small while consumers keep up. Kafka charges for retention: disk multiplied by days and by replication. That buys cheap fan-out, replay and per-key order, and it means a slow consumer costs nothing until it falls past the retention window. So size RabbitMQ for its worst backlog, and set limits such as max-length or TTL so a stalled consumer cannot fill the broker. Size Kafka for its retention window and for twice your peak in partitions. Then alert on the matching signal: queue depth for RabbitMQ, and for Kafka, consumer lag measured against how much retention is left. A lag of eight days is harmless on a 30-day topic and data loss on a 7-day one.
Which would you pick?
Three situations. Pick the side you'd actually build — the explanation follows.
You need to hand one-off jobs to a worker pool: each job goes to exactly one worker, failures retry with backoff, and urgent jobs jump the queue.
Kafka has no per-message acknowledgment, no built-in retry-with-backoff for a single failed item, and no priority queues. A consumer group gives you one-consumer-per-partition, not per-message dispatch, and retry topics are you rebuilding machinery RabbitMQ ships natively.
Order events must be consumed by five services, and a sixth is coming next quarter that will need to replay the last 30 days from the beginning.
This is the remember-vs-forget distinction the page is built on. A broker that deletes on delivery has nothing for a future consumer to read, so a fanout exchange serves today's five and leaves the sixth needing a bespoke backfill. Kafka retains the log, and replay is the default behaviour rather than a recovery project.
Throughput is short of target, so someone proposes raising the topic from 12 partitions to 200.
Over-partitioning fragments ordering-sensitive keys across more partitions and adds real overhead — open file handles, replication traffic — with no throughput benefit past what your consumers can actually process. Partition count is a scaling lever only up to consumer capacity; beyond it, you have bought cost and weakened ordering.
Quick answers
What is the main difference between Kafka and RabbitMQ?
Kafka is a durable, replayable log: messages are kept and each consumer tracks its own position, so many services can read the same stream and rewind history. RabbitMQ is a broker that routes each message to a queue and deletes it once a consumer acknowledges. Kafka remembers; RabbitMQ forgets.
Which has higher throughput, Kafka or RabbitMQ?
Kafka, by a wide margin — it is built for millions of messages per second via partitioned, sequential-disk writes. RabbitMQ handles high throughput too but is optimized for flexible routing and per-message delivery rather than raw stream volume.
Can RabbitMQ replay messages like Kafka?
Not natively. Once a RabbitMQ message is acknowledged it is deleted, so there is no rewind. Kafka keeps messages for a configured retention (days to forever), so any consumer can replay from any offset — essential for reprocessing and event sourcing.
When should I use RabbitMQ over Kafka?
When you are distributing tasks to workers and need rich routing (priorities, topic/fanout exchanges, dead-letter queues) or request/reply patterns, and you do not need to replay history. RabbitMQ is often simpler to operate at modest scale.
Kafka vs RabbitMQ: a log, or a queue?
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Handbooks
- The Kafka HandbookApache Kafka as a distributed append-only log, not a queue — topics, partitions and offsets, producers, consumers and consumer groups, per-key ordering, replication and ISR, delivery semantics (at-least-once and exactly-once), retention vs log compaction, and when Kafka beats a message queue.Read →
- The WebSockets & Real-Time HandbookWhy "live" is hard on a protocol that can't push. Polling makes you wait on average half the interval to learn of an event (a 10s poll = ~5s staleness) and wastes a request every time nothing changed — and shrinking the interval only multiplies the waste. A WebSocket keeps one persistent full-duplex line open so the server pushes the instant something happens: latency ≈ one network hop, zero empty requests. The poll-vs-push latency math, when to use SSE instead, and the stateful-scaling pitfalls. With worked math and runnable code.Read →
- Kafka vs KinesisSame partitioned-log model underneath, different operational surface: Kafka is self-run and portable with a huge ecosystem; Kinesis is fully AWS-managed with a hard per-shard throughput ceiling. Retention, cost model, and the lock-in trade-off.Read →
- REST vs Webhooks vs SSEThree ways client and server move data, split by who exposes an endpoint and whether the connection stays open: REST pulls, webhooks flip who runs the server, SSE keeps one connection open for a live push. How real systems run all three at once.Read →
- Streaming vs BatchBatch processes on a schedule; streaming reacts per-event. The real engineering cost of streaming isn’t speed, it’s correctness under disorder — event time vs processing time, watermarks, exactly-once semantics. The Lambda and Kappa architectures that combine both.Read →
- Mechanistic InterpretabilityThe engineer's guide to reading a model — interpretability as a debugger, not a séance. Why features live in superposition (not one per neuron), how sparse autoencoders pull monosemantic features back out, how attribution and circuit tracing find why a model did something (contribution of input i to output = the summed path weight W2·W1, validated causally by ablation), feature steering as a direct intervention, and an honest map of what you can debug today versus what is still research. Worked math plus a runnable 2-layer circuit tracer.Read →