Kafka achieves fault tolerance by replicating every partition across multiple brokers, so the failure of any single broker doesn't cause data loss or an unavailable topic.
Key Points: • Each partition has one leader and one or more follower replicas that continuously copy the leader's data. • Only in-sync replicas (ISR) — followers that are caught up with the leader — are eligible to be promoted if the leader fails. • If a broker hosting a partition leader fails, a new leader is automatically elected from the ISR, typically coordinated via ZooKeeper or, in newer versions, the KRaft controller quorum. • Producers using acks=all combined with a sufficient min.insync.replicas ensure a write is durable across multiple replicas before being acknowledged. • Data is persisted to disk on each replica, so even a full broker restart doesn't lose already-committed data.
Example: If a topic has replication factor 3 and the broker hosting the current leader crashes, Kafka promotes one of the two remaining in-sync replicas to leader within seconds, and producers/consumers reconnect to the new leader with no data loss.
Interview Tip: A concise interview answer is:
"Kafka achieves fault tolerance by replicating each partition across multiple brokers and automatically electing a new leader from the in-sync replicas if the current leader fails, so as long as replication factor and min.insync.replicas are configured sensibly, a single broker failure doesn't cause downtime or data loss."