Replication

Topic Replication

  • Topics should have replication factor greater than 1 (usually between 2 and 3), commonly 3.

  • If broker goes down or goes for maintenance, another broker can take over and serve the data.

  • Replication is synchronous if fast enough i.e In sync Replica (ISR).

Topic Replication

Leader Election

  • At any time, one broker can be a leader for a given partition.

  • Producers can only send data to broker that is leader of the partition.

  • Consumers by default, will read from leader broker for a partition.

Leader Election
  • But as of Kafka 2.4+ it is possible to configure consumers to read from closest replica. This may help with latency and network cost.

Consumers_Topic_Replication

Topic Durability

  • For replication factor of 3, topic data durability can withstand 2 brokers loss. Recommended for production.

  • General formula is for replication factor of N, can still recover data even after permanent loss of N-1 brokers.

Last updated