What is the role of replication in Kafka?

Replication in Kafka is the process of maintaining multiple copies of each partition across different brokers so that data remains available and durable even if a broker fails.

Key Points: • Each partition has a designated leader broker that handles all reads and writes, and one or more follower brokers that replicate the leader's data. • The replication factor for a topic determines how many total copies of each partition exist across the cluster. • If a broker fails, Kafka can promote one of the surviving in-sync replicas to leader, so the topic stays available. • Replication also spreads read load in the sense that failover keeps consumers served, though by default only the leader serves client traffic unless follower fetching is explicitly enabled. • Higher replication factors improve durability and availability at the cost of extra storage and network usage.

Example: A topic with replication factor 3 stores three copies of every partition across three different brokers, so the cluster can survive up to two broker failures without losing that topic's data.

Interview Tip: A concise interview answer is:

"Replication keeps multiple copies of each partition on different brokers so a broker failure doesn't mean data loss or downtime — Kafka just promotes one of the in-sync replicas to leader — and the replication factor is the main knob for balancing durability against storage cost."