OwlTheEngineer
System Design in 60 SecondsEpisode 28 · System design

Message queues vs Kafka: queues vs logs

RabbitMQ and SQS are message queues where messages are consumed and deleted. Kafka is an append-only distributed commit log where events are retained and replayed.

Owl · 2 min read · 0 views
– comments
Ep 28 · System design
60s VISUAL BREAKDOWN
Episode 28
Watch the fast visual breakdown or discuss on social:

Engineers often ask whether they should use RabbitMQ / SQS or Apache Kafka. While both decouple producers from consumers, their architectural models are completely different:

  • Traditional Message Queue (RabbitMQ, SQS): A To-Do List. Once a worker processes a message and sends an ACK, the message is permanently deleted.
  • Distributed Event Log (Kafka, Pulsar): An Append-Only Ledger. Messages are written sequentially to disk, kept for days or weeks, and multiple independent consumers track their own reading offsets.
Message Queue (RabbitMQ):  [ Msg 1 ] [ Msg 2 ] ──> Consumer ──> (Deleted upon ACK)
Distributed Log (Kafka):   [0][1][2][3][4][5]  ──> Consumer A (Offset: 3)
                                               ──> Consumer B (Offset: 5, Analytics)

How Message Queues work (Smart Broker, Dumb Consumer)

In systems like RabbitMQ:

  • The broker is responsible for state tracking, routing keys, fan-out exchanges, dead-letter queues, and acknowledging message delivery.
  • When a consumer pulls a message, the broker marks it invisible.
  • If the consumer succeeds, the message is removed. If it crashes, the broker re-queues it for another worker.
  • Ideal for: Background tasks, sending transactional emails, video encoding jobs, asynchronous work distribution.

How Kafka works (Dumb Broker, Smart Consumer)

Kafka treats topics as ordered partitions stored on disk:

  • Producers append events to the end of a partition: { offset: 42, payload: { order_id: 101 } }.
  • Consumers are grouped into Consumer Groups. Each consumer maintains its own pointer (offset) in the stream.
  • Messages are not deleted when read. They remain available for other consumer groups (e.g. Analytics, Billing, Notification service) to read at their own pace.
  • If a bug is fixed in production, a consumer group can rewind its offset to 3 days ago and replay history from scratch.
  • Ideal for: Event sourcing, real-time analytics, microservice event streaming, IoT telemetry.

Key Architectural Differences

FeatureMessage Queues (RabbitMQ / SQS)Event Streams (Kafka / Redpanda)
Data modelTransient FIFO message bufferAppend-only partitioned commit log
Message lifecycleDeleted after successful consumptionRetained on disk by time or size (e.g. 7 days)
Replayability❌ No replay (once ACKed, it’s gone)✅ Yes (can rewind offsets to any point in time)
OrderingPer-queue FIFO (can mix during concurrency)Strictly ordered within each partition
Routing complexityHigh (Topics, headers, fanouts, dead-letters)Simple (Partitioning by message key)
Throughput~10k–50k msgs/sec~1,000,000+ msgs/sec
SYSTEM DESIGN CHECK

Test Your Understanding

Quick architectural scenario challenge based on this breakdown.

SCENARIO

A 3rd-party payment gateway starts timing out with 504 errors during peak traffic.

Q1.How should a downstream dependency failure be handled to protect upstream service availability?

Comments –