BrokersClustersISRAcksReplicationKRaftLeader ElectionController
Kafka Brokers & Replication
The physical layer — how Kafka stores data across brokers, replicates for durability, and survives failures through leader election and ISR management.
35 min read9 sections
01
Brokers & Cluster Topology
A broker is a single Kafka server. It receives records from , stores them on disk, and serves them to consumers. A Kafka cluster is a group of brokers working together, with .
Cluster Topology — 3 Brokers, 1 Topic, 6 Partitions, RF=3text
Broker 1 (id=1) Broker 2 (id=2) Broker 3 (id=3)
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ P0 (Leader) │ │ P0 (Follower) │ │ P0 (Follower) │
│ P1 (Follower) │ │ P1 (Leader) │ │ P1 (Follower) │
│ P2 (Follower) │ │ P2 (Follower) │ │ P2 (Leader) │
│ P3 (Leader) │ │ P3 (Follower) │ │ P3 (Follower) │
│ P4 (Follower) │ │ P4 (Leader) │ │ P4 (Follower) │
│ P5 (Follower) │ │ P5 (Follower) │ │ P5 (Leader) │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Key points:
- Each partition has exactly ONE leader and (RF-1) followers
- Leaders handle ALL reads and writes for their partition
- Followers only replicate data from the leader (fetch requests)
- Partitions are distributed to balance load across brokers
- If Broker 2 dies: P1 and P4 elect new leaders from remaining ISR
🏢
The Office Building
A Kafka cluster is like an office building with multiple floors (brokers). Each floor has filing cabinets (partitions). For each document type, one floor is the 'primary office' (leader) where all new documents arrive. The other floors keep photocopies (replicas). If a floor floods (broker failure), the primary office moves to another floor that has up-to-date copies.
What Each Broker Manages
- ✅A subset of partition replicas (both leaders and followers)
- ✅Disk storage for log segments of its assigned partitions
- ✅Network connections from producers and consumers
- ✅Fetch requests from follower replicas replicating data
- ✅Heartbeats to the controller for liveness detection
1 / 9