System Design Playbook
20 · Async & cloud7 min read

Kafka vs message queues: logs, offsets and replay

A queue hands out jobs and forgets them; a log like Kafka keeps every event in order so many services can read it at their own pace, and read it again.

In one sentence

A queue (SQS, RabbitMQ) deletes each message once one consumer handles it. A log (Kafka, Kinesis) keeps events in order for days; every consumer group tracks its own offset, so many services read the same stream and can replay it.

See the difference

Queue vs log (Kafka)
Broker
offset 0…-1new events →Billingoffset 0Analyticsoffset 0
Events produced
0
Events stored
0
Analytics lag
0
Events each service saw
0 / 0
A log keeps every event in order (for days or forever). Each consumer group just remembers its offset: slow services lag without slowing anyone, and a new or fixed service can replay history from the start.
In queue mode, billing and analytics compete for the same messages. In log mode, each keeps its own offset: analytics can lag, replay from 0, and a new service can start from the beginning.

How a log works

  • Producers append events to the end of a topic. Nothing is deleted when it's read; events expire by time or size (e.g. 7 days), or are kept forever.
  • Each event gets an increasing number, its offset.
  • A consumer group is one service (billing, analytics…). It stores the offset it has reached. Two groups never affect each other.
  • To scale, a topic is split into partitions. Events with the same key (e.g. orderId) go to the same partition, so order is kept per key. Inside a group, each partition is read by one consumer, so the number of partitions caps the parallelism.

Queue or log?

Queue (SQS, RabbitMQ)Log (Kafka, Kinesis, Pulsar)
After a message is readDeletedKept until retention ends
Many services reading the same eventsOne queue per service (fan-out with SNS)Native: one consumer group each
Re-reading the pastNoYes: move the offset back
OrderingBest effort (FIFO queues are limited)Guaranteed per partition
Per-message retries and DLQBuilt inYou build it (retry topics)
OperationsFully managed and simpleMore to run and tune (managed options exist)

Pick a queue for jobs

  • Send this email, resize this image
  • Each task done once by any worker
  • Simple retries and dead-letter queues

Pick a log for events

  • "Order created" consumed by 5 services
  • Analytics, search indexing, audit trail
  • Need to replay after a bug, or rebuild a view

Things that bite

  • At-least-once delivery: after a crash, a consumer can re-read events it already processed. Make consumers idempotent.
  • Hot partitions: if one key gets most of the traffic (a celebrity, a big customer), its partition becomes the bottleneck.
  • Consumer lag is the key metric: how far behind the head each group is. Growing lag means you need more consumers (and enough partitions).
  • Retention costs storage: keeping 30 days of a busy topic can be many terabytes.

Key takeaways

  • 01Queues delete messages once handled; logs keep them and let each consumer group track an offset.
  • 02Logs let many services read the same events independently and replay history.
  • 03Partitions give scale and per-key ordering; their number caps parallel consumers.
  • 04Use queues for one-off jobs and logs for event streams; monitor consumer lag.

Check your understanding

1 of 3

What happens to a message in a log like Kafka after it's read?

Related concepts