Lesson 7 · Reliability core
Replication & ISR
How Kafka survives a broker dying — and what acks=all was really waiting for.
Your win: explain leaders, followers, and the in-sync replica set;
describe what happens when a broker holding a leader dies; and connect it back to the
acks knob from Lesson 4.
Every partition is copied N times
A partition isn't stored on one broker — it's stored on replication factor brokers. One replica is the leader (handles all reads and writes); the rest are followers that continuously fetch from the leader to stay identical.1 Producers and consumers only ever talk to the leader; followers are pure backups.
ISR: the replicas that are allowed to take over
The ISR (in-sync replicas) is the leader plus every follower currently caught up to it. Kafka tracks this set live: a follower that falls too far behind is dropped from the ISR, and rejoins when it catches up.1
The ISR matters for one reason: when a leader dies, the new leader is elected from the ISR — and only from the ISR, because only those replicas have all the committed data. Followers that were lagging aren't eligible (electing one would lose data). The group of consumers reading that partition then just reconnects to the new leader and continues.
This is what acks=all was waiting for
Now Lesson 4 closes. acks=all means "confirm the write only once the
whole ISR has it." So even if the leader dies immediately after, a caught-up follower
becomes leader with your write intact. acks=1 (our setting)
confirms after only the leader — faster, but if the leader dies before a follower
copied it, that write is gone.
acks=all alone isn't enough — pair it with
min.insync.replicas ≥ 2. That forces at least two replicas to hold a
write before it's acknowledged, so a single broker loss never loses data. "acks=all
+ min.insync.replicas=2" is a gold-star interview answer.
Why your local stack shows none of this
Locally you'd never see replication in action, and the repo tells you why — topic creation forces replication factor 1 for the local environment:
internal/golibs/kafka/kafka.go:773 (UpsertTopic)if isLocalEnv {
topicConfig.ReplicationFactor = 1 // one copy — no fault tolerance locally
}
conn.CreateTopics(*topicConfig)
upsert_kafka_topics job. Locally it's always 1, so a
single broker restart does interrupt you — that's an artifact of local dev,
not how staging/prod behave.
Confluent Developer — Kafka Data Replication Protocol
The clearest walkthrough of leaders, followers, ISR, and leader election. Pair with the Confluent replication design doc for exact wording.
→ developer.confluent.io/courses/architecture/data-replication
→ docs.confluent.io/kafka/design/replication.html
Check yourself (from memory)
Q1. For one partition, reads and writes are served by…
Q2. When a leader dies, the new leader is chosen from…
Q3. With replication factor 3, how many brokers can you lose?
acks=all to the ISR in one sentence.acks=all waits until every in-sync replica has the
write before confirming it — so if the leader dies right after, a caught-up follower
(an ISR member) becomes leader with your data intact. Pair it with
min.insync.replicas ≥ 2 for real single-broker-loss safety.1. Confluent — Kafka Replication; Confluent Developer — Data Replication Protocol.