--:--
kafka/
KAFKA

Kafka, live

Three brokers, two topics, two consumer groups, all running right here. Take a guided scenario, or break things yourself: stop a broker, cut its power, add a consumer, drag the timeline back to see it again, or type kafka-topics --describe in the terminal.

Simulated time 0:00

KIP-101, part 2: the same restart with leader epochs (Kafka 0.11+)

Step 1 of 5

Same start

The same two brokers and the same producer, but this cluster uses Leader epochA counter that goes up with every new leader. Each record carries the epoch it was written in, so a returning replica can ask where its epoch ended and cut off exactly what diverged (KIP-101). for truncation, like every Kafka since 0.11.

Based on KIP-101 (Apache Kafka)

How to read this picture

Brokers

  • Power light. Green: running. Red: stopped.
  • Activity light. Blinks while records go in or out.
  • The KRaft controller. It decides which replica leads each partition.
  • In and Out: network bytes per second. Disk: bytes in its log files. Cache: bytes written but not yet on disk.
  • Dashed border: a slow broker. Its followers fall behind.
  • Grey stripes: a stopped broker.
  • Leader replica: takes writes and serves reads
  • Follower replica: copies the leader
  • Out of the ISR: too far behind to count
  • Number on the right: the log end offset, the next offset this replica will write.

A partition’s log

  • A record; the colour is its key
  • No key
  • Striped: only in the page cache, lost if the power goes
  • Faded: above the high watermark, not yet on every ISR replica, so consumers can’t read it
  • Red inner border: a tombstone (null value) that deletes its key in a compacted topic
  • Grey hatching: deleted by retention or compaction
  • Dotted: an offset this replica doesn’t have yet
  • Red outline: differs from the leader at the same offset
  • High watermark: consumers read only below this line
  • A follower’s own idea of the high watermark, which lags the leader’s
  • Blue mark (in Inspect): where a consumer group will read next
  • Gold frame: the partition you picked. The Inspect panel below shows it.

Producers and consumers

  • Envelope: a producer. acks says how many replicas must have a record before it counts as written.
  • Dashed producer: records are waiting in it because no leader can be reached.
  • Face: one consumer in a group. Lag is how many records it hasn’t read yet.
  • Group: its state (Stable, rebalancing…), assignor and generation, which goes up at every rebalance.

What moves

  • Solid square: a record on its way from a producer to the leader (colour = key)
  • Hollow square: a follower copying records from the leader
  • Round dot: records fetched by a consumer
  • Crossed square: a request that failed

Producers

app

→ events · 0/s · acks=all

No keys (sticky)

sent 0 · acked 0 · failed 0

Cluster

Broker 1

Controller

Running

In0 B/s
Out0 B/s
Disk0 B
Cache0 B

Broker 2

Running

In0 B/s
Out0 B/s
Disk0 B
Cache0 B

Consumer groups

No consumer groups yet.

events · partition 0

Leader
1
Leader epoch
0
Replicas
1, 2
In-sync replicas
1, 2
Log start offset
0
High watermark
0
Log end offset
0

Click a record to follow its journey.

Segment files on broker 1 Leader

  • 00000000000000000000.log0 records0 B.index .timeindex

Segment files on broker 2 ISR

own HW 0

  • 00000000000000000000.log0 records0 B.index .timeindex

HW: consumers read below this line · LEO: next offset to write · only in the page cache · differs from the leader at the same offset

NOTES

Kafka notes

The concepts behind what you see above. They also live under Notes, tagged #kafka.