Kafka has a reputation for being complicated, and its vocabulary does not help: topics, partitions, offsets, segments, consumer groups, rebalances, generations. I used these words for a long time before I could explain why each one has to exist.
The quickest way I know to understand a design is to rebuild a small version of it. mq is a small Kafka-style message queue in Go, using only the standard library. It has topics split into partitions, an append-only segmented log per partition, consumer groups with committed offsets, retention, and a TCP protocol with a Go client. It is a single broker and a learning project. What it gave me is a clear picture of why a log sits at the centre of a message queue.
What it does
The code is four packages:
wal : the storage engine.…