liveBook · Manning

Replication factor

As explained in Kafka Streams in Action, Second Edition

A replication factor is the configured number of broker replicas maintained for each Kafka topic partition.

A replication factor configures how many broker replicas Kafka maintains for each topic partition. Replication keeps records available if a broker fails: one broker leads, while follower brokers copy the leader’s log. section 2.9.1

Use the factor to match the deployment context:

  • A factor of 3 provides one leader and two followers; caught-up followers become in-sync replicas (ISR) and can be elected leader if the current leader fails. section 2.9.1
  • A local testing broker can use replication factor 1 because no additional broker is available or required for the exercise. section 2.5.1
  • Followers that fall behind the configured lag limit are removed from the ISR list until they catch up. section 2.9.1
kafka-topics --create --topic first-topic\
 --bootstrap-server localhost:9092\        #1
 --replication-factor 1\       #2
 --partitions 1      #3

The topic-creation command makes the setting explicit: replication factor 1 creates a single replica for the local broker, alongside one partition. section 2.5.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains leader-follower replication, ISR membership, follower lag, and leader election.
Examples
Uses a one-partition local Docker topic with replication factor 1 and contrasts it with the recommended factor 3.
What you can do after
Operate/configure Kafka topics with replication suited to local testing or broker-failure availability.
How it connects
Connects topic partitions with leader brokers, follower brokers, in-sync replicas, producer acknowledgments, and minimum ISR.

Also explained in

Compare how 4 books explain replication factor →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.