Kafka 将分区复制到多个代理以实现持久性和可用性 — 每个分区都有一个 leader 和 follower 副本。如果代理发生故障,follower 会接管。理解复制是 Kafka 容错能力的关键。
复制如何工作
Each PARTITION is replicated across multiple brokers (REPLICATION FACTOR copies, e.g. 3):
→ LEADER replica → handles all reads and writes for the partition
→ FOLLOWER replicas → copy (replicate) the leader's data, staying in sync
→ producers/consumers interact with the LEADER; followers are backups
→ if the leader's broker FAILS → a follower is promoted to leader (failover) → no data loss,
continued availability
同步副本(ISR)
ISR (In-Sync Replicas) → the set of replicas CAUGHT UP with the leader:
→ only in-sync replicas are eligible to become leader (ensures the new leader has the data)
→ durability config: acks=all + min.insync.replicas → a write is acknowledged only when
enough ISRs have it → survives failures without data loss
→ ISR is central to balancing durability and availability
