Skip to content
All articles

Kafka · Event-Driven Systems

Why Kafka is a log, not a queue

A queue deletes a message once it is delivered. A Kafka topic keeps it and remembers one position per consumer group. That one choice explains fan-out, replay, and the head-of-line problem.

· 4 min read

Comparison. A queue deletes messages on delivery to competing workers: no second reader, no replay, and the broker tracks every message. A Kafka topic is an append-only log, offsets 0 to 9, kept by retention; consumer group A is at offset 9 and group B at offset 4. Reading doesn't delete, a new reader is a new group, and replay is an offset reset.

A traditional message queue deletes a message once it has been delivered and acknowledged. It sounds like tidy housekeeping. In practice it causes three problems you have probably met.

You cannot add a second independent reader. Marketing wants every order event too, but the fulfilment workers already share each message between them. A second view needs a fan-out topology, publishing twice, or another copy of the data somewhere.

You cannot replay. A bug in the fulfilment consumer mishandled nine hours of orders. The messages are gone, so the fix is a one-off backfill script against the database, rebuilding events that used to exist.

The broker tracks every message's fate: delivered, acknowledged, redelivered, dead-lettered. That bookkeeping is a large part of what makes queues hard to scale.

What a log changes

A Kafka topic is an append-only log kept according to a retention policy, not consumed away. Reading does not delete. A consumer group records only how far it has read in each partition, its offset. Adding a reader means adding a group with its own offsets. Replaying nine hours means moving a group's offsets back nine hours.

The price of storing one number

Within a traditional consumer group, a partition's progress is a single integer. That is what makes fan-out and replay cheap, and it is also why the group cannot say "this one record failed, deliver just that one again" while moving past it. One stuck record blocks its partition, which is why Kafka designs end up with a dead-letter topic.

QueueKafka consumer groupKafka share group
Second independent readerneeds fan-out or double publishingyes, a new groupyes
Replay nine hoursno, the messages are goneyes, reset the offsetsyes, from the retained log
Acknowledge one recordyesno, progress is one number per partitionyes
Orderinglost with competing consumersper partitionweakened
Parallelism ceilingnumber of consumersnumber of partitionsbeyond the partition count

Share groups, available from Kafka 4.2, bring back per-record acknowledgement, and with it per-record bookkeeping and weaker ordering. They are a different trade, not a newer version of the same thing.

Think Like an Engineer

A team wants both fan-out and per-record acknowledgement on one topic. They can have it with two groups of different kinds on the same log: a consumer group for the reader that needs per-key order and replay, and a share group for the worker that needs to skip failures. What no single group can offer is both, because skipping a record and keeping that key's order are the same decision seen from two sides.

The useful question about a topic is which of those columns its readers need. A topic carrying changes to an order's state needs per-partition ordering. A topic of independent work items may not.

Get one diagram a week

A short article built around one engineering diagram, from the same library as these courses.

One diagram-led article a week on AI and systems engineering. We email you once to confirm, and every newsletter has an unsubscribe link. Privacy policy