Architecture
5 min read
November 22, 2026
Kafka vs RabbitMQ: how to choose a message broker
Kafka vs RabbitMQ compared: queues versus a replayable log, ordering, routing, delivery guarantees, retries, operations and cost, with a simple guide to choosing for your system.
By Parth Patel
Kafka and RabbitMQ both move messages between services, so they are often compared as if they were two versions of the same thing. They are not. RabbitMQ is a message broker built around queues and routing. Kafka is a distributed, replicated log built around retaining events and replaying them. Choosing well starts with understanding that difference.
I've used both in production for event-driven messaging and background jobs; this is the comparison I use when deciding between them.
The core difference
RabbitMQ delivers messages to consumers and removes them once acknowledged. A message is a task to be done. The broker does the routing work: exchanges direct messages to queues by routing key, topic pattern or headers.
Kafka appends events to a topic and keeps them for a configured time, whether or not anyone has read them. Consumers track their own position (offset). Many independent consumer groups can read the same events, and any of them can rewind and replay.
That one difference drives almost every other trade-off.
Side-by-side
| RabbitMQ | Kafka | |
|---|---|---|
| Model | Queues; messages removed after acknowledgement | Partitioned log; events retained |
| Replay | Not built in | Rewind a consumer group to any offset |
| Ordering | Per queue (with one consumer) | Per partition (by key) |
| Routing | Rich: direct, topic, fanout, headers | Simple: topic and partition key |
| Throughput | High | Very high, designed for streams |
| Consumer scaling | Competing consumers on a queue | Up to one consumer per partition per group |
| Delivery | Per-message acknowledgements, retries, dead-lettering | Offset commits; retries are an application pattern |
| Operations | Simpler to run | More moving parts; managed services help |
When RabbitMQ is the better choice
- Work queues. Sending emails, generating PDFs, resizing images: tasks that should be done once by any available worker.
- Complex routing. Messages that need to reach different queues based on type, region or priority.
- Per-message control. Priorities, delayed retries, per-message time-to-live and dead-letter exchanges are built in.
- Lower volume, simpler operations. For many applications RabbitMQ is easier to run and reason about.
When Kafka is the better choice
- Event streaming. A stream of business events (orders placed, payments captured) that many services consume independently.
- Replay and new consumers. A new analytics service can read the last 30 days of events without anyone re-sending them.
- Event sourcing and audit trails. The log is a durable record of what happened.
- High throughput. Large volumes of events, telemetry or change data capture from databases.
- Ordering per entity. Using the order ID as the partition key keeps every event for one order in sequence.
Ordering and scaling, in practice
Both systems give you ordering only within a unit: a RabbitMQ queue with a single consumer, or a Kafka partition. Scaling out trades away global ordering.
In Kafka, choose the partition key carefully: events that must stay in order share a key (the same account, order or device). The number of partitions caps how many consumers in a group can work in parallel, so plan it for future throughput.
In RabbitMQ, multiple consumers on one queue process messages in parallel and out of order. If order matters per entity, use consistent-hash exchanges or a queue per key range.
Delivery guarantees and idempotency
Neither system removes the need for idempotent consumers. Both deliver at least once in normal configurations: a consumer can crash after doing the work but before acknowledging or committing, and the message comes back.
Design every consumer so processing a message twice is harmless: record processed message IDs, use natural idempotency keys, or make the operation an upsert. On the producing side, a transactional outbox keeps database changes and published messages in step. The Node.js microservices guide shows both patterns.
Retries and failures
RabbitMQ has the tools built in: negative acknowledgements, retry queues with delays, and dead-letter exchanges for messages that keep failing.
In Kafka, a failing message blocks its partition if you retry in place. The usual pattern is retry topics with increasing delays and a dead-letter topic, implemented in your consumer framework.
Either way, alert on dead letters and build a way to replay them once the cause is fixed.
Operations and cost
RabbitMQ is generally simpler to operate at moderate scale. Kafka has more concepts (brokers, partitions, replication, consumer groups, retention, schema management), and a managed service (Amazon MSK, Confluent Cloud and others) is usually worth the cost unless you have a platform team.
Also consider whether you need either: a managed queue such as Amazon SQS, or a jobs table in PostgreSQL, is enough for many applications' background work.
A simple decision guide
- Tasks to be done once → RabbitMQ (or a managed queue).
- Events that many services consume, or that you need to replay → Kafka.
- Both → it is common and reasonable to use Kafka for domain events and a simple queue for jobs.
- Small system, uncertain needs → start with a managed queue or a database-backed job queue, and move when the need is clear.
The right broker is the one that matches how your messages are used. Decide by asking whether a message is a task to be consumed, or a fact to be retained.