Few technology decisions generate more heated debate in architecture reviews than the choice between Apache Kafka and RabbitMQ. Both are mature, battle-tested, and widely deployed. Both handle messages between services. And both communities will tell you their tool is obviously the right choice.
In reality, they solve different problems. The confusion arises because those problems overlap enough that either can technically work — but using the wrong one means fighting your infrastructure for years. I've seen both mistakes in production, and they're not subtle when they happen.
How Each System Thinks About Messages
RabbitMQ: Messages as Tasks
RabbitMQ was built around the AMQP protocol and the metaphor of a post office. A producer sends a message to an exchange. The exchange routes that message to one or more queues based on rules (direct, fanout, topic, headers). A consumer picks up the message, processes it, and acknowledges it. The message is then removed from the queue.
This is the key behavior: once processed and acknowledged, the message is gone. RabbitMQ is designed for transient work — tasks that have a clear destination and a clear completion state. Order processing, email dispatch, notification delivery, background jobs. If something goes wrong, messages can be dead-lettered and requeued, but the base model is consume-and-discard.
Kafka: Events as a Log
Kafka thinks about messages entirely differently. Instead of a queue, Kafka has a log — an append-only, ordered, persistent sequence of events. Producers write events to a topic (a named log). Consumers read from that log at their own pace, tracking their position (offset) independently.
The events stay in the log for a configurable retention period (days, weeks, or indefinitely). Multiple consumer groups can read the same events completely independently. A new service can be added and replay the entire history. An existing service can be restarted and continue from where it left off.
This is a fundamentally different model: the log is the source of truth, not just a transit lane.
Where Each Excels
Apache Kafka
- Event streaming & real-time pipelines
- High-throughput data ingestion (millions of events/sec)
- Event sourcing & CQRS architectures
- Audit logs & compliance requirements
- Fan-out to many independent consumers
- Replay capability for reprocessing
- Stream processing (Kafka Streams, Flink)
RabbitMQ
- Task queues & background job processing
- Complex routing logic (topic exchanges)
- Priority queues
- Request-reply patterns (RPC over messaging)
- Per-message TTL and expiry
- Small teams, simpler operational model
- Low-latency delivery (< 1ms typical)
The Numbers That Actually Matter
| Dimension | RabbitMQ | Kafka |
|---|---|---|
| Throughput | ~50K msg/sec per node | Millions/sec across cluster |
| Latency | <1ms typical | 5–15ms typical |
| Message retention | Until consumed | Configurable (days/weeks/forever) |
| Consumer model | Push (broker delivers) | Pull (consumer polls) |
| Ordering guarantee | Per-queue (single consumer) | Per-partition (strict) |
| Operational complexity | Low to medium | Medium to high |
| Horizontal scaling | Federation, shovel | Native partition-based |
Kafka vs RabbitMQ Performance: What Actually Drives the Numbers
The table above gives orders of magnitude, not promises. In real benchmarks the configuration matters more than the product: a badly tuned Kafka cluster loses to a well-tuned RabbitMQ, and vice versa. These are the levers that move throughput and latency the most.
Kafka: throughput comes from batching
- Batching and compression:
batch.size,linger.msandcompression.type(lz4 or zstd) decide how many records travel per request. Higher linger means more throughput and a few extra milliseconds of latency. - Durability:
acks=allwithmin.insync.replicas=2is the safe default. It costs latency, not correctness — measure with it on, because that is how you will run in production. - Partitions: consumer parallelism is capped by the partition count of a consumer group. Too few partitions limit scale; too many cost memory, file handles and recovery time.
- Consumers:
max.poll.records,fetch.min.bytesand processing time per record determine consumer lag far more often than the broker does.
RabbitMQ: latency comes from flow control
- Queue type: quorum queues (Raft-replicated) are the default for data safety since RabbitMQ 4.0. Non-replicated classic queues are faster but lose messages with the node.
- Publisher confirms and persistence: persistent messages with confirms are the realistic setting. Confirm in batches or asynchronously, never one-by-one synchronously.
- Prefetch (QoS):
basic.qoscontrols how many unacknowledged messages a consumer holds. Too low starves consumers, too high causes uneven load and long redeliveries. - Queue length: RabbitMQ is fastest when queues are short. Long backlogs mean consumers are too slow — that is a capacity problem, not a broker problem.
Benchmark it yourself
Both projects ship load-test tools. Run them with your message size, durability settings and consumer count — not the defaults:
# Kafka: 1 million 1 KB records, durable writes
bin/kafka-producer-perf-test.sh --topic perf-test --num-records 1000000 \
--record-size 1024 --throughput -1 \
--producer-props bootstrap.servers=localhost:9092 acks=all linger.ms=10 compression.type=lz4
bin/kafka-consumer-perf-test.sh --bootstrap-server localhost:9092 \
--topic perf-test --messages 1000000
# RabbitMQ: PerfTest with quorum queues, persistent messages and confirms
java -jar perf-test.jar --uri amqp://localhost --queue-args x-queue-type=quorum \
--flag persistent --confirm 100 --producers 2 --consumers 2 \
--size 1024 --qos 200 --time 60
Compare p99 latency at your expected load, not the maximum throughput. Most systems never reach the limits of either broker; they do hit tail latency and consumer lag.
What Changed in 2025–2026
- Kafka 4.0 removed ZooKeeper. KRaft is the only metadata mode, which makes small clusters simpler to run than they used to be. Existing ZooKeeper clusters have to migrate on 3.x first (the safe order for the KRaft migration).
- Queues for Kafka (KIP-932). Share groups let several consumers work on the same partition with per-record acknowledgement — early access in Kafka 4.0, preview in 4.1, and Spring for Apache Kafka 4.1 (on Kafka 4.2) supports share consumers for production. This narrows the “Kafka is no task queue” gap, but RabbitMQ still has richer routing, priorities and per-message TTL.
- RabbitMQ 4.0 removed classic queue mirroring. Replication now means quorum queues or streams. RabbitMQ Streams offer an append-only log with replay — useful for moderate fan-out without introducing Kafka.
The Same Use Case in Spring Boot
An order service publishes an OrderPlaced event. With Kafka the event goes into a log that any number of services can read; with RabbitMQ it is routed into queues and removed once processed.
// Kafka (spring-kafka): key = orderId keeps all events of one order in order
@Service
class OrderEventsKafka {
private final KafkaTemplate<String, OrderPlaced> kafka;
OrderEventsKafka(KafkaTemplate<String, OrderPlaced> kafka) { this.kafka = kafka; }
void publish(OrderPlaced e) { kafka.send("orders", e.orderId(), e); }
@KafkaListener(topics = "orders", groupId = "billing")
void bill(OrderPlaced e) { /* every group (billing, analytics …) gets its own copy */ }
}
// RabbitMQ (spring-amqp): routed via a topic exchange, gone after ack
@Service
class OrderEventsRabbit {
private final RabbitTemplate rabbit;
OrderEventsRabbit(RabbitTemplate rabbit) { this.rabbit = rabbit; }
void publish(OrderPlaced e) { rabbit.convertAndSend("orders", "order.placed", e); }
@RabbitListener(queues = "billing.orders")
void bill(OrderPlaced e) { /* competing consumers share the queue's work */ }
}
The code looks almost identical. The difference is in what happens after the listener returns: Kafka keeps the event for replay, RabbitMQ deletes it. That is the decision you are really making.
Common Mistakes I See in Practice
Using Kafka as a task queue
Kafka has no native concept of "acknowledge and delete." If you put tasks into Kafka and want exactly-once processing with clear completion semantics, you have to build this logic yourself — tracking consumer offsets, handling idempotency, managing consumer group assignments when services scale. Teams underestimate this work consistently. For task queues, RabbitMQ with proper dead-lettering is half the code and twice the reliability.
Using RabbitMQ for fan-out at scale
Fanout exchanges in RabbitMQ work well for a handful of consumers. But each queue gets a full copy of every message. At high throughput with many consumers, you're now multiplying your storage and memory usage. Kafka's consumer group model — where all members of a group share a partition, but different groups each get a full copy — scales to dozens of consumers without this overhead.
Choosing Kafka for greenfield projects "to be safe"
This is the most common mistake I see from teams who've read the right blog posts but haven't operated production Kafka. ZooKeeper is gone since Kafka 4.0 (KRaft only), but production Kafka still needs careful partition sizing, replication factor decisions, schema registry for Avro/Protobuf, monitoring for consumer lag, and operators who understand the operational model deeply. For a team of three building a new product, this is often a multi-month distraction from the actual product.
A Practical Decision Guide
Ask these questions about your specific use case:
- Do you need to replay events? If you need to reprocess historical events, audit past state, or add new consumers that need full history — Kafka.
- Do you have >5 independent consumers of the same event stream? Kafka's consumer group model handles this naturally. RabbitMQ fanout gets expensive.
- Is your throughput measured in tens of thousands per second or more? Kafka. Under that, RabbitMQ's simpler operations won't be a bottleneck.
- Do you need complex routing (topic patterns, header matching, priority)? RabbitMQ's exchange types handle this natively.
- Is this a task with a clear completion? ("Send this email", "Process this order") RabbitMQ's acknowledge-and-delete model fits perfectly.
- Is your team smaller than 5 engineers? Strongly consider RabbitMQ first. Kafka's operational burden is real.
When to Use Both
In larger systems, using both is common and sensible — they're complementary, not competing. A typical pattern: Kafka handles the high-volume event stream (user activity, telemetry, order events), while RabbitMQ handles the downstream task dispatch (sending emails, triggering enrichment jobs, scheduling reports). Each tool does what it's best at.
The integration point is usually a Kafka consumer that translates events into RabbitMQ tasks. Keep that boundary thin and well-tested.
FAQ: Kafka vs RabbitMQ
Is Kafka faster than RabbitMQ?
For raw throughput, yes: Kafka batches records and scales horizontally across partitions, reaching millions of events per second in a cluster. For low latency on individual messages, RabbitMQ is usually faster. Which matters depends on whether you move large event streams or many small tasks.
Can Kafka replace RabbitMQ?
Partly. Share groups (Queues for Kafka) add queue-style consumption, but RabbitMQ still offers richer routing, message priorities, per-message TTL and request-reply. Many systems run both: Kafka for the event backbone, RabbitMQ for task dispatch.
Can RabbitMQ replay messages like Kafka?
Classic and quorum queues cannot — messages are removed after acknowledgement. RabbitMQ Streams provide an append-only log with replay, which covers moderate fan-out and reprocessing without adding Kafka.
Which is easier to operate?
RabbitMQ, for most teams. Kafka got simpler with KRaft, but partition sizing, replication, schema management and consumer-lag monitoring still require experience. Small teams without a platform team should start with RabbitMQ unless they need replay or very high throughput.
When should I use both Kafka and RabbitMQ?
When you have a high-volume event stream that several services consume and downstream work items with a clear completion state. A thin consumer translates Kafka events into RabbitMQ tasks; keep that boundary small and well-tested.
Go Deeper
Final Thought
Kafka and RabbitMQ are both excellent systems built by smart people to solve specific problems. The teams that struggle with them are the ones who adopted without clearly understanding what problem they're solving. Before the next architecture discussion, settle this question first: are you building a task pipeline or an event log? The answer should drive the rest of the conversation.