What is the role of replication in Kafka?
Instruction: Explain how replication works in Kafka and why it is important.
Updated
Official answer
Replication maintains copies of each partition on multiple brokers. One replica leads writes; followers fetch its log. If a broker fails, an eligible surviving replica can take over leadership, subject to metadata-quorum and replica-state requirements.
A replication factor of three means three assigned replicas, not three currently healthy, synchronized copies. Monitor the in-sync replica set, replication lag and under-replicated partitions. Spread replicas across appropriate failure domains; a broker count alone does not prove zone or regional resilience.
For an illustrative replication factor of three with min.insync.replicas=2 and producer acks=all, writes require the applicable minimum in-sync condition. Losing enough synchronized replicas can make writes unavailable rather than silently reducing the durability requirement. Unclean leader election trades acknowledged-data safety for availability and must not be treated as a harmless recovery shortcut. Current Kafka versions also have eligible-leader-replica rules; check the deployed feature configuration.
Consumers normally fetch from leaders, but configured follower fetching is supported. Therefore, saying that the leader always handles every read is too broad.
Replication helps recover from specified replica failures. It does not protect against every deletion, invalid producer event, compromised credential or disaster affecting all copies. Keep appropriate backup/archive and recovery procedures, and test what happens when brokers, disks or whole failure domains are lost.
Replication design, eligible leader replicas, broker configuration
Related Questions
-
easy
-
medium
-
medium
-
hard
-
hard