min.insync.replicas in Kafka: The Safety Net That Decides When a Write Is Truly Safe
One small setting controls how many copies of your data must be healthy before Kafka will accept a write. This guide explains what it means, how it works with replication and acknowledgements, and how to choose the right value.
Imagine you are posting an important legal document and you want to be sure it is never lost. You make three photocopies and store them in three separate offices. Now someone asks: when should you tell the client, “Your document is safely stored”? If you say it after storing just one copy, a fire in that single office destroys everything. If you insist on all three offices confirming, then one office being closed for a holiday stops the whole process. The sensible middle path is to say, “I will confirm once at least two offices have stored a copy, and I will refuse to accept the document at all if fewer than two offices are open.”
That rule, “at least two copies must be safe before I confirm, and I refuse the job if I cannot guarantee that”, is exactly what the Kafka setting min.insync.replicas expresses. It is a small number with a big impact on whether your data survives failures, and whether your applications keep running when machines break. In this tutorial we will build up from the basics, using simple language and everyday analogies, until you can confidently choose and operate this setting in production.
1Kafka Basics You Need First
A quick refresher on the pieces that this setting protects.
Apache Kafka is a platform for storing and moving streams of events. An event is a small record of something that happened, such as a payment, a click, or a sensor reading. Kafka keeps these events on disk, in order, so that many applications can read them later.
Broker
A Kafka server. A Kafka cluster is made of several brokers working together.
Topic
A named category of events, such as “payments”. Think of it as a labelled folder of related messages.
Partition
A topic is divided into partitions, and each partition is an ordered log stored on disk.
Producer
An application that writes events into Kafka.
Consumer
An application that reads events from Kafka.
Offset
The position number of an event inside a partition.
Why data safety is a real question
Kafka runs on ordinary servers, and ordinary servers fail. Disks break, machines lose power, networks drop, and software crashes. If each partition lived on exactly one broker, then any failure of that broker would make the data unavailable, or lose it entirely. Kafka’s answer is replication: keeping several copies of each partition on different brokers. But copies alone are not enough. We also need rules about when a write counts as safely stored, and that is where min.insync.replicas enters the story.
Think of a bank vault system where every important ledger is kept in several branches. Having multiple branches is only useful if the rules say when a transaction is officially recorded. Otherwise a clerk might tell you “done” while only one branch, the one about to be flooded, has the entry.
2Replication: Leaders, Followers, and Copies
To understand the setting, first understand how Kafka copies data.
Each partition has a number of copies, called replicas. The number of copies is set by the replication factor. A replication factor of three means every partition exists on three different brokers. One of those replicas is chosen as the leader, and the others are followers.
Leader
The one replica that handles all writes from producers and normally all reads from consumers for that partition.
Follower
A replica that continuously fetches new data from the leader and appends it to its own copy of the log.
Replication Factor
The total number of copies of each partition, including the leader. It is chosen when the topic is created.
flowchart LR
P[Producer] --> L[Leader replica on Broker 1]
L --> F1[Follower replica on Broker 2]
L --> F2[Follower replica on Broker 3]
C[Consumer] --> L
How followers copy data
Followers work like consumers. They repeatedly ask the leader, “Do you have anything new for me?” The leader sends the latest records, and the follower appends them to its own log and asks again. This means followers are always slightly behind the leader, by a tiny amount if everything is healthy, and by a lot if the follower is slow or disconnected.
What happens when a leader fails
If the broker holding the leader dies, Kafka promotes one of the followers to become the new leader, and producers and consumers continue with it. This is why replication provides high availability. But there is a catch: a follower that was far behind at the moment of failure does not have all the data. Promoting such a follower could silently lose records that the old leader had accepted. Kafka needs a way to know which followers are safe to promote, and that leads us to the next idea.
A newspaper editor dictates stories to several scribes. If the editor suddenly leaves, one scribe takes over. But a scribe who missed the last three paragraphs is a poor replacement. The team needs to know which scribes are fully up to date before choosing a successor.
3The In-Sync Replica Set
The “ISR” is the list of replicas that are caught up and trusted.
For every partition, Kafka maintains a set called the in-sync replicas, or ISR. It always contains the leader, and it also contains every follower that is sufficiently caught up with the leader. Only members of this set are considered safe to take over as leader, and only members of this set count when we ask “is this write safely stored?”
What does “in sync” mean?
A follower is in sync if it has recently kept up with the leader. More precisely, the follower must have contacted the leader and caught up to its latest data within a time limit set by the broker setting replica.lag.time.max.ms, which by default is thirty seconds. If a follower goes silent or falls too far behind for longer than that, the leader removes it from the ISR. When the follower recovers and catches up again, it is added back.
sequenceDiagram
participant L as Leader
participant F1 as Follower 1
participant F2 as Follower 2
L->>F1: New records
F1-->>L: Fetch again, caught up
L->>F2: New records
Note over F2: Follower 2 stalls, disk is slow
L->>L: No catch up within the time limit
L->>L: Remove Follower 2 from the ISR
F2-->>L: Later, catches up again
L->>L: Add Follower 2 back to the ISR
“The replication factor tells me how many safe copies I have.” Not exactly. The replication factor is the number of copies that should exist. The ISR size is the number of copies that are healthy right now, and it can be much smaller than the replication factor during problems.
A relay team may have five runners on paper, but only those who are awake, warmed up, and at the track are “in sync”. The coach can only send those on the field. The in-sync set is the list of runners actually ready right now.
4So, What Is min.insync.replicas?
The definition in one sentence, followed by what it really means.
The setting min.insync.replicas defines the minimum size the ISR must have for Kafka to accept writes that demand full acknowledgement. The count includes the leader itself. So a value of two means the leader plus at least one follower must be in sync.
A Floor, Not a Target
It is the lowest acceptable ISR size. The ISR can be larger, and usually is. The setting only decides when Kafka must say no.
Set Per Topic or Per Broker
It exists as a broker-wide default and as a topic-level override. The topic-level value wins when both are set.
One
The broker default is one, which means the leader alone is enough. That is convenient but offers no protection against losing the leader.
Applies with acks set to all
The check is enforced only for producers that ask for acknowledgement from all in-sync replicas. Otherwise it is not consulted.
The two jobs it does
It protects durability
By requiring several healthy copies, it ensures that every acknowledged write already exists on more than one broker, so a single failure cannot erase it.
It chooses safety over availability when in doubt
If too few copies are healthy, Kafka refuses new acknowledged writes instead of pretending they are safe. That refusal is the price of the guarantee.
A cautious courier company promises that no parcel is accepted unless at least two of its three warehouses are open to store a copy of the manifest. On days when two warehouses are closed, it politely turns customers away rather than risk losing parcels. Customers are inconvenienced, but nothing is lost.
The name is slightly misleading. It does not set how many replicas must be in sync in general. It sets the minimum required for a write to be accepted under full acknowledgement. Reading is not affected by it, as we will see later.
5Working Together with Producer Acknowledgements
The setting only makes sense alongside the producer’s acks choice.
When a producer sends a record, it chooses how much confirmation it wants back from Kafka. This choice is called acks, short for acknowledgements, and it has three levels.
| acks Setting | Producer Waits For | Data Loss Risk | Does min.insync.replicas Apply? |
|---|---|---|---|
| 0 | Nothing at all. The producer does not wait for any reply. | Highest. Records may vanish without the producer knowing. | No |
| 1 | The leader only. | Medium. If the leader dies before followers copy the record, it is lost. | No |
| all | The leader and every replica currently in the ISR. | Lowest, when combined with a sensible minimum. | Yes |
Setting min.insync.replicas to two or three on a topic while the producers use acks of one. The setting is then never checked, and the team wrongly believes their data is protected. The two settings must be used together.
What acks all really waits for
Here is a subtle point that surprises many people. With acks set to all, the leader waits until every replica currently in the ISR has copied the record, not merely until the minimum number of replicas has. The minimum acts as a gate before this happens: if the ISR is smaller than the minimum, the leader rejects the write immediately. If the ISR is at least the minimum, the leader accepts the write and waits for all current ISR members.
sequenceDiagram
participant P as Producer with acks all
participant L as Leader
participant F1 as Follower 1
participant F2 as Follower 2
P->>L: Send record
L->>L: Is the ISR size at least the minimum
L->>L: Append record to the leader log
L->>F1: Replicate
L->>F2: Replicate
F1-->>L: Copied
F2-->>L: Copied
L-->>P: Acknowledge success
A notary will only start certifying a document if at least two witnesses are present in the room. Once they begin, the notary waits until every witness who is present has signed before handing over the certificate. The “two witnesses minimum” is the entry rule, and “everyone present signs” is the completion rule.
Recent Kafka client versions default to acks of all and turn on the idempotent producer, which makes safe settings the default for new applications. Older clients and some libraries still default to weaker values, so always verify what your producers actually use.
6What Happens When the ISR Gets Too Small
The moment the safety net tightens is the moment producers notice it.
Suppose a topic has a replication factor of three and a minimum of two. Normally the ISR has three members. If one broker fails, the ISR shrinks to two, which still meets the minimum, so everything continues. If a second broker fails or falls behind, the ISR shrinks to one, which is below the minimum. From that moment, the leader refuses writes that demand full acknowledgement.
flowchart TD
A[Producer sends with acks all] --> B{Is ISR size at least the minimum}
B -->|Yes| C[Leader appends and waits for the ISR]
C --> D[Success returned to producer]
B -->|No| E[Leader rejects the write]
E --> F[Producer receives a not enough replicas error]
F --> G[Producer retries until it succeeds or times out]
The two error types
NotEnoughReplicas
The leader saw that the ISR was already too small before writing, so it rejected the record without appending it.
NotEnoughReplicasAfterAppend
The leader appended the record, but the ISR shrank below the minimum before the required acknowledgements arrived. The record may exist on the leader even though the producer was told it failed.
Both errors are retriable, which means a well-configured producer automatically tries again for a while. If the problem clears quickly, for example a follower catches up within seconds, the retry succeeds and the application never notices. If the problem persists longer than the producer’s delivery timeout, the send finally fails and the application receives an error.
What still works
It is important to understand that reads keep working. Consumers can continue reading everything that was already safely committed, because the minimum only restricts new acknowledged writes. Producers using weaker acks values also keep writing, though without protection. Only the combination of acks set to all and a too-small ISR is blocked.
Seeing not-enough-replicas errors feels alarming, but it means the system is refusing to make a promise it cannot keep. The alternative would be to accept writes that would be lost if one more machine failed, and to discover it only afterwards.
A lift with a safety inspection rule refuses to move if fewer than two safety brakes are working. Passengers are annoyed at the delay, but they are alive to complain about it.
7The Three Numbers: Replication Factor, Minimum, and acks
Durability and availability come from how these three settings fit together.
Replication Factor
How many copies exist in total. It sets the maximum possible protection.
min.insync.replicas
How many copies must be healthy for a write to be accepted. It sets the required protection.
acks
How much confirmation the producer demands. It decides whether the required protection is enforced at all.
Two simple formulas
With acks set to all, two easy rules describe the behaviour, assuming all replicas are healthy at the start.
Write availability
Producers can keep writing as long as at least the minimum number of replicas remain in sync. So the number of replica failures you can tolerate while still accepting writes is the replication factor minus the minimum.
Durability of acknowledged data
Every acknowledged write exists on at least as many replicas as the minimum. So acknowledged data survives the loss of up to the minimum minus one replicas.
| Replication Factor | min.insync.replicas | Failures Tolerated While Writing | Acknowledged Data Survives Losing | Verdict |
|---|---|---|---|---|
| 1 | 1 | 0 | 0 replicas | No redundancy at all. Suitable only for disposable data. |
| 2 | 1 | 1 | 0 replicas | Writes continue after one failure, but an acknowledged record may exist only on the leader. |
| 2 | 2 | 0 | 1 replica | Safe, but any single broker outage blocks writes. |
| 3 | 1 | 2 | 0 replicas | Looks redundant, but the guarantee is as weak as having one copy. |
| 3 | 2 | 1 | 1 replica | The widely recommended balance for important data. |
| 3 | 3 | 0 | 2 replicas | Very safe, but any single failure blocks writes. |
| 5 | 3 | 2 | 2 replicas | Excellent for critical data that must survive multiple failures. |
A replication factor of three with a minimum of one looks safe on a diagram, but a producer with acks of all is satisfied when the leader alone is in the ISR. If the two followers were lagging and the leader then fails, acknowledged data can be lost. The number of copies only matters if the minimum forces them to be healthy.
If min.insync.replicas is larger than the replication factor, the ISR can never be big enough, and every write with acks of all fails permanently. Always keep the minimum less than or equal to the replication factor, and in practice strictly less, to leave room for one failure.
8Choosing the Right Value
There is no universal answer, but there is a sensible default and a clear way of thinking.
The classic recommendation
For most production topics that carry important data, the widely used combination is a replication factor of three, a minimum of two, and producers using acks of all. This lets the cluster survive the loss of one broker without losing acknowledged data and without stopping writers, and it still refuses writes when only one healthy copy remains.
flowchart TD
A[How valuable is the data] --> B{Can you afford to lose some records}
B -->|Yes, logs or metrics| C[Replication factor 2 or 3 with minimum 1]
B -->|No, business events| D{Must writes survive one broker outage}
D -->|Yes| E[Replication factor 3 with minimum 2]
D -->|Writes may stop during outages| F[Replication factor 3 with minimum 3 or 2 on 2]
E --> G{Must data survive two simultaneous failures}
G -->|Yes| H[Replication factor 5 with minimum 3]
G -->|No| I[Keep replication factor 3 with minimum 2]
Questions to ask yourself
What does losing one record cost?
Money movements, orders, and audit trails justify strong settings. Debug logs and click counters may not.
Can the producer wait or buffer?
If producers can hold data for a while during a rare outage, strictness is cheap. If they cannot, for example a high-speed sensor gateway with tiny buffers, blocked writes can cause data loss at the source.
How many brokers and zones do you have?
A replication factor of three needs at least three brokers, and ideally three separate zones. The minimum should reflect how many failures you want to survive.
How often do you do maintenance?
If you restart brokers frequently, a minimum equal to the replication factor will block writes every single time. Leave headroom for planned work.
Is availability or durability more important?
This is the deep trade-off behind the whole setting. A higher minimum leans toward durability, and a lower one leans toward availability.
Advantages of a Higher Minimum
- Acknowledged data exists on more brokers
- Stronger protection against simultaneous failures
- Prevents silent acceptance of writes that only the leader holds
- Clear, honest failure instead of hidden data loss
Trade-offs of a Higher Minimum
- Fewer broker failures tolerated while writing
- Writes block sooner during outages or maintenance
- Producers need buffering and retry design
- Needs more brokers and more disk for more copies
9Consistency vs Availability and Unclean Leader Election
A sister setting decides what happens when even the ISR is gone.
Sometimes failures are so bad that every replica in the ISR is lost, and only out-of-sync followers remain, holding an incomplete copy of the data. Kafka must choose between two unpleasant options: make the partition unavailable until an in-sync replica returns, or promote an out-of-sync replica and accept that some acknowledged records will be lost. The broker setting unclean.leader.election.enable controls this choice.
| Setting Value | What Kafka Does | Consequence |
|---|---|---|
| false, the default | Refuses to promote an out-of-sync replica. The partition stays offline until an ISR member returns. | No silent data loss, but temporary unavailability |
| true | Promotes an out-of-sync replica so the partition returns quickly. | Possible loss of acknowledged records, and diverging histories |
How the two settings complement each other
Think of the minimum as guarding the front door, controlling when writes are accepted, and unclean leader election as guarding the back door, controlling who may take over after a disaster. For strong durability you need both closed: a sensible minimum together with unclean election disabled. Leaving unclean election on makes the minimum’s protection partially pointless, since a lagging replica may become leader and overwrite the true history.
flowchart LR
A[Leader and ISR members fail] --> B{Unclean election allowed}
B -->|No| C[Partition offline until an ISR member returns]
B -->|Yes| D[Out of sync replica becomes leader]
C --> E[No acknowledged data lost, temporary downtime]
D --> F[Service returns fast, some acknowledged data lost]
If every fully informed manager is unavailable, a company can either wait until one returns, or appoint an intern who missed the last few weeks of meetings. Waiting is slow and safe. Appointing the intern is fast, but decisions may contradict earlier promises.
For topics where data matters, keep unclean leader election off. For disposable, high-volume telemetry where being available always matters more than being complete, turning it on for that specific topic can be a conscious and documented choice.
10The High Watermark: What Consumers Can See
Reading has its own safety rule, and it works hand in hand with the ISR.
Kafka does not let consumers read every record the leader has appended. It only exposes records up to a marker called the high watermark, which is the highest offset that has been copied to all replicas currently in the ISR. A record beyond the high watermark exists on the leader but is not yet considered committed, so consumers cannot see it yet.
flowchart LR
A[Records 0 to 7 on all ISR members] --> B[High watermark]
B --> C[Records 8 to 10 only on the leader]
A --> D[Visible to consumers]
C --> E[Not visible yet]
Why this matters
This rule guarantees that consumers never see a record that could vanish after a leader change. Suppose consumers could read records held only by the leader, and then the leader crashed. A new leader would not have those records, and consumers would have seen data that never officially existed. The high watermark prevents this.
The relationship with the minimum
When the ISR shrinks, the high watermark is calculated over fewer replicas, so it can advance even though a lagging follower has been removed. The minimum then ensures that this smaller group is still large enough to be meaningful. Without a minimum, the high watermark could advance based on the leader alone, meaning “committed” would merely mean “written on one machine”.
The minimum restricts writers, not readers. Readers are protected by the high watermark. During an ISR shortage, consumers continue to read committed data normally, and only writers using full acknowledgement are turned away.
11Why Replicas Fall Out of the ISR
Understanding the causes helps you prevent a great many not-enough-replicas alarms.
Broker crash or restart
A stopped broker cannot fetch, so its replicas leave the ISR until they restart and catch up.
Slow disks
A follower with a struggling disk cannot write as fast as the leader sends, so it falls behind.
Network trouble
Packet loss, congestion, or a partition between brokers breaks the follower’s fetch loop.
Long garbage collection pauses
A broker that freezes for many seconds appears dead to its peers and drops from the ISR.
Overloaded brokers
Heavy traffic, hot partitions, or too many partitions on one broker can starve follower fetching.
Bursts and catch-up storms
A sudden spike in incoming data can outrun a follower briefly, and a broker recovering from downtime must copy a large backlog before rejoining.
Throttled reassignments
Partition moves and replica rebuilds consume bandwidth and can slow ordinary replication.
Misconfigured lag limits
A lag time limit set too strictly makes healthy but briefly slow followers drop out repeatedly.
Flapping: the sneaky pattern
Sometimes a follower keeps dropping out and rejoining, over and over. This pattern, called ISR flapping, produces intermittent not-enough-replicas errors that appear and disappear in minutes and are notoriously hard to catch. It usually points to a borderline resource problem such as a busy disk or a saturated network link on one broker, not to a dramatic failure. Watching the rate of ISR shrinks and expansions is the best way to spot it.
Imagine a sports team where one player keeps stepping off the field and returning every few minutes because of a nagging cramp. The team never fully collapses, yet plays are constantly disrupted. The real solution is to treat the cramp, not to keep re-adding the player.
12Failure Scenarios Step by Step
Let us watch what happens with a replication factor of three and a minimum of two.
Everything healthy
The ISR has three members. Writes with acks of all succeed after all three have copied. Any single machine could die without losing acknowledged data.
One follower fails
After the lag time limit, the leader drops it. The ISR has two members, which meets the minimum. Writes continue, now confirmed by two replicas. The cluster is running with reduced safety, and monitoring should alert operators.
The leader fails while two remain
The remaining in-sync follower becomes the new leader with all committed data. The ISR is now one member, which is below the minimum. Writes with acks of all are rejected, while reads continue.
A failed broker returns
It fetches the missed data from the leader. Once caught up, it rejoins the ISR, which grows back to two and satisfies the minimum. Blocked producers retry successfully.
The last broker returns and the ISR is whole
All three replicas are in sync again, and the cluster is back to full protection.
flowchart LR
S1[ISR of 3 all healthy] -->|one broker fails| S2[ISR of 2 writes continue]
S2 -->|second broker fails| S3[ISR of 1 writes rejected reads continue]
S3 -->|one broker returns and catches up| S2
S2 -->|other broker returns| S1
A scenario that goes wrong when the minimum is one
Now consider the same setup, but with the minimum left at the default of one. Two followers fall behind because of a network problem, and the ISR quietly shrinks to just the leader. Producers with acks of all keep getting “success”, because the leader alone satisfies the rule. Then the leader’s disk fails. The followers have not seen the last several minutes of data, and if unclean election is on they may take over, or if it is off the partition stays offline. In either case, records that were acknowledged as safe are gone or trapped.
With a minimum of one, nothing appears wrong while the ISR shrinks. There are no errors, no failed sends, and no alarms unless you deliberately monitor the ISR size. The danger is invisible until the moment it costs you data.
13Maintenance, Rolling Restarts, and Zones
Planned work is where careless settings hurt the most.
Rolling restarts
Upgrading or patching a Kafka cluster means restarting brokers one at a time. With a replication factor of three and a minimum of two, restarting a single broker temporarily reduces the ISR of affected partitions to two, which is still acceptable. The essential rule is to restart only one broker at a time, and to wait until it has fully caught up and rejoined the ISR of all its partitions before moving to the next. Restarting a second broker too early would drop some partitions below the minimum and stall producers.
Check the cluster is healthy first
Confirm that no partitions are under-replicated or below the minimum before touching any broker.
Shut down one broker gracefully
A controlled shutdown moves leadership away cleanly, so clients see a short, orderly switch rather than an abrupt failure.
Perform the maintenance and restart
Bring the broker back up with the new version or configuration.
Wait for full recovery
Do not proceed until every partition on that broker is back in the ISR and no partitions are under-replicated.
Repeat for the next broker
Continue one at a time, watching producer error rates throughout.
With a replication factor of three and a minimum of three, even a single graceful restart blocks writes for every partition hosted on that broker. Teams that choose this setting must accept planned write outages, or must pause producers during maintenance.
Spreading replicas across zones
Replicas of the same partition should live in different failure domains, such as separate racks or cloud availability zones. Kafka supports this through rack awareness, where each broker is labelled with its location, and replica placement spreads copies across locations. With a replication factor of three and three zones, each zone holds one copy, and a minimum of two means the loss of an entire zone leaves writes running.
flowchart TD
P[Partition with 3 replicas]
P --> Z1[Zone A holds replica 1]
P --> Z2[Zone B holds replica 2]
P --> Z3[Zone C holds replica 3]
Z1 --> R[Minimum of 2 means one whole zone can fail and writes continue]
Z2 --> R
Z3 --> R
With only two zones and three replicas, one zone must hold two copies. Losing that zone removes two replicas at once, dropping the ISR below the minimum of two. To truly survive a zone loss with these settings, you need at least three zones.
14Where and How the Setting Is Applied
Knowing where the value lives prevents unpleasant surprises.
Broker Default
A cluster-wide value applied to any topic that does not define its own. It is the safety net for topics created without much thought.
Topic Override
A value set for one specific topic, which takes priority over the broker default. It can be provided at creation or changed later.
Per-Producer Override
Producers cannot choose their own minimum. They only choose acks. The minimum is always a server-side decision.
Practical guidance
Set a sensible broker default, such as two on a cluster where topics normally have a replication factor of three, so that newly created topics are protected automatically. Then override it at topic level when a particular topic has different needs. The topic-level value can be changed on a live topic without restarting brokers, but changing it takes effect immediately, so plan it as you would any production change.
Internal topics
Kafka keeps some internal topics for its own operation, such as the topic that stores consumer group offsets and the topic that stores transaction state. These have their own replication and minimum settings, controlled by broker configuration. The transaction state log, for example, has its own minimum with a default of two. If internal topics have weak settings, then the reliability of offsets and transactions is weak no matter how carefully your data topics are configured, so check them in every new cluster, especially small development-style clusters that are later promoted to production.
On a cluster with fewer brokers than the desired replication factor, a topic cannot be created with that factor, and internal topics may be created with too few copies. A cluster that started life as a single-broker test rig can carry weak internal topics into production. Audit them.
Governance
Because the minimum is a server-side value, anyone with permission to alter topic configurations can weaken it, for example dropping it from two to one to silence errors during an incident, and forgetting to restore it. Restrict who may alter topic settings, review changes, and keep topic configurations in version-controlled definitions so that drift is visible.
15Performance and Latency Considerations
Does a higher minimum make Kafka slower? The answer is more nuanced than most people expect.
The minimum itself is only a check, and it costs almost nothing. What costs time is the acknowledgement level. With acks of all, the leader waits for every replica in the ISR to copy the record, so the write is as slow as the slowest in-sync follower. Raising the minimum does not add waiting by itself, because the leader was already waiting for all ISR members. But designing for more copies, for instance a replication factor of five, means more followers to wait for, and more network and disk traffic.
| Choice | Effect on Write Latency | Effect on Durability | Effect on Resource Use |
|---|---|---|---|
| acks of 1 instead of all | Lower, waits only for the leader | Weaker | Same replication traffic |
| Higher replication factor | Higher, more followers to wait for | Stronger | More disk, network, and CPU |
| Higher minimum | No direct increase | Stronger | No direct increase |
| Cross-zone replicas | Higher, because of network distance | Much stronger against zone loss | More cross-zone network cost |
| Batching and compression at the producer | Slightly higher per record, much better throughput | No change | Less network and disk per record |
Slow followers slow everyone
Because acks of all waits for every current ISR member, one slow but not-yet-removed follower slows every write to that partition until the lag limit removes it. This is why healthy disks and stable networks on all brokers matter, and why tuning the lag limit is a balance. A short limit removes slow followers quickly but risks flapping. A long limit tolerates hiccups but lets slow followers drag out latency.
A group photo requires everyone present to smile at once. The photo is as slow as the slowest person getting ready. Requiring “at least two people present” does not slow the photo, but having twelve people in the picture makes it harder to get everyone ready.
Teams often lower acks to gain speed without measuring. Frequently, adjusting batching, compression, and linger time recovers most of the throughput while keeping full acknowledgement. Test with realistic loads before weakening durability.
16Retries, Idempotence, and Duplicates
When writes are rejected, producers retry. Retrying safely needs a few extra ideas.
When the ISR falls below the minimum, a producer receives a retriable error. Kafka producers retry automatically for as long as their delivery timeout allows, which by default is two minutes. During this time the application usually sees only a delay, not an error, and if the ISR recovers quickly the write goes through.
The duplicate problem
Retries can create duplicates. Recall the error that means the record was appended to the leader but the ISR shrank before acknowledgements arrived. The producer is told the write failed and sends it again, yet the first copy may already exist in the log. Without protection, the partition now contains the record twice.
sequenceDiagram
participant P as Producer
participant L as Leader
P->>L: Send record 42
L->>L: Append record 42
L->>L: ISR shrinks below the minimum
L-->>P: Error, not enough replicas after append
P->>L: Retry record 42
L->>L: Detect the same sequence number if idempotence is on
L-->>P: Acknowledge without a second copy
The idempotent producer
Enabling idempotence gives every producer an identity and every record a sequence number per partition. The broker uses these to recognise a retried record it has already stored, and discards the duplicate while still acknowledging success. Recent Kafka clients enable this by default, and it requires acks of all, which fits perfectly with the minimum in-sync replica design.
Delivery Timeout
The total time a producer keeps trying to deliver a record. Set it long enough to survive a typical broker restart, but short enough that stuck applications fail visibly.
Idempotence
Prevents duplicates caused by retries within a producer session. Should be on for nearly every producer.
Buffer Memory
Determines how much unsent data a producer can hold while waiting. Larger buffers ride out short blockages, but memory is finite.
If a topic can block for minutes, what will your application do meanwhile? Options include buffering, applying backpressure to upstream callers, or writing to a local fallback. An application that simply crashes on the first send error turns a recoverable cluster event into an outage of its own.
17Monitoring and Alerting
The whole design only pays off if you notice the ISR shrinking before it becomes a crisis.
| Signal | Where It Comes From | What It Tells You |
|---|---|---|
| Under-replicated partitions | Broker metrics | Partitions with fewer in-sync replicas than the replication factor. The earliest warning that redundancy is reduced. |
| Partitions below the minimum | Broker metrics | Partitions where writes with full acknowledgement are being rejected right now. This should page someone. |
| Partitions exactly at the minimum | Broker metrics | Partitions one failure away from blocking. A valuable early alert. |
| ISR shrink and expand rates | Broker metrics | Frequent changes indicate flapping and borderline resources. |
| Offline partitions | Controller metrics | Partitions with no leader at all. Reads and writes both fail. |
| Producer error and retry rates | Client metrics | How much applications feel the problem. |
| Follower lag and replica fetch rates | Broker metrics | Which followers struggle before they leave the ISR. |
| Disk latency and network saturation | Host metrics | The usual root causes of slow followers. |
Alert design that works
Warn on any under-replicated partition that persists
Short blips are normal, but a partition that stays under-replicated for several minutes needs attention.
Page on partitions below the minimum
This is the state in which producers are being rejected. It is business-impacting and should be urgent.
Alert on partitions at the minimum
Being at the minimum means there is no safety margin left, so one more failure will block writes.
Track ISR churn over time
Rising shrink and expand rates reveal slow degradation long before an outage.
Audit topic configurations regularly
Scan all topics for a minimum of one or for a minimum above the replication factor, and for producers using weak acknowledgement.
The best monitoring includes checks for wrong settings, not only for failing hardware. A topic quietly created with a replication factor of one, or a minimum silently reduced during an incident, is a hidden risk that no runtime metric will reveal.
18Design Patterns and Anti-Patterns
A few habits protect your data, and a few quietly endanger it.
Helpful patterns
Safe defaults at the broker
Set a broker-wide default of a minimum of two so that any topic created without special care gets sensible protection.
Three settings as a package
Treat replication factor, minimum, and acks as a single decision, documented together for each topic.
Tiered topic classes
Define categories such as critical, standard, and disposable, each with pre-agreed settings, so teams choose a class instead of guessing numbers.
Headroom for maintenance
Choose a minimum at least one below the replication factor so planned restarts do not stop writers.
Anti-patterns to avoid
Problem
The team sets the minimum to two but leaves producers on acks of one, or on an old client default that is weaker than all.
Why It’s Harmful
The minimum is only enforced for full acknowledgement. Nothing is checked, and the team wrongly believes durable copies exist before each acknowledgement.
Correct Approach
Set acks to all for every producer writing important data, enable idempotence, and audit client configurations across services.
Problem
Leaving the minimum at the default of one on a topic with three replicas, because “we have three copies”.
Why It’s Harmful
Acknowledgements can be given when only the leader is in the ISR, so acknowledged data can vanish with the leader’s disk, and no alarm ever fired.
Correct Approach
Use a minimum of two with a replication factor of three for important topics, and monitor partitions at or below the minimum.
Problem
Setting the minimum equal to the replication factor to “maximise safety”.
Why It’s Harmful
Any single broker outage or restart blocks writes on all partitions it hosts. Routine maintenance becomes an outage, and teams end up disabling the setting during incidents.
Correct Approach
Keep the minimum at least one below the replication factor unless planned write outages are acceptable, or raise the replication factor instead.
Problem
Lowering the minimum during an incident to stop producer errors, and never restoring it.
Why It’s Harmful
The errors disappear, but so does the protection. The cluster runs for months with hidden risk, and the underlying failure remains unfixed.
Correct Approach
Fix the reason the ISR shrank. If a temporary change is truly needed, record it, alert on it, and restore it as part of the incident closure checklist.
Problem
Enabling unclean leader election on important topics to reduce downtime.
Why It’s Harmful
It reopens the back door that the minimum closes. An out-of-sync replica can become leader and erase acknowledged history.
Correct Approach
Keep it disabled for data that matters, and improve availability through more replicas, zones, and faster recovery instead.
Problem
Placing all three replicas on brokers in the same rack or zone.
Why It’s Harmful
A single rack or zone failure removes every copy at once, making the replication factor useless for that scenario and pushing the ISR straight to zero.
Correct Approach
Enable rack awareness and spread replicas across at least three failure domains.
19Real-World Examples
Different kinds of data justify different combinations of settings.
Payments and financial ledgers
Every event represents money. Use a replication factor of three or five, a minimum of two or three, acks of all, idempotent producers, and unclean election disabled. The occasional short write pause during failures is a price worth paying.
E-commerce orders
Orders must not vanish, but checkout should keep working during a single broker failure. A replication factor of three with a minimum of two gives both, provided the application handles brief retries gracefully.
Application logs and debug traces
Losing a few lines during a crash is acceptable, and availability matters more. A replication factor of two or three with a minimum of one, and possibly acks of one, keeps ingestion fast and continuous.
IoT sensor telemetry
Enormous volumes and modest per-record value. Devices often cannot buffer much, so blocking writes is costly. A lenient minimum with sensible replication is often chosen, with downstream systems tolerating small gaps.
Event sourcing and audit trails
The log itself is the source of truth and must never lose committed events. Use strong settings, spread replicas across zones, retain data long enough, and monitor at-minimum partitions carefully.
Change data capture pipelines
Database changes flowing into Kafka must be complete, because downstream copies depend on every change. Use a minimum of two with acks of all, and keep the connector’s producer settings aligned with the topic’s requirements.
Internal system topics
Offsets and transaction state deserve strong settings in every environment, since losing them damages every application built on top.
20A Troubleshooting Journey
Let us follow a realistic incident from first alarm to lasting fix.
A ride-booking company runs a “bookings” topic with a replication factor of three and a minimum of two. At peak hour, the booking service starts logging errors saying there are not enough replicas, and customers see delayed confirmations.
Confirm what the error means
Not-enough-replicas means the ISR for some partitions has fallen below two. This is not an application bug. The cluster is refusing writes it cannot protect.
Find which partitions are affected
Broker metrics show partitions below the minimum, all with a leader on one broker and a follower on another broker that is having trouble. Not all partitions are affected, so this is not a total cluster failure.
Look for the common broker
One broker appears in every affected partition’s replica list. Its disk write latency graph has been climbing for an hour, and its follower fetch lag is high.
Understand the chain of events
The slow disk made the broker’s followers fall behind and get removed from the ISR. Another broker had been restarted earlier for patching, and its replicas were still catching up. Two replicas were missing at once, dropping the ISR to one.
Fix the root cause, not the setting
The team moves traffic away from the sick broker, replaces its failing disk, and waits for the earlier restarted broker to finish catching up. The ISR grows back to two, and blocked producers succeed on their next retry. Nobody lowers the minimum.
Prevent a repeat
They add alerts for partitions at the minimum and for rising disk latency, adopt a rule that patching waits until the cluster shows no under-replicated partitions, and improve the booking service’s buffering so short blocks stay invisible to customers.
The lesson is that not-enough-replicas errors are a symptom of a real cluster problem, and the healthy response is to fix that problem, not to loosen the safety rule that revealed it.
21Frequently Asked Questions
It sets the minimum number of replicas, including the leader, that must be in the in-sync set for Kafka to accept writes from producers using acks of all. If the in-sync set is smaller, those writes are rejected.
No. The check is enforced only for full acknowledgement. Producers with weaker acknowledgement are not stopped by it, but they also do not receive its protection.
The broker default is one, meaning the leader alone is enough. For important data, this is usually too weak, and many teams raise the broker default to two.
No. The replication factor is how many copies should exist. The minimum is how many of them must be healthy for a write to be accepted. The minimum must not exceed the replication factor.
A replication factor of three, a minimum of two, and producers with acks of all and idempotence enabled. This tolerates one broker failure for both durability and write availability.
The in-sync set for some partition has dropped below the minimum, usually because of a broker outage, restart, slow disk, or network issue. Investigate why followers left the in-sync set instead of lowering the setting.
Yes, as long as the partition has a leader. The minimum restricts only writes with full acknowledgement. Consumers keep reading committed data.
Not directly, because it is a threshold check. Latency is driven by acks of all waiting for every in-sync replica, and by the replication factor and network distance between replicas.
The minimum decides when writes are accepted. Unclean leader election decides whether an out-of-sync replica may become leader when no in-sync replica remains. For strong durability, keep a sensible minimum and leave unclean election off.
No. Producers choose only acks. The minimum is a broker or topic setting controlled by administrators.
Possibly, particularly with the error where the record was appended before the ISR shrank. Enabling the idempotent producer prevents such duplicates within a producer session.
It can be changed without restarting brokers, and it takes effect immediately. Raising it may instantly block writes on partitions whose ISR is smaller than the new value, so check the cluster’s health first.
Three zones, with one replica in each, so that the loss of a whole zone leaves two replicas and writes continue. With only two zones, one zone holds two copies and its loss breaks the minimum.
Audit topic settings for a minimum of one on important topics, a minimum above the replication factor, a replication factor of one, and producers with weak acknowledgement. Combine this with metrics on under-replicated and at-minimum partitions.
Treat it as a last resort and a temporary measure. The errors mean the cluster lost redundancy. Fix the underlying problem, and if you must lower the value, record it and restore it as soon as the ISR is healthy.
22Summary and Key Takeaways
The setting min.insync.replicas is Kafka’s way of saying that a write is only safe when enough healthy copies exist. It counts the leader and the followers that are currently caught up, and it is enforced only when producers ask for full acknowledgement. When the in-sync set is too small, Kafka refuses new writes rather than promise something it cannot guarantee, and readers keep reading committed data throughout.
Good results come from treating the replication factor, the minimum, and the acknowledgement level as one package, usually three, two, and all for important data. Keep the minimum below the replication factor to leave room for maintenance, spread replicas across zones, keep unclean leader election off, monitor partitions at and below the minimum, and fix the causes of shrinking in-sync sets instead of loosening the rule that reveals them.
Key Takeaways
- It is a floor for healthy copies — the minimum in-sync replicas, counting the leader, that must exist for writes with full acknowledgement to be accepted.
- It needs acks of all to matter — with acks of one or zero the setting is never checked, so protection exists only when both are configured together.
- The classic package is 3, 2, and all — a replication factor of three, a minimum of two, and full acknowledgement tolerate one failure without data loss or a write outage.
- Never exceed the replication factor, and leave headroom — a minimum above it blocks all writes, and a minimum equal to it blocks writes during any single restart.
- A minimum of one gives false comfort — the leader alone can satisfy it, so acknowledged data can be lost silently while everything looks healthy.
- Close the back door too — keep unclean leader election off for important data, and spread replicas across at least three zones so real failures cannot remove every copy.
- Watch the in-sync set, not just the errors — alert on under-replicated, at-minimum, and below-minimum partitions, investigate ISR flapping, and fix root causes instead of lowering the setting.