Learnitweb

Configure the min.insync.replicas property

What Is min.insync.replicas?

When a Kafka producer sends a message, the broker writes the message to a partition. If that partition is replicated across multiple brokers (replication factor > 1), Kafka defines a set of “in-sync replicas” (ISRs)—these are replicas that are fully caught up with the leader. The min.insync.replicas property defines the minimum number of these ISRs that must acknowledge a message before it is considered successfully written.

Important: If the number of available in-sync replicas falls below this threshold, the producer will fail to write the message, depending on the acks configuration.

Why It Matters in Larger Clusters

In a multi-broker Kafka cluster, your producer’s message delivery latency can increase with more servers—especially if you’ve configured the producer to wait for acknowledgments from all in-sync replicas (acks=all).

By configuring min.insync.replicas, you:

  • Improve resiliency: Prevent successful writes if too few brokers are alive.
  • Protect against data loss: Don’t acknowledge writes unless enough replicas are in sync.
  • Gain control over trade-offs between durability and availability.

Step 1: Create a Topic with min.insync.replicas

You can specify min.insync.replicas when creating a topic using the kafka-topics.sh CLI tool.

bin/kafka-topics.sh \
  --create \
  --topic <topic-name> \
  --partitions <num> \
  --replication-factor <num> \
  --bootstrap-server <broker-address> \
  --config min.insync.replicas=<value>

Let’s say we want to create a topic called in-sync-topic with:

  • 3 partitions
  • A replication factor of 3
  • min.insync.replicas=2
bin/kafka-topics.sh \
  --create \
  --topic in-sync-topic \
  --partitions 3 \
  --replication-factor 3 \
  --bootstrap-server localhost:9092 \
  --config min.insync.replicas=2

This means at least 2 replicas (including the leader) must acknowledge the write for it to be successful.

Step 2: Update min.insync.replicas for an Existing Topic

If you already have a topic and want to change or add the min.insync.replicas setting, use the kafka-configs.sh script.

bin/kafka-configs.sh \
  --bootstrap-server <broker-address> \
  --alter \
  --entity-type topics \
  --entity-name <topic-name> \
  --add-config min.insync.replicas=<value>

Update the topic topic-two to set min.insync.replicas=2:

bin/kafka-configs.sh \
  --bootstrap-server localhost:9092 \
  --alter \
  --entity-type topics \
  --entity-name topic-two \
  --add-config min.insync.replicas=2

Verifying Configuration

To verify whether the new setting was applied:

bin/kafka-topics.sh \
  --describe \
  --topic topic-two \
  --bootstrap-server localhost:9092

Look for:

Configs: min.insync.replicas=2