Backend Patterns

Kafka vs RabbitMQ vs SQS

Kafka, RabbitMQ and Amazon SQS compared: log vs queue models, ordering, replay, throughput, delivery guarantees and operations, and when to use each.

Streams of light flowing through parallel channels representing message queues
Illustration: Backend Architect / AI-generated.

Key takeaways

  • Kafka is a durable, replayable log built for high-throughput event streaming.
  • RabbitMQ is a flexible message broker with rich routing for task queues and messaging patterns.
  • SQS is a fully managed queue with almost no operations, ideal for decoupling services on AWS.
On this page

Message systems let services communicate asynchronously: a producer sends a message and moves on, and consumers process it later. Kafka, RabbitMQ and SQS are three of the most popular choices, and they are built on different ideas.

The key difference: log vs queue

  • A queue (RabbitMQ, SQS) delivers each message to a consumer, which acknowledges it, and then the message is gone.
  • A log (Kafka) appends messages to a durable, ordered log. Logs suit fan-out workloads such as news feeds, where many consumers read the same events. Consumers track their own position and can re-read history. Many consumer groups can read the same data independently.

Comparison

KafkaRabbitMQSQS
ModelPartitioned, replayable logBroker with exchanges and queuesManaged queue
OrderingPer partitionPer queue (with caveats)Standard: best effort; FIFO queues: ordered
ReplayYes, within retentionNot by defaultNo
ThroughputVery highHighHigh, scales automatically
RoutingTopics and partitionsRich: direct, topic, fanout, headersSimple; combine with pub/sub services
OperationsSignificant (unless managed)ModerateMinimal

When to use Kafka

  • Event streaming and event-driven architectures
  • Many independent consumers of the same data
  • Replaying history to rebuild state; see event sourcing and CQRS
  • High-volume logs, metrics and analytics pipelines

When to use RabbitMQ

  • Background job and task queues
  • Complex routing between services
  • Request/reply messaging and priorities
  • Lower-latency messaging at moderate scale

When to use SQS

  • Decoupling services on AWS with minimal operational effort
  • Buffering spikes in load between producers and workers
  • Simple work queues where replay isn’t needed

Delivery guarantees

All three can deliver messages at least once, which means duplicates are possible. Design consumers to be idempotent; see our guide to idempotency keys. “Exactly-once” processing is possible in specific setups but requires careful design end to end.

In a system design interview

Use a queue to smooth spikes and decouple slow work, such as sending notifications (see designing a notification system) or recording analytics (see designing a URL shortener). Choose a log when multiple consumers need the same events or replay matters.

Frequently asked questions

Is Kafka a queue?

Not exactly. It’s a distributed log that can be used like a queue through consumer groups, while also supporting replay and multiple readers.

Which is easiest to operate?

SQS, because it’s fully managed. Managed offerings also exist for Kafka and RabbitMQ.

Can I use more than one?

Yes. Many systems use Kafka for event streaming and a queue for background jobs.

Sources

  1. Apache Kafka documentation
  2. RabbitMQ documentation
  3. Amazon SQS documentation

Every article is edited by a human and checked against our editorial policy. Spotted a mistake? Tell us.

Keep reading