--:--
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

Retention and compaction

Step 1 of 3

Segments roll

Each partition is stored as SegmentA partition is stored as a series of files, each named after its first offset. Retention and compaction work on whole closed segments. files named after their first offset. app-logs rolls a new segment every 600 bytes and keeps them for 15 s.

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

web

→ app-logs · 8/s · acks=1

No keys (sticky)

sent 0 · acked 0 · failed 0

profile-svc

→ profiles · 4/s · acks=all

A few keys

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

Broker 3

Running

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

Consumer groups

archiver

Rebalancing

range · gen 0 · Total lag 0

  • archiver0.5/s

    No partitions (more members than partitions, or rebalancing)

app-logs · partition 0

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

Click a record to follow its journey.

Segment files on broker 2 Leader

  • 00000000000000000000.log0 records0 B.index .timeindex

Segment files on broker 1 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.