Video in progress

What is the replication factor, and what do you usually set it to on prod?

The replication factor is how many brokers hold a copy of each partition. On prod it's usually 3: even if one broker goes down, no data is lost and the topic keeps working.

📖 Answer

With replication.factor=3, the orders-0 partition is stored on three different brokers. One is the leader, the others are followers.

kafka-topics.sh --create --topic orders \
  --partitions 6 --replication-factor 3 \
  --bootstrap-server localhost:9092

Why 3 and not 2? With two copies, if you shut down one broker for an upgrade, only a single copy is left, and if that one fails too, the data is gone. With 3 you can take one broker out for maintenance and still survive one more unexpected failure.

In local or test environments you set 1, because there's a single broker. If that setting accidentally makes it to prod, you have a problem. Create topics by hand or with IaC, and don't let the application create them automatically.