The log is the database — per-consumer offsets on an append-only log
Log messages are immutable; consumers are bookmarks tracking their own offset. Reads do not delete.
You've seen records flow end-to-end. Now the load-bearing fact: Kafka is NOT a queue. Reads don't pop messages — the consumer is just a bookmark, and the log keeps the bytes.
Scene 02
The log is the database
- Watch
- Try it
- Predict
- Capture
What Kafka is for: many services need to react to the same stream of events — orders, clicks, signups, metrics — without each one polling a database or calling every consumer directly. Kafka is a durable, append-only log that producers write to and any number of consumers read from independently. The vocabulary in this diagram is the whole thing: a Producer sends messages; a Partition is the ordered log of those messages (one cell per message, numbered left-to-right by offset); a Consumer reads from a position on that strip. Watch the producer append messages to the partition. Consumer 1's cursor follows along — it's a position, not a queue position. Messages don't disappear when read; the cursor just advances.
Highlighted lines are the ones running in the diagram right now.
def append(record):offset = len(log) # next slotlog.append(record) # write-once cell# no overwrite, no in-place mutationreturn offset
def read(consumer_id, count = 1):pos = cursor[consumer_id]records = log[pos : pos + count]# slice — log itself is unchangedcursor[consumer_id] = pos + len(records)return records
def dequeue():if not buffer:return Nonerecord = buffer.pop(0) # head removed# gone — no second reader can ever see itreturn record
Where this sits in Build Kafka
Scene 02 of 13, in the Why a log? act — Orientation — the log is the database, not a queue.. Why a log isn't a queue, and why that one fact unlocks the rest.
Up next. Offsets, retention, and where bookmarks live — if reads don't delete, what does? And where does a consumer's bookmark physically live?
Designs that use this
- Twitter / X TimelinePush or pull? Both. The canonical fanout problem.
- Uber / Lyft — Match Drivers and RidersMatch a rider to the closest acceptable driver in under 3 s. Geohash, S2, surge.
- Slack / DiscordChannels and history. Push or pull — and how a hot-channel fanout doesn't melt the gateway.
- WhatsApp / MessengerHundreds of millions of long-lived sockets, sub-second 1:1 + group delivery, E2E-encrypted, multi-device, multi-region active-active.