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.

Previously

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

  1. Watch
  2. Try it
  3. Predict
  4. Capture
Producerappends only(no overwrites)PARTITION 0Consumer 1offset = 0
What to watch for

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.

Continue unlocks when the animation finishes.
Implementation

Highlighted lines are the ones running in the diagram right now.

Log.append
producer-side append to the partition
def append(record):
offset = len(log) # next slot
log.append(record) # write-once cell
# no overwrite, no in-place mutation
return offset
Log.read
server-side read at a per-consumer offset
def read(consumer_id, count = 1):
pos = cursor[consumer_id]
records = log[pos : pos + count]
# slice — log itself is unchanged
cursor[consumer_id] = pos + len(records)
return records
Queue.dequeue
the contrast — single reader, destructive read
def dequeue():
if not buffer:
return None
record = buffer.pop(0) # head removed
# gone — no second reader can ever see it
return 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?

All 13 scenes in Build Kafka · Every curriculum

Built with Arqly
Every scene in Build Kafka builds on the one before it.All 13 Build Kafka scenes