Replication, In-Sync Replicas & Leader Election
Understand partition replication mechanics, how the In-Sync Replicas (ISR) set shrinks and expands, High Watermark progression, and leader election trade-offs.
Hardware failures are an unavoidable reality in distributed systems. Hard drives fail, network switches drop packets, and hypervisors reboot physical nodes without warning.
To survive hardware failure without data loss or downtime, Apache Kafka replicates every partition commit log across multiple broker nodes.
In this lesson, you will explore how partition replication operates, how Kafka tracks replica health through the In-Sync Replicas (ISR) set, and how leader elections maintain data durability.
01Leaders, Followers, and Replication Factor
When you create a topic, you specify a Replication Factor (RF), which defines how many total copies of each partition exist across the cluster. In production environments, a replication factor of 3 is standard.
For every partition, Kafka designates:
- One Leader Replica: Handles all producer write requests and, by default, all consumer fetch requests. The leader is the source of truth for the partition.
- Multiple Follower Replicas: Do not handle client writes. Followers act like internal consumers, running dedicated background threads called
ReplicaFetcherThreadthat continuously fetch records from the leader and append them to their local disk logs.
Loading the rest of the lesson…