Skip to the guide

Kafka from the ground up

IntermediateConcept3 pages

Kafka is the event stream most interviewers have in mind: a log split into partitions, copied across servers, kept for days and read by any number of consumer groups. Interviewers probe two things: what's lost when a server dies, and how big the cluster must be.

The order books

A delivery firm writes every job into a set of order books, shared out between several desks. A clerk only ever writes on the next empty line, and every line is numbered. Jobs for the same customer always go in the same book, so they stay in order. Two other desks keep carbon copies; if a desk's book is lost, an up-to-date copy becomes the original. Billing and tracking each read every book at their own pace, with a bookmark in each. Pages older than a week are torn out.

  • the clerk writing a job → the producer
  • the set of books → a topic
  • one book → a partition: a log you only append to
  • the line number → the offset
  • the desks → brokers, the servers that store partitions
  • same customer, same book → the message key chooses the partition
  • carbon copies → replicas: one leader that takes writes, and followers that copy it
  • each team with its bookmarks → a consumer group with its committed offsets
  • tearing out old pages → retention, 7 days by default