Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Handbooks  /  Kafka vs RabbitMQ
Engineering~9 min readComparison
Head to Head

Kafka vs RabbitMQ: a log, or a queue?

KafkavsRabbitMQ

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.

01

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.

→ The rule

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.

02

Head to head

DimensionKafkaRabbitMQ
ModelDistributed append-only logSmart routing broker + queues
After consumptionMessage stays (consumers track offsets)Message deleted on ack
ReplayYes — rewind to any offsetNot in classic/quorum queues — gone once acked (streams, since 3.9, can replay)
ThroughputVery high (millions/sec)High, but lower than Kafka
RoutingSimple (topic + partition)Rich (direct, topic, fanout, headers)
OrderingGuaranteed within a partitionPer-queue, weakens with competing consumers
Multiple consumersEach reads the whole stream independentlyCompete for messages (work-sharing)
Best fitEvent streaming, logs, analytics, CDCTask queues, RPC, complex routing
03

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
→ Not either/or at 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".

04

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.

→ The trade you're actually making

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.

05

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.

→ The pattern generalizes

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.

06

Common mistakes

MistakeWhy it bites
Using Kafka as a task queue for one-off jobsKafka 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 throughputPartitions 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 KafkaKafka 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 consumerUnlike 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

The picture: route-and-delete vs append-and-read

RabbitMQ: route, copy, delete Kafka: append once, read by offset producer exchange billing queue shipping queue fraud queue an entry per bound queue deleted when its consumer acks producer 0 1 2 3 4 5 billinganalytics fraud: replay orders partition 0, by offset one copy, kept for the retention window each group stores only its offset
RabbitMQ does its work when a message arrives. The exchange matches bindings and puts an entry in every queue that matches, and each entry is gone once its consumer acks. Kafka does almost nothing on arrival: it appends to the end of one partition’s log. The work moves to the readers, which each keep a number, their offset. A new reader, or an old one replaying (fraud, above), only needs to start from a smaller number. That is also why the two fail differently. A RabbitMQ queue with a stalled consumer grows inside the broker. A Kafka group with a stalled consumer just has an offset that stops moving while the log keeps growing, until the oldest segments age out past retention.
Trade-offs

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.

CaseTimeSpaceWhy
One more service wants the eventsRabbitMQ: 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 historyKafka: 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 hourKafka: 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 queueKafka’s risk is different: if lag outlives retention, records are deleted before they are read, and nothing tells the consumer.
Retry one failed message laterRabbitMQ: 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 lineRabbitMQ: 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 workersRabbitMQ: 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 partitionRabbitMQ makes you choose between order and parallelism for each queue. Kafka lets you have both, split by key.
Send only some events to a readerRabbitMQ: 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 subsetFiltering on the broker is RabbitMQ’s strength, and it is exactly the per-message work Kafka skips to go fast.
Run the clusterKafka: 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 durableRabbitMQ: publisher confirms with durable or quorum queues. Kafka: acks=all with a replication factor of 3.Both keep several replicas on diskBoth 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.

Your call

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.

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.

Throughput is short of target, so someone proposes raising the topic from 12 partitions to 200.

Frequently asked

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.

▶  Watch it explained

Kafka vs RabbitMQ: a log, or a queue?

Kafka vs RabbitMQ · Engineering · Vibe Engines · 2026
Finished this one? 0 / 209 Handbooks done
NextKafka vs Kinesis Next on the “Moving data between services” ladder · rung 3 of 6

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks