Lesson 21 / 25

RabbitMQ vs Kafka vs Cloud Queues

Choose between RabbitMQ, Kafka and managed queue services.

Different tools for different shapes of work

RabbitMQ is a smart broker: rich routing with exchanges, per-message acknowledgements, priorities, TTLs, dead-lettering and request-reply. It shines for task distribution, command and event routing between services, and workloads where messages are consumed and removed, with moderate to high throughput. Apache Kafka is a distributed log: very high throughput, long retention, replay, partition-based ordering and stream processing ecosystems; consumers track offsets themselves and routing is mostly by topic. RabbitMQ streams cover some log-style needs inside RabbitMQ. Managed cloud services such as Amazon SQS and SNS, Azure Service Bus and Google Cloud Pub/Sub remove broker operations entirely, with different feature sets and limits; Amazon MQ and some providers also offer managed RabbitMQ. Choose by workload shape (tasks versus event log), routing needs, replay requirements, throughput, ecosystem, and whether your team wants to operate a broker.

A comparison table

Typical strengths; check current limits of each product for your design.

need                                   RabbitMQ                 Kafka                     SQS / Service Bus / Pub/Sub
-------------------------------------  -----------------------  ------------------------  ---------------------------
flexible routing (topic, headers)      excellent                topics + consumer logic   filters / subscriptions
per-message ack, retries, DLQ          built in                 consumer-managed offsets  built in
replay old messages                    streams                  core feature              limited / seek features
very high throughput, long retention   streams: good            excellent                 good, provider limits
priorities, TTL, delayed delivery      yes                      no (build yourself)       varies
operations burden                      run it (or managed)      run it (or managed)       none (fully managed)

Pick by consumption model

If consumers take a task and it disappears when done, think queue (RabbitMQ, SQS). If many consumers read and re-read an ordered history, think log (Kafka, RabbitMQ streams).

Quick check: Which requirement points most strongly towards a log-based system such as Kafka (or RabbitMQ streams) rather than classic queues?

  • Per-message priorities
  • A simple background email job
  • Many consumers replaying months of ordered events
  • Request-reply with correlation IDs
Answer

Many consumers replaying months of ordered events — Long retention with replay by many independent consumers is the defining strength of logs.