This episode covers Kafka replication and high availability: leader and follower replicas, In-Sync Replicas, the high watermark and log-end-offset, unclean leader election, min.insync.replicas, and rack awareness for failure domain isolation and multi-AZ deployment.

Replication is the reason Kafka stays available when a broker dies. Every partition is copied to several brokers, and when its leader fails, a replacement is promoted. But behind that simplicity lie complex decisions: who gets to be the leader, and when the system is willing to sacrifice availability for consistency.
Episode 24 dissects replication in depth: the roles of leaders and followers, In-Sync Replicas, the high watermark mechanism, the risk of unclean leader election, the role of min.insync.replicas, and rack awareness for multi-AZ deployment.
Every partition has one leader and several followers. The leader serves all writes and reads; followers only copy data from the leader. When the leader dies, the controller picks the best follower as the new leader. If a follower stops receiving data or fails, it's marked out-of-sync and removed from the ISR.
The ISR is the list of followers still in sync with the leader. A follower leaves the ISR if it doesn't send fetch requests or lags past replica.lag.time.max.ms (default 30 seconds). A follower that catches up rejoins the ISR. The ISR determines failure tolerance: with an ISR of 3 and a replication factor of 3, two brokers can die without data loss.
Check ISR health with describe:
bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic ordersThe output shows per partition the Leader, Replicas, and Isr columns. Healthy state: all Replicas appear in Isr, and Leaders are evenly spread. If a replica is missing from the Isr, investigate why the follower is lagging.
Followers pull data from the leader via periodic fetch requests. Every partition tracks two positions:
Consumers can only read records below the high watermark. This prevents consumers from seeing data that hasn't been replicated — if the leader dies before replication finishes, data above the high watermark isn't considered stored.
When all ISR replicas are dead, Kafka faces a choice: wait for an ISR replica to recover (unavailable, but safe) or promote an out-of-sync follower to leader (available, but data may be lost). This policy is governed by unclean.leader.election.enable:
unclean.leader.election.enable=falseunclean.leader.election.enable=false is the recommended production setting for data that must not be lost. For non-critical workloads that prioritize availability, consider true with full awareness of the consequences.
This is the classic CAP trade-off in concrete form. Choose based on your data: for financial transactions and critical events, consistency wins (false); for telemetry where loss is acceptable, availability wins (true). Monitor unclean-leader-elections-per-sec to detect whether the active policy is being forced.
The consequences of choosing true need to be fully understood: consumers reading before the election can see records that then "disappear" after an out-of-sync follower is promoted — because records above the high watermark are discarded. Always account for this impact on consuming applications before changing the setting.
min.insync.replicas determines the minimum number of ISR replicas required for a write to be accepted:
min.insync.replicas=2The combination that guarantees high durability: min.insync.replicas=2 on the broker with acks=all on the producer. With a replication factor of 3, brokers accept writes only if at least 2 replicas are in sync — once the ISR drops to 1, writes are rejected, preventing writes to a lone leader that might lose data.
min.insync.replicas is the most important safety net. It ensures acks=all means all current ISRs receive the data, and the ISR can't shrink below the threshold. Note: the ISR is a dynamic condition, not a fixed size — if a replica is slow, the ISR can drop and block writes. Design the replication factor and threshold accounting for how many brokers can be down.
Kafka can place replicas in different failure domains via broker.rack:
broker.rack=us-east-1abroker.rack=us-east-1a tells Kafka where a broker's failure domain is. When creating a topic, Kafka tries to place leader and follower replicas in different racks, so one rack failure doesn't bring down all replicas of a partition.
With rack awareness, multi-AZ deployment becomes safe: a replication factor of 3 with brokers spread across three AZs. An AZ failure only drops one replica per partition — the ISR stays at 2 of 3, and writes continue. Combine with min.insync.replicas=2 so one AZ being down neither blocks writes nor sacrifices durability.
Warning
Rack awareness only works if you set broker.rack correctly from the start and topics use --rack-aware or brokers are configured with the right replica.selector.class. Verify with kafka-topics.sh --describe that replicas are spread across different racks.
In this episode 24 you've understood replication in depth: leaders and followers, ISR, the high watermark, the risk of unclean leader election, the role of min.insync.replicas, and rack awareness for multi-AZ deployment.
The key takeaways:
unclean.leader.election.enable=false prevents data loss at the cost of availability.min.insync.replicas=2 plus acks=all guarantees high durability.In the next episode 25 we'll discuss disaster recovery and data migration — MirrorMaker 2.0 for cross-cluster replication, active-active and active-passive patterns, RPO/RTO considerations, and zero-downtime migration between clusters.