Replication Factor - srivalligade04/ConfluentExamPreparationNotes GitHub Wiki
A replication factor greater than 2 is a key strategy to minimize data loss in Apache Kafka. Here's how it works and why it matters:
What is Replication Factor?
The replication factor determines how many copies of each partition Kafka maintains across different brokers.
- Replication factor = 1: No redundancy. If the broker fails, data is lost.
- Replication factor = 2: One backup. Safer, but still vulnerable if both brokers fail.
- Replication factor = 3 or more: Multiple backups. Much higher fault tolerance.
Benefits of Replication Factor > 2
Higher Fault Tolerance
- Kafka can tolerate multiple broker failures without losing data.
- With RF=3, Kafka can lose one broker and still have two in-sync replicas.
Stronger Durability with min.insync.replicas
- You can safely set min.insync.replicas=2 (or more), ensuring that at least 2 brokers must acknowledge a write.
- This prevents acknowledging writes that only exist on a single broker.
- Better Support for Safe Failover
- If a leader fails, Kafka can promote another in-sync replica without needing to resort to an unclean leader.