Handling Cluster-Wide ISR Shrinkage in Kafka
A plain-English guide to what happens when many Kafka partitions lose their in-sync copies at once: why it happens, how to spot the pattern, how to respond calmly, and how to stop it from coming back.
It is a quiet afternoon. Suddenly, dashboards light up. The number of under-replicated partitions jumps from zero to thousands. Producers start reporting errors about “not enough replicas”. Someone in the chat writes, “Is Kafka down?” It is not down, exactly. Kafka is protecting your data by refusing to pretend that copies are safe when they are not. But something has gone wrong across the whole cluster, and every minute of delay makes it harder to fix.
That moment is called cluster-wide ISR shrinkage. “ISR” stands for in-sync replicas, the copies of your data that are fully up to date. When many partitions lose members of that group at the same moment, it is rarely a coincidence. Usually a single shared cause is hiding behind the noise: a network problem, an expired certificate, a forgotten speed limit, a slow disk, or a cluster that is simply too busy.
This guide starts from zero. Every new word is explained the first time it appears, and each big idea comes with an everyday comparison. By the end you will understand how Kafka decides who is in sync, what a shrinkage storm looks like, how to find the common cause quickly, how to respond without making things worse, and how to build a cluster and a team that shrug off the next one.
1What the ISR Is and Why You Should Care
Before we talk about shrinking, we need to know what is being shrunk. The idea is simple once you see it as a team of copy-keepers.
Copies of your data
Apache Kafka stores streams of events in named categories called topics. Each topic is divided into partitions, and each partition is a separate ordered log. To protect against machine failures, every partition is stored as several copies, called replicas, on different servers called brokers. The number of copies is the replication factor, and three is the most common choice.
One replica is chosen as the leader. Producers write to it and consumers read from it. The other replicas are followers. A follower has one job: keep asking the leader for new data and add it to its own copy, so that it stays identical.
The in-sync group
Not every follower is always up to date. A follower might be slow, disconnected or restarting. Kafka keeps a list of the replicas that are fully caught up, and calls it the in-sync replica set, or ISR. The leader is always in it. A follower is in it only while it keeps pace.
Imagine a court reporter typing a transcript while two assistants copy it by hand. The assistants who have copied every line so far are “in sync”. If one assistant falls behind, gets distracted or leaves the room, the team drops that assistant from the trusted list until they catch up again.
Why the list is so important
- Safety of acknowledged writes. When a producer asks for full confirmation, Kafka waits until every replica in the ISR has the data. Being in the ISR means “I hold everything that was confirmed”.
- Safe leadership. If the leader dies, the new leader is normally chosen only from the ISR, since only those replicas are guaranteed to have all confirmed data.
- Honest reporting. The size of the ISR tells you, at any moment, how many safe copies of a partition actually exist.
What “shrinkage” means
ISR shrinkage means the list gets shorter: the leader decides a follower is no longer keeping up and removes it. With three copies, the ISR drops from three members to two, or to just the leader alone. When the follower catches up again, the list expands back. A little shrinking and expanding is a normal part of life. Widespread, simultaneous shrinking is a warning that something serious is happening.
Shrinkage is a symptom, not a disease. Kafka is telling you that copies are not keeping up. Your job is to find out why, and the reason is nearly always outside the ISR mechanism itself.
2How Kafka Decides Who Is In Sync
The rule is smaller and simpler than most people expect. Understanding it precisely removes a lot of confusion during an incident.
The follower’s loop
A follower runs a constant loop. It sends a fetch request to the leader saying, “Here is the position I have reached. Please send anything newer.” The leader replies with new data, and the follower adds it to the end of its log and asks again. The follower’s position is called its log end offset, and the leader remembers the latest one it heard from each follower.
sequenceDiagram
participant F as Follower
participant L as Leader
participant C as Controller
F->>L: Fetch new data from my offset
L-->>F: Send data and current high watermark
F->>F: Append data to local log
Note over L: Leader tracks how recently each follower was caught up
L->>L: Follower silent or behind for too long
L->>C: Ask to shrink the in-sync set
C-->>L: Approve and record the new set
The time-based rule
The leader does not count how many messages a follower is behind. It watches the clock. A setting called replica.lag.time.max.ms gives the maximum time allowed. If a follower has not fetched, or has not caught up to the leader’s latest data, for longer than this limit, the leader removes it from the ISR. In recent Kafka versions the default is thirty seconds, though older versions used ten, so check your own setup.
This detail matters a great deal. A follower that is slightly behind for a moment is fine. A follower that is continuously behind, or silent, for that whole time window is out. Anything that stops many followers from fetching and catching up for thirty seconds will shrink many ISRs at once.
The high watermark
The high watermark is the offset up to which all in-sync replicas have the data. Consumers can only read up to this point, because data beyond it could still be lost in a failover. When a producer asks for full confirmation, its request waits until the high watermark passes its message. So a single slow follower who is still in the ISR holds back the high watermark for the whole partition, and delays every writer waiting for full confirmation.
Think of a convoy that can only move as fast as its slowest truck. If one truck is stuck, the whole convoy waits. Removing the stuck truck from the convoy lets the rest move on, but the convoy is now smaller and less protected.
Who changes the list?
The leader decides, but the decision must be recorded in a central place so that everyone agrees. In modern Kafka, the leader sends a request to the controller, the part of the cluster that manages metadata, asking it to change the ISR. The controller records the new list and tells the other brokers. In older setups, the leader wrote the change to ZooKeeper directly. Either way, if this recording step is slow or fails, ISR changes can be delayed or rejected, which is one of the causes covered later.
The expand side
When a removed follower fetches all the way up to the leader’s high watermark, the leader asks to add it back. This rejoining is the expansion. If a follower keeps falling behind and catching up in cycles, you see repeated shrink and expand events, which people call ISR flapping.
| Term | Plain meaning |
|---|---|
| Replica | One copy of a partition on one broker |
| Leader | The copy that serves reads and writes |
| Follower | A copy that fetches from the leader |
| ISR | The replicas that are caught up |
| Log end offset | The last position in a replica’s log |
| High watermark | The last position that all in-sync replicas hold |
| Controller | The component that records cluster metadata such as the ISR |
3Normal Shrinkage Versus a Storm
Some shrinkage is healthy. The skill is telling everyday ripples from a wave that needs action.
Expected shrinkage
Certain events legitimately make followers drop out of the ISR for a while:
- A broker is restarted for an upgrade or patch. Every partition it hosts loses a replica from the ISR until it returns and catches up.
- A new replica is added during a partition move. It starts far behind and is not in the ISR until it catches up.
- A brief network blip makes one follower miss its window.
These are usually limited, short and explainable. You know why they happened, and they end by themselves.
The signature of a storm
Many partitions at once
Hundreds or thousands of partitions shrink within the same minute, rather than a handful.
Many brokers involved
The affected partitions have leaders or followers on lots of different machines.
No known cause
Nobody announced a restart or a move, and the timing seems random.
Shrinks without expands
Shrink events pile up, but expansions do not follow, so the damage persists.
Client errors
Producers report “not enough replicas”, and write latency rises or spikes.
Flapping
The same partitions shrink and expand over and over, minute after minute.
The numbers to watch
| Metric | What it counts | Reading it |
|---|---|---|
| UnderReplicatedPartitions | Partitions with fewer in-sync copies than the full replica list | Should sit at zero. Anything sustained is a problem |
| IsrShrinksPerSec | How often ISRs are being reduced | Spikes show a storm starting |
| IsrExpandsPerSec | How often ISRs recover | Should follow shrinks closely; a gap means trouble |
| UnderMinIsrPartitionCount | Partitions whose ISR is below the required minimum | Writes with full confirmation are failing here |
| AtMinIsrPartitionCount | Partitions sitting exactly at the minimum | One more loss would stop writes |
| OfflinePartitionsCount | Partitions with no leader | Reads and writes are impossible |
| FailedIsrUpdatesPerSec | ISR change requests that were rejected | Points at controller or metadata trouble |
A steady shrink count with no matching expands is more dangerous than a large shrink count followed by quick recovery. Always compare the two lines on the same graph.
4Why Cluster-Wide Is a Different Problem
One partition losing a follower is a local repair job. Thousands of partitions losing followers together is a different kind of event, and it needs a different mindset.
Common cause, not many bad luck events
If one disk on one broker fails, a few hundred partitions may shrink, all with the same broker as the missing follower. That is a local fault. But when partitions shrink across many brokers at once, the chance that a separate fault hit each one is tiny. Almost always there is one shared cause that touches everybody: the network they all use, the certificate they all present, the setting they all obey, the controller they all report to, or the load they all share.
If one house loses power, you check its fuse. If a whole town loses power, you do not check every fuse. You look at the power station and the main lines.
Why the blast radius is larger
- Many applications feel it at once. Every producer that uses full confirmation on any affected topic sees errors or delays.
- The safety margin vanishes everywhere. With ISRs reduced across the cluster, one more failure anywhere could take partitions offline or lose data.
- Recovery competes with itself. When followers rejoin, they all fetch at once, adding load exactly when the cluster is weakest.
- Fixes can hurt. Restarting brokers in a panic makes still more replicas leave the ISR.
A calm mindset
The single most valuable habit in a storm is to resist random action. Kafka is doing its job by protecting confirmed data. Your first goals are to find the pattern and to avoid adding load or churn. A ten-minute investigation that finds the shared cause usually beats an hour of restarts.
5The Cost: Durability, Availability and Latency
A smaller ISR is not just a number on a dashboard. It changes what your system can promise to users, and different settings decide which promise breaks first.
Three settings that decide the impact
- Replication factor: how many copies exist in total. Three is standard.
- Minimum in-sync replicas (
min.insync.replicas): the smallest ISR size for which the leader still accepts writes that need full confirmation. Two is a common choice with three copies. - Producer acknowledgement setting (
acks): how much confirmation the producer waits for. The safest value,all, waits for the whole ISR.
What happens as the ISR shrinks
| ISR size (of 3 copies) | Writes with acks=all and minimum 2 | Risk if the leader now fails |
|---|---|---|
| 3 (healthy) | Accepted | Two safe copies remain; no confirmed data lost |
| 2 | Accepted | One safe copy remains; no confirmed data lost, but no spare |
| 1 (leader only) | Rejected with a not-enough-replicas error | Partition goes offline until a safe replica returns, or data may be lost if unsafe election is allowed |
| 0 (no leader) | Impossible | Partition is offline |
A bank vault needs two keys to open. If only one key holder is present, the bank refuses to open the vault, because it would rather be unavailable than unsafe. Minimum in-sync replicas is that rule for your data.
Availability: refused writes
When the ISR falls below the minimum, producers using full confirmation receive errors named not enough replicas. Reads continue, but writers cannot proceed. If your applications do not retry, they lose events. If they retry blindly, they add load to a cluster that is already struggling.
Durability: fewer safe copies
Even when writes are accepted, an ISR of one means the only up-to-date copy lives on a single machine. If it dies, the partition goes offline. The system may be forced into a painful choice between waiting and allowing an out-of-date replica to lead, which can lose data that was already confirmed.
Latency: the slow follower problem
Before a slow follower is removed, it holds back the high watermark, so writers wait. The thirty-second window means a follower that stalls can add many seconds of delay to every full-confirmation write on its partitions before Kafka acts. After removal, latency drops, because the writers no longer wait for the slow follower. Thus a latency spike followed by a shrink is a classic pattern: the delay was the early warning.
Clients that do not wait for the ISR
Producers that use weaker confirmation settings do not experience the errors, because the leader does not wait for followers. That may look like good news, but it is the opposite. Those writes are being accepted without protection, and the loss of the leader could silently destroy them. A quiet shrinkage for these clients is the most dangerous kind.
Never treat a lack of client errors as proof that all is well. Check whether your critical producers really use full confirmation and a minimum ISR greater than one.
6Anatomy of a Shrinkage Storm
Storms rarely stay the size they started. Understanding the feedback loops that grow them explains why speed and calm both matter.
flowchart TD
A["Trigger: slowdown or fault"] --> B["Followers fall behind"]
B --> C["ISR shrinks on many partitions"]
C --> D["Producers see errors or delays and retry"]
D --> E["More load on leaders"]
E --> B
C --> F["Followers later catch up and rejoin"]
F --> G["Catch-up fetch traffic surges"]
G --> B
Loop one: retries pile on
When producers get errors or timeouts, most clients retry automatically. If thousands of clients retry at once, leaders receive more requests, not fewer, right when they are already too slow. More load makes followers fall further behind, which shrinks more ISRs, which causes more errors. This is called a retry storm.
Loop two: catching up costs more
A follower that has been away is far behind. When it returns, it fetches large amounts of data as quickly as it can. Many followers doing so together create a burst of traffic between brokers, using network bandwidth, disk reads on the leaders and processor time. That can push other followers past the time limit, and the shrinking continues even though the original trigger has gone.
Picture a traffic jam on a highway. A small accident starts it. Then drivers slow down, more cars pile up behind, and the jam keeps growing long after the wrecked car has been towed away. The jam has its own momentum.
A typical timeline
The trigger
Something changes: a network hiccup, a disk slowdown, a bad setting, a deployment. Fetch requests from followers start taking longer.
The stall
Followers stop keeping up. Writers waiting for full confirmation see latency climb as the high watermark stalls.
The shrink
After the time limit passes, leaders remove the lagging followers. Under-replicated counts jump. Latency briefly improves.
The errors
Where the ISR falls under the minimum, writers begin to fail. Retries add load.
The scramble
Alerts fire, people investigate, and someone may restart brokers, causing more churn.
The recovery or the spiral
If the cause is removed and load is contained, followers catch up and expand. Otherwise flapping continues.
Look at the order of events on your graphs. Which metric moved first: network errors, disk latency, processor use, request time, or the shrink count? The earliest mover is usually the closest to the cause.
7Root Cause Family One: The Network
Followers and leaders talk to each other constantly. Anything that disturbs that conversation for half a minute can shrink many ISRs at once.
Typical network causes
Saturated links
Traffic from producers, consumers and replication exceeds the network card or switch capacity, so fetch responses queue up.
Packet loss and retransmission
Even small loss rates slow connections badly, since lost data must be resent and the sender slows down.
Cross-zone degradation
When brokers sit in different availability zones, a problem on the link between zones affects the followers on the far side.
Network splits
A group of brokers cannot reach others. Followers in the cut-off group vanish from the leaders’ view.
Firewalls and load balancers
Idle timeouts, connection limits or rule changes can cut broker-to-broker connections.
DNS problems
Slow or failing name lookups stop brokers from reconnecting after a drop.
The followers are like assistants who phone the reporter every few seconds for the latest lines. If the phone line is crackly or jammed, they fall behind through no fault of their own.
How to recognize a network cause
- Followers are missing from ISRs across many leaders, but the machines themselves look healthy in disk and processor graphs.
- Affected brokers cluster in one zone, one rack or behind one switch.
- Network error and retransmission counters rise on the machines, and round-trip times between brokers grow.
- Cloud provider status pages or network teams report an incident.
What to do
- Ask the network or cloud team about events in the relevant zones and links.
- Measure round-trip time and loss between a few affected pairs of brokers with ordinary network tools.
- Check bandwidth graphs against the machine’s documented sustained limit, not the burst figure.
- Remove sudden extra traffic where possible: pause backups, mirroring or bulk consumers that share the same links.
Cloud machines often advertise “up to” network speeds that are only bursts. After the burst allowance runs out, traffic is throttled to a much lower baseline, and replication can suddenly starve. Compare against the documented baseline.
8Root Cause Family Two: Disks and Storage
Both leaders and followers depend on the disk. A follower that cannot write fast enough falls behind, and a leader that cannot read fast enough cannot feed its followers.
How a slow disk shrinks an ISR
Followers must write every fetched batch to their log. Leaders must read data for followers that are behind the cached recent data. If a disk stalls for even a few seconds, requests wait, queues grow, and the thirty-second window becomes easy to miss. Because Kafka spreads partitions over many disks, a shared storage problem hits many at once.
Common storage causes
- Exhausted burst credits. Many cloud volumes allow fast speeds for a while and then fall back to a low baseline. A busy cluster can run out of credits together, and every broker slows at nearly the same time.
- Shared-storage limits. Network-attached volumes may share a bandwidth cap with the machine’s other network traffic.
- Failing hardware. A dying disk shows growing latency and error counts before it fails outright.
- Background pressure. Log cleaning for compacted topics, deletion of very large old files, or another program sharing the disk can steal speed.
- Nearly full disks. A disk close to capacity slows down and can stop accepting writes.
- File system trouble. Errors, forced checks or a remount can pause everything.
- Page cache pressure. When memory for caching is squeezed, reads that used to come from memory hit the disk instead, overwhelming it.
A busy restaurant kitchen depends on one dishwasher. If the dishwasher slows, plates pile up, and every cook is stuck waiting for a clean pan. The problem is not the cooks, and hiring more cooks will not help.
Clues in the data
| Clue | What it suggests |
|---|---|
| Disk latency or queue depth rising on many brokers | Storage limit reached or a shared storage fault |
| Disk read activity rising while consumers are current | Cache misses; memory is too small or being squeezed |
| Disk usage close to full on a few brokers | Those brokers are slowing and will hold back followers |
| Log flush or append times increasing | Disk cannot keep up with the write rate |
| Operating system errors about the storage device | Hardware or file system trouble |
What to do
- Check the volume’s credit or throughput graphs from the provider, and its configured maximum.
- Reduce write load where you can, for instance by slowing bulk producers with quotas.
- Free space on nearly full disks by adjusting retention carefully, or by adding capacity.
- Increase provisioned throughput if the platform allows it, since some volume types can be tuned while running.
9Root Cause Family Three: Processor, Memory and Pauses
A broker that cannot get its work done in time looks, to the rest of the cluster, exactly like a broker that is broken.
Busy request threads
Brokers process requests with pools of threads. Network threads read and write on connections, and I/O threads carry out the requests. Follower fetch requests are ordinary requests that wait in the same queue as client requests. If threads are saturated, the queue grows, and follower fetches are delayed. A watch on the request handler idle percentage, discussed later, shows this clearly.
Garbage collection pauses
Kafka runs inside the Java virtual machine, which periodically pauses to clean up unused objects. A healthy broker pauses for a fraction of a second. A broker with a mis-sized heap, or under memory pressure, can pause for many seconds. During that pause it sends nothing, receives nothing, and looks dead. A pause near or beyond the ISR time limit removes the broker from many ISRs at once. If the pauses happen on several brokers, for instance because of a shared change that increased memory demand, the storm is cluster-wide.
Machine-level pauses
- Swapping. If the operating system pushes Kafka’s memory to disk, response times collapse.
- Noisy neighbors and steal time. On shared virtual machines, another tenant can take processor time. The machine appears busy even though your processes cannot run.
- Live migration or maintenance. Cloud providers occasionally freeze or move virtual machines, causing short stalls.
- Throttled processors. Some machine types earn processor credits and slow down when they run out.
A shop clerk who suddenly freezes for thirty seconds, in the middle of serving customers, does not seem slow. To the customers and the manager, they look like they left the building.
How to recognize it
- Garbage collection logs show long pauses that line up with the shrink events.
- Processor use is pegged, or steal time is high, on the affected brokers.
- Request queue size and request wait times are elevated while disks and networks look calm.
- Memory graphs show swap use or a heap near its limit.
What to do
- Confirm the heap size is sensible, not oversized, and that a modern collector is in use.
- Reduce the request load temporarily with client quotas.
- Turn off or fix any recent change that increased memory or processor demand, such as a new feature, a new client wave or a larger batch setting.
- Move the workload to machines with more headroom if processor credits or a noisy neighbor are to blame.
Always keep garbage collection logs enabled and shipped somewhere central. When you need them at 3 a.m., you will not have time to log in to every machine.
10Root Cause Family Four: Overload and Traffic Surges
Sometimes nothing is broken at all. The cluster is simply asked to do more than it can, and replication is the first thing to suffer.
Surges from clients
A marketing campaign, a flash sale, a replay job, or a new application that starts reading from the beginning can multiply traffic in minutes. Extra producer traffic means more data to replicate. Extra consumer traffic means more outgoing bytes competing with replication for network and cache. A cluster sized for average load will show ISR shrinkage during a peak.
Surges from operators
Some of the worst storms are self-inflicted:
- Partition reassignments copy large amounts of data between brokers. Without a speed limit, they can saturate network and disks and starve normal replication.
- Adding brokers and rebalancing triggers large data moves.
- Mass consumer restarts cause everyone to re-read from an old position.
- Big batch jobs that read whole topics at full speed.
The forgotten speed limit
Kafka lets you set replication throttles so that data moves during a reassignment do not overwhelm the cluster. The danger is the opposite mistake. If a throttle is set too low, or left in place after the move is finished, it also limits ordinary follower replication for the throttled partitions or brokers. Followers then fall behind whenever traffic rises, and ISRs shrink. This is a classic cause of mysterious, recurring shrinkage that begins a few hours after a reassignment and ends only when someone removes the limit.
It is like putting a speed limit sign on a road for roadworks and forgetting to take it down. Months later, everyone still crawls along and nobody remembers why.
Client quotas as a shield
Kafka also supports client quotas that cap how much bandwidth or request time a client may use. They protect replication from being crowded out by a runaway application. They are best set in advance for known heavy clients, and they can be applied quickly during an incident to slow the worst offenders.
How to recognize overload
| Clue | Likely meaning |
|---|---|
| Bytes in and out per broker much higher than usual | A client or job surge |
| A reassignment or rebalance is in progress | Data moves are competing with replication |
| Replication throttle settings present on brokers or topics | Possible forgotten or too-tight throttle |
| Consumer lag jumps as new groups appear | Replay or newly started readers |
| Request handler idle percentage near zero | The broker is out of processing capacity |
What to do
- Stop or pause any reassignment, rebalance or bulk job that is running.
- Check for and remove stale replication throttles once the move they were made for is done.
- Apply quotas to the heaviest clients.
- Ask application teams to slow down or delay non-urgent work.
11Root Cause Family Five: Security and Configuration Changes
These causes are sneaky because the machines are healthy. Everything is running. The brokers simply are no longer allowed, or able, to talk to each other properly.
Expired or changed certificates
Brokers often prove their identity to each other with digital certificates. Certificates expire on a fixed date. If the certificates that brokers use for replication expire, or are replaced with ones that other brokers do not trust, the follower connections fail. Because certificates are usually issued together, they often expire together, so every follower loses the connection at the same moment. The result is an instant, cluster-wide shrinkage with no hardware trouble at all.
It is as if every employee’s building pass expired at midnight on the same day. Nobody is sick and the doors are not broken, but nobody can get past the guard.
Permission changes
Kafka uses access control rules to decide who may do what. Followers connect using a special internal identity, and they need permission to act on the cluster to fetch replication data. If a rule change, a clean-up script or an automation accidentally removes or overrides those permissions, followers are refused. Look at recent changes to access rules and to the identity brokers use to talk to each other.
Listener, address and name changes
- Changing the advertised addresses of brokers so that other brokers can no longer reach them.
- Switching the security protocol for inter-broker traffic in only part of the cluster.
- DNS changes that point names at the wrong machines.
- Load balancers placed between brokers with short idle timeouts that silently cut long-lived connections.
Setting changes that alter behavior
| Setting area | How a bad change causes shrinkage |
|---|---|
| Fetcher thread count | Too few threads for the number of partitions means followers cannot keep pace |
| Replica fetch sizes and wait times | Very small fetches or long waits slow catch-up |
| Replica lag time limit | Set too low, normal hiccups exceed it |
| Socket buffers and timeouts | Small buffers cripple throughput on links with higher delay |
| Replication throttles | Too-tight limits starve followers, as in Chapter 10 |
| Protocol version settings during upgrades | Mixed versions can misbehave if the upgrade steps are followed out of order |
How to recognize it
- Broker logs on followers show authentication, authorization or connection errors to other brokers.
- The storm began at a precise moment that matches a certificate expiry, a deployment or an automation run.
- Hardware graphs are unremarkable.
- The affected brokers form no pattern by zone, but all show the same error text.
Track certificate expiry dates for brokers, clients and the certificate authority in a calendar and in monitoring. Alert weeks ahead, not days. An expired certificate is one of the most preventable causes of a full outage.
12Root Cause Family Six: The Controller and Metadata
The ISR is not only a local idea on the leader. Every change must be recorded by the controller. If the recording system is unhealthy, the whole cluster’s view of ISRs can go wrong.
What the controller does here
When a leader wants to shrink or expand its ISR, it sends a request to the controller. The controller checks it, saves the new list and shares it with the brokers. In older clusters the coordination service ZooKeeper played this role, and in newer ones Kafka’s own KRaft controllers do. If the controller is overloaded, slow, mid-election or cut off, requests time out or are rejected, and brokers may have a stale picture of which replicas are in sync.
How controller trouble appears
Failed ISR updates
The count of rejected or failed ISR change requests rises above zero for a sustained time.
Controller elections
The active controller changes repeatedly, or no controller is active for a period.
Metadata lag
Brokers or clients see old leader information, causing errors such as “not the leader for this partition”.
Session timeouts
Brokers lose their session with the coordination system and are treated as gone, causing leadership moves across many partitions.
The controller is like the town records office. Even if two neighbors agree that a boundary has moved, nothing is official until the office stamps the paper. If the office is closed, everybody is left working with outdated maps.
Likely reasons for controller trouble
- A controller node under heavy load, for instance because it shares a machine with a busy broker.
- Too many partitions, making metadata changes large and slow to apply.
- Long pauses or network issues between controller nodes, breaking their agreement protocol.
- Storms of leadership changes caused by another problem, which flood the controller with work.
- Problems in the older coordination service, such as slow disks or overloaded nodes.
What to do
- Confirm there is exactly one active controller and that it is stable.
- Check the health, disk speed and processor use of the controller nodes.
- Avoid actions that generate large metadata changes during the incident, such as mass topic creation or partition moves.
- If controllers share machines with brokers in production, plan to separate them.
Dedicated controller nodes, usually three, give you a calm, predictable coordination layer. It is a small cost that removes a whole family of hard-to-diagnose incidents.
13Root Cause Family Seven: Restarts, Upgrades and Deployments
Many storms are simply maintenance done too quickly. The safe pace for restarting brokers is set by the ISR itself.
Why a restart shrinks ISRs
When a broker stops, every partition it hosts loses a replica. If it was a leader, leadership moves. When it comes back, its replicas must catch up on everything they missed before they can rejoin the ISR. A clean shutdown lets Kafka move leadership in an orderly way first, which reduces disruption. A crash or forced kill skips that, and on restart the broker may need to check and rebuild parts of its logs, which takes time proportional to how much data it has.
The dangerous pattern
The dangerous habit is restarting the next broker before the previous one has fully caught up. Now two brokers are behind at once. Partitions that had replicas on both are down to a single in-sync copy, perhaps below the minimum, and writes fail. Do this across a whole cluster and you have manufactured a cluster-wide storm on purpose.
It is like rotating the tires on a car by removing all four wheels at once. Each wheel is fine, but the car cannot move. Removing one at a time, and putting it back before the next, keeps you on the road.
Other maintenance triggers
- Rolling upgrades that skip the required order of steps for protocol versions.
- Configuration pushes that restart all brokers together through an automation tool.
- Operating system patching that reboots machines on a shared schedule.
- Autoscaling or instance replacement that removes several machines at once.
- Cloud provider maintenance events that touch many machines in the same window.
How to recognize it
The timing lines up with a change record, a deployment tool’s log or a scheduled patch window. The missing followers are the brokers that restarted, and the restarts happened close together. Logs show recovery work such as checking log segments after an unclean stop.
What to do
- Halt any rollout in progress.
- Let restarted brokers catch up fully before touching another.
- Fix the automation so it waits for a healthy ISR state between steps. Chapter 21 shows how.
14Detecting It Early: Metrics and Alerts
The best storm is the one you catch in the first two minutes. Good alerts turn a surprise into a routine.
The core alert set
| Alert | Condition | Severity |
|---|---|---|
| Under-replicated partitions | Above zero for more than a few minutes | Warning, then critical if it grows |
| Under minimum ISR partitions | Above zero at all | Critical, because writes are failing |
| Offline partitions | Above zero at all | Critical |
| ISR shrink rate | Well above your normal baseline | Warning |
| Shrinks without matching expands | Shrinks exceed expands for several minutes | Warning to critical |
| Failed ISR updates | Above zero for a sustained time | Warning; check the controller |
| Active controller count | Anything other than exactly one across the cluster | Critical |
| At minimum ISR partitions | Above baseline | Early warning that the next failure hurts |
Supporting signals that explain the cause
- Request handler idle percentage and network thread idle percentage show whether brokers are out of processing capacity.
- Produce request time, and especially the part spent waiting for followers, shows replication lag before the ISR shrinks. When the waiting part of produce time rises, followers are struggling.
- Follower fetch request time and queue time show whether followers’ requests are slow to be served.
- Maximum replica lag shows how far behind the worst follower is.
- Disk latency, network errors, processor steal and garbage collection pauses confirm the physical cause.
- Producer error rates and retry rates from the client side show impact and warn of retry storms.
A car has a warning light for low fuel long before the engine stops. The waiting-for-followers time is your fuel warning; the shrink count is the engine cutting out.
Designing alerts that people trust
- Alert on sustained conditions, so routine restarts do not page anyone at night.
- Suppress or annotate alerts during announced maintenance, and make sure the suppression ends.
- Group alerts by broker, zone and cause, so ten thousand messages become one clear incident.
- Link every alert to a short runbook.
- Graph shrinks and expands together, so the gap is obvious at a glance.
Record your normal shrink and expand rates over a month. A baseline turns “this looks high” into “this is fifty times our normal”, which is far easier to act on.
15Reading the Pattern: A Diagnostic Decision Tree
You do not need to investigate everything at once. A few good questions, asked in order, point to the right family of causes.
flowchart TD
S["ISR shrinkage alert"] --> Q1{"One follower broker missing from many partitions?"}
Q1 -- Yes --> A1["Follower host problem: disk, pauses, network, restart"]
Q1 -- No --> Q2{"Many followers missing from one leader broker?"}
Q2 -- Yes --> A2["Leader overloaded, or its network or disk is slow"]
Q2 -- No --> Q3{"Do the affected brokers share a zone or rack?"}
Q3 -- Yes --> A3["Zone or rack network or infrastructure problem"]
Q3 -- No --> Q4{"Did anything change recently?"}
Q4 -- Yes --> A4["Certificates, permissions, settings, throttles, deployments"]
Q4 -- No --> A5["Systemic: controller, cloud event, traffic surge"]
How to get the answers
Kafka’s command-line tools can list partitions that are under-replicated (--under-replicated-partitions) or below the minimum ISR (--under-min-isr-partitions). Export that list and group it in a spreadsheet or small script in two ways:
- By missing replica. For each partition, note which replica is not in the ISR. If one broker appears almost everywhere, you have a follower-side problem with that broker.
- By leader. Count affected partitions per leader. If a single leader dominates, the leader cannot serve its followers.
- By zone or rack. Add each broker’s zone and see whether the affected set clusters.
| Pattern you see | Most likely family | First check |
|---|---|---|
| One broker missing everywhere | That broker’s disk, pauses, network or a recent restart | Its logs, garbage collection and disk graphs |
| One leader affected everywhere | Leader overload or slow serving | Its request queue, network and disk |
| One zone or rack affected | Infrastructure between that zone and the rest | Cloud status and inter-zone round-trip time |
| Everything at once, at a sharp moment | Certificate, permission, setting or deployment | Change logs and broker error messages |
| Everything, building gradually | Load growth, throttle, storage credits | Bytes in and out, throttle settings, volume credits |
| Metadata errors and controller changes | Controller or coordination trouble | Active controller count and controller node health |
A doctor does not order every test for every patient. A few quick questions, such as where it hurts and when it started, point to the right department. This tree is your quick set of questions.
16First Response: The Runbook
A good runbook is short enough to follow under stress. Here is a practical order of actions for the first thirty minutes.
Declare and assign roles
Open an incident, name one person to lead, one to investigate and one to communicate with affected teams. Clear roles prevent everyone from touching everything.
Assess the severity
Check under-minimum-ISR and offline partition counts. Are writes failing? Which topics and applications matter most? This sets urgency.
Freeze changes
Pause deployments, restarts, reassignments and bulk jobs. Announce a change freeze. Nothing new should be added to the mix.
Check the cheap causes first
Look at recent changes, certificate expiry, permission edits, replication throttles, and cloud provider status. These take minutes and explain a large share of storms.
Find the pattern
Group affected partitions by missing replica, by leader and by zone, and walk the decision tree from Chapter 15.
Reduce load
Apply client quotas to heavy clients, ask teams to pause non-urgent jobs, and ask producers with aggressive retries to back off.
Fix the cause
Renew the certificate, restore the permission, remove the throttle, repair the network link, add storage capacity, or roll back the change.
Watch recovery
Follow expansions and under-replicated counts fall. Manage the catch-up traffic. Chapter 18 covers this.
Communicate and record
Post regular updates, and keep a timeline of what was seen and done, for the review afterward.
The urge to “just restart the brokers” is strong. Restarts remove replicas from ISRs, add recovery work, and rarely fix a cluster-wide cause. Restart only when evidence points to one specific broker being stuck.
17Stabilizing Without Making It Worse
Under pressure, teams reach for settings that promise quick relief. Some help, some hide the problem, and some make it much worse. Here is how to tell them apart.
Safe actions to take early
- Pause changes and heavy jobs. This cannot hurt and often helps immediately.
- Apply or tighten client quotas on the heaviest producers and consumers.
- Remove stale replication throttles once you are sure they are no longer needed.
- Ask application teams to slow retries or add delays between attempts.
- Add capacity where it is obviously short, such as raising a volume’s provisioned throughput.
Knobs that need careful thought
| Knob | What it does | Risk |
|---|---|---|
| Raise the replica lag time limit | Gives followers more time before removal, reducing flapping | Real stalls last longer before Kafka reacts, and full-confirmation writes wait longer. It treats the symptom |
| Add follower fetcher threads | Gives followers more parallel fetching capacity | Uses more processor and connections; helps only if fetching is the bottleneck. Needs a broker restart in many versions |
| Lower the minimum in-sync replicas | Lets writes continue with fewer copies | Reduces durability. Use only as a deliberate emergency decision, and restore it afterward |
| Allow unclean leader election | Lets an out-of-date replica become leader to bring a partition back | Can permanently lose confirmed data. A last resort, per topic, with owner approval |
| Increase replication throttle rates | Speeds up recovery copying | Uses more bandwidth and may crowd out clients |
| Pause automatic leader rebalancing | Stops leadership from moving back to preferred brokers during instability | Leadership stays uneven until you re-enable it |
Lowering the minimum in-sync replicas is like a bank saying, “Fine, one key is enough to open the vault today.” It keeps customers happy for the moment, but it is exactly the moment when a mistake or a thief would be most costly.
Things not to do
- Do not restart many brokers. It adds churn and recovery work.
- Do not delete data or topics to “clear the problem”. It rarely helps and cannot be undone.
- Do not switch on unclean leader election cluster-wide. The damage can be silent and permanent.
- Do not start large reassignments in the middle of an incident.
- Do not raise the lag limit as your first step. Find the cause first.
Write every change you make during an incident in a shared timeline, with the time and the person. When the storm ends, the timeline tells you which action helped and which did nothing.
18Recovering: Managing the Catch-Up
Fixing the cause is only half of the job. The cluster then has to bring all those lagging followers back, and how you manage that decides whether recovery is smooth or a second storm.
What recovery looks like
Once the cause is gone, followers fetch the data they missed and, when caught up, rejoin their ISRs. Expand events climb, under-replicated partitions fall, and the under-minimum count drops to zero. The amount of data to copy equals the incoming rate multiplied by the length of the outage, so longer incidents mean heavier recovery traffic.
Watch for the second wave
All followers fetching at once can saturate the same resources that just recovered. Signs of trouble include the shrink count rising again while expands are still low, request queue times increasing, and network use hitting its limits. If this happens, ease the load rather than restarting anything.
Techniques that help
- Keep client load moderate until the under-replicated count is near zero, by leaving quotas in place.
- Use replication throttles deliberately only if catch-up traffic is threatening clients, and then remove them as soon as it is safe.
- Recover the most important topics first where you can, by prioritizing their partitions, or by giving non-critical clients lower priority.
- Avoid restarts while brokers are catching up, since each restart resets progress for the partitions it hosts.
- Let automatic leader rebalancing wait until the ISRs are healthy, so leadership does not move again during catch-up.
How to know it is really over
- Under-replicated, under-minimum and offline partition counts are all zero and stay there.
- Shrink and expand rates have returned to baseline.
- Request latencies and queue times are back to normal.
- Client error and retry rates have returned to normal.
- Leadership is spread evenly, or a rebalance has been planned.
- Any temporary emergency settings, such as a lowered minimum ISR, quotas and throttles, have been reviewed and restored.
After a power cut, switching every appliance on at the same instant can trip the fuse again. Bringing things back gradually keeps the lights on.
19Protecting Writes While the Cluster Is Unwell
Your applications decide whether a shrinkage storm becomes lost data, or a short pause that nobody notices. Their settings matter as much as the brokers’.
Settings for critical data
| Setting | Recommended idea | Why |
|---|---|---|
| Replication factor | Three for important topics | Allows one failure while keeping a spare |
| Minimum in-sync replicas | Two with three copies | Refuses writes rather than accepting them with only one safe copy |
| Producer acknowledgement | All in-sync replicas (acks=all) | A confirmed write is stored on several machines |
| Idempotent producer | On (default in modern versions) | Retries do not create duplicate records |
| Retries and delivery timeout | Generous timeout, with backoff between attempts | Survives a short storm without giving up too early |
| Unclean leader election | Off for important topics | Avoids silently losing confirmed data |
Behave well when errors occur
When a producer receives a not-enough-replicas error, it should wait and retry with exponential backoff, meaning longer and longer delays between tries, plus a little random variation so thousands of clients do not all retry at the same instant. It should also have a bounded local buffer, and a clear plan for what to do when the buffer fills, such as slowing the source, spilling to local storage, or failing the request visibly.
If a shop’s door is jammed, it does not help if all the customers keep shoving at it at the same time. If they step back and try again after different short waits, the door frees up much faster.
Tiers of importance
Not every topic deserves the same settings. Classify topics by how much loss or delay the business can accept, and choose settings to match:
Money, orders, audit
Three copies, minimum two, full confirmation, no unclean election. Prefer refusing writes to risking loss.
User-facing state
Same protections, with well-tuned retries and buffering to hide short interruptions.
Debug and metrics data
May accept weaker settings so it never blocks a business process during trouble.
Consumers during a storm
Consumers only read data up to the high watermark, so they see slightly older data while followers lag, and they are otherwise unaffected. Delays in end-to-end freshness are the main effect. If consumers are configured to read from followers in their own zone, they follow the same watermark rule and see the same delay. Consumers rarely need changes, but downstream teams should know that data may be delayed, not lost.
Audit every important producer’s real settings, including defaults inherited from libraries. A single service still using weak confirmation can silently lose data during exactly the events this guide describes.
20Preventing Recurrence: Architecture and Configuration
The cheapest storm is the one that never happens. These design choices make shrinkage rarer, smaller and shorter.
Spread replicas across failure domains
Tell each broker which rack or availability zone it lives in, and Kafka places the replicas of each partition in different ones. Then a problem in one zone can remove at most one replica from a partition, and with three copies and a minimum of two, writes continue. Make sure the number of brokers in each zone is equal.
Leave headroom
Many storms are just clusters running too hot. Size brokers so that normal peak load uses about half of tested capacity, leaving room for a lost broker or zone, for recovery traffic and for surges. Watch the busiest broker, not the average.
Give replication its own road
Kafka lets you define separate network listeners for inter-broker traffic and client traffic. Using a dedicated inter-broker listener, and where possible a dedicated network path or quality-of-service class, keeps a client surge from crowding out replication. It also makes it easier to secure and monitor the replication path.
Right-size the fetching machinery
- Set enough replica fetcher threads for the number of partitions each broker follows.
- Keep replica fetch sizes large enough to move data efficiently.
- Set socket buffers appropriate for links between zones.
- Keep the wait time for fetches well below the replica lag limit.
Keep partitions manageable
The more partitions a broker leads and follows, the more work its fetchers and the controller must do. Stay within tested partition counts per broker, and avoid creating thousands of tiny partitions “just in case”.
Choose the lag limit consciously
The default replica lag limit works for most clusters. If your links between zones are long and your pauses are occasional, you might raise it modestly after testing, accepting that real stalls take longer to detect. Change it as a deliberate design decision, with measured evidence, not as a panic fix.
Isolate the coordination layer
Run controllers on dedicated machines, in separate zones, with reliable disks and modest but steady resources.
Rack awareness
Replicas in different zones, evenly balanced.
Capacity headroom
Peak load around half of tested limits.
Dedicated replication listener
Client surges cannot crowd out followers.
Dedicated controllers
Metadata stays calm when brokers are busy.
Tested partition counts
Staying within limits protects fetchers and controllers.
Fast, predictable disks
Sustained speed, not burst speed, sets the pace.
21Preventing Recurrence: Operations and Habits
Good habits matter as much as good design. Most storms trace back to a small number of preventable operational mistakes.
The safe rolling restart
Restart one broker at a time, and never start the next until the ISR state is healthy again. This single rule prevents the most common self-inflicted storm.
flowchart LR
R1["Restart one broker"] --> R2["Wait for it to rejoin"]
R2 --> R3{"Under-replicated partitions at zero?"}
R3 -- No --> R2
R3 -- Yes --> R4["Move to the next broker"]
R4 --> R1
- Use controlled shutdown, so leadership moves away before the broker stops.
- Do not pass the wait step just because a timer expired. Check the actual under-replicated count.
- Follow upgrade steps in the documented order, including protocol version changes.
- Restart the controller nodes carefully, one at a time, keeping the majority alive.
Certificates and secrets
- Keep an inventory of every certificate and its expiry date.
- Alert at least thirty days ahead, then again at fourteen and seven.
- Stagger expiry dates across brokers where possible, so a single missed renewal cannot hit everyone at once.
- Practice renewal in a test cluster.
Change hygiene
- Roll out changes gradually, to one broker or one zone first, and watch the ISR metrics before continuing.
- Require review for changes to access rules and to inter-broker settings.
- Record every replication throttle you set, with an owner and an end date, and verify removal afterwards.
- Keep configuration in version control, and compare running values with the stored ones regularly.
Capacity and growth
- Review capacity quarterly with real numbers.
- Start growth work when disk, processor or network use passes agreed thresholds, before they become emergencies.
- Apply quotas to clients that are known to be spiky.
Practice
Run game days in a test environment or in a carefully chosen quiet window. Simulate a lost zone, a slow disk, an expired certificate and a forgotten throttle. Time how long it takes your team to find the cause using the decision tree. Every drill exposes gaps in dashboards, alerts and runbooks while the stakes are low.
Firefighters do not learn to use the hose during a fire. They rehearse, so their hands know what to do when the alarm rings. Your incident response deserves the same rehearsal.
22The Post-Incident Review
A storm that teaches nothing is a storm you will meet again. A good review turns pain into a stronger system without blaming people.
A blameless approach
The aim is to understand how the system allowed a mistake or a failure to cause harm, not to find someone to blame. If a person made a change that caused the storm, ask why the change was possible, why nothing warned them, and why the effects were not caught sooner.
Questions to answer
| Topic | Questions |
|---|---|
| Timeline | When did it start, when was it detected, when was it fixed, and how long did each phase take? |
| Impact | Which topics, applications and customers were affected? Was any data lost or delayed? |
| Root cause | What was the true trigger, and which conditions allowed it to become cluster-wide? |
| Detection | Which alert fired first? Was it fast enough? What was missing? |
| Response | Which actions helped, which were neutral, and which made things worse? |
| Prevention | What design, configuration or process change would have stopped it or shrunk it? |
| Follow-up | Who owns each action, and by what date? |
Typical follow-up actions
- Add or tune the alerts that would have fired earlier.
- Update the runbook with the steps that worked.
- Fix the automation or process that allowed the trigger.
- Adjust capacity, settings or architecture.
- Share the story with other teams that run Kafka.
23A Storm in Numbers: A Worked Example
Numbers make the ideas concrete. Let us walk through an invented but realistic storm and do the arithmetic that shapes how long recovery takes.
The setup
A cluster has nine brokers spread over three zones. Producers send 60 MB/s in total. Every partition has three copies, so each byte is followed by two follower copies. There are about 3,000 partitions in all. Critical topics use a minimum of two in-sync replicas. The replica lag limit is 30 seconds.
The incident
At 14:00, the certificates used by brokers to talk to each other expire, and all follower connections fail. The team finds the cause and installs new certificates by 14:10. Let us trace what happens.
| Time | What happens |
|---|---|
| 14:00:00 | Follower connections fail. Full-confirmation writes begin to wait, since followers can no longer fetch. |
| 14:00:30 | The lag limit passes. Leaders shrink ISRs on roughly all 3,000 partitions. Under-replicated count jumps to about 3,000. |
| 14:00:31 | Every ISR is now the leader alone, which is below the minimum of two. Critical producers start getting not-enough-replicas errors. |
| 14:03 | Alerts have been firing for two minutes. The team opens an incident and freezes changes. |
| 14:06 | Someone notices authentication errors in follower logs. The certificate expiry is confirmed. |
| 14:10 | New certificates are in place. Followers reconnect and begin catching up. |
How much data must be caught up?
Followers were away for ten minutes, which is 600 seconds. Producers kept sending, or tried to, at up to 60 MB/s. Assume the writes that were accepted continued, so the missed data per follower copy is about 60 MB/s times 600 seconds, which is 36,000 MB. There are two follower copies of each byte, so the total to copy is about 72,000 MB, or 72 gigabytes. Spread over nine brokers, each has about 8 GB to catch up.
How long does catch-up take?
| Catch-up speed per broker | Time for 8 GB | Comment |
|---|---|---|
| 50 MB/s extra | about 160 seconds | Under three minutes, if the brokers have spare capacity |
| 20 MB/s extra | about 400 seconds | Still comfortable, but noticeable |
| 5 MB/s because of a leftover throttle | about 1,600 seconds | Nearly 27 minutes of exposure and possible new lag |
Think of a river that has been dammed for ten minutes. When the dam opens, the water behind it rushes out faster than normal. Downstream must handle the surge, or it floods. Catch-up is that surge.
What the numbers teach
- Detection speed matters. Every extra minute of outage adds more data to catch up.
- Throttles and headroom decide whether recovery takes minutes or half an hour.
- Writes with full confirmation were refused for about ten minutes, so client retry behavior decided how much the applications suffered.
- A cluster running near capacity would have struggled to absorb the catch-up traffic and might have shrunk again.
24Reading the Dashboards: What Each Cause Looks Like
Each family of causes leaves a different fingerprint on your graphs. Learning the shapes lets you make a good guess in seconds.
| Shape on the graph | What it usually means |
|---|---|
| Follower fetch rate falls off a cliff to near zero at one moment | Connections broke: certificate, permission, firewall or address change |
| Traffic rises and then hits a flat ceiling that never moves | A limit: replication throttle, quota, network baseline or volume throughput cap |
| Disk latency climbs gradually, then stays high | Storage credits used up, a full disk, or growing contention |
| Sharp, regular spikes in request time | Garbage collection pauses or periodic background work |
| Retransmissions and round-trip time grow together | Network loss or congestion |
| One broker’s lines differ sharply from its peers | A local hardware or host problem on that broker |
| Shrinks repeat in a daily rhythm at busy hours | Capacity limit or a leftover throttle |
| Shrinks and expands alternate every few minutes | Flapping: borderline capacity, a metastable loop or an unstable link |
| Controller changes right before the shrinks | Metadata or coordination trouble |
Flat lines are clues
Natural traffic wobbles. When a graph is suspiciously flat at its top, a limit is at work, because real load would rise and fall. A flat ceiling on replication traffic across brokers is a very strong sign of a throttle, a quota or a bandwidth cap.
If the water level in a tank rises and then stops at exactly the same height every time, you suspect an overflow pipe, not a random coincidence.
Compare, do not stare
- Put the same metric for all brokers on one graph and look for outliers.
- Overlay the shrink count with the candidate cause, such as disk latency, and see which moved first.
- Compare with the same hour yesterday and a week ago to separate normal peaks from new problems.
- Mark deployments, certificate dates, configuration changes and cloud events on the timeline.
Build one “ISR investigation” dashboard in advance, showing the shrink and expand rates, under-replicated counts, request idle percentages, disk latency, network errors, garbage collection pauses and follower fetch rates side by side. During a storm, nobody wants to build charts.
25Special Situations: Small Clusters, Managed Services and Odd Settings
The advice so far assumes a typical self-managed cluster with three copies. A few common situations need extra care.
Replication factor and minimum ISR together
| Copies | Minimum ISR | Behavior during a single-broker problem |
|---|---|---|
| 3 | 2 | Writes continue with one copy missing. The standard safe choice |
| 3 | 1 | Writes continue, even down to one copy, so protection can silently vanish |
| 2 | 2 | Any single missing copy stops writes. Safe but fragile |
| 2 | 1 | Writes continue but with a single copy after any failure. Weak |
| 1 | 1 | No redundancy at all; any broker failure loses availability and maybe data |
Very small clusters
In a cluster of exactly three brokers, taking one down for maintenance puts every partition at the minimum. If anything else goes wrong in that window, writes stop. Plan maintenance for quiet times, keep brokers healthy, and consider more brokers for critical workloads.
Managed Kafka services
If your provider runs the brokers, you cannot log in and restart machines, but the same logic applies. Check the provider’s service health page and the metrics they expose. Look at your own clients: are they overloading the service, using more partitions than the plan supports, or reaching quotas? Contact support with evidence, such as the time the shrinkage began, the affected topics and the metrics. Meanwhile, use client-side protections such as backoff, quotas and buffering. Many providers also offer scaling options; use them early in an incident if load is the cause.
Consumers reading from followers
Some consumers are set to read from the nearest replica, including followers, to save cross-zone traffic. They see data only up to the high watermark, which may lag while followers struggle. Warn those teams that freshness can drop during a storm.
Tiered storage
With tiered storage, older data lives in object storage while recent data stays local. The catch-up of a lagging follower usually concerns only the recent local data, so recovery traffic is bounded. But heavy reads of old data from remote storage can add network and cache pressure. Keep an eye on them when you are recovering.
Topics with unusual settings
- Compacted topics run background cleaning that competes for disk. Watch them if disks are the suspect.
- Very high-throughput topics may need dedicated brokers or quotas so they cannot dominate replication.
- Topics with a per-topic lag or minimum setting that differs from the cluster default can behave differently from their neighbors. Check for exceptions when a subset of topics is affected.
Do not assume all topics are configured alike. Compare the settings of affected and unaffected topics. The difference is sometimes the whole answer.
26A Field Guide to the Settings That Govern the ISR
Many settings touch replication. Knowing what each one does, and how it can help or hurt during a storm, lets you review your cluster calmly before trouble arrives. Default values change between Kafka versions, so always check the documentation for the version you run.
Broker and topic settings
| Setting | Plain meaning | Relevance to a storm |
|---|---|---|
replica.lag.time.max.ms | How long a follower may go without catching up before removal | Sets how quickly shrinkage happens and how tolerant Kafka is of pauses |
min.insync.replicas | Smallest ISR that still accepts full-confirmation writes | Decides when writes are refused |
unclean.leader.election.enable | Whether an out-of-sync replica may become leader | Trades safety for availability; keep off for critical data |
num.replica.fetchers | Threads used by each broker to fetch from each source broker | Too few can leave followers unable to keep up on busy brokers |
replica.fetch.max.bytes | Largest amount a follower asks for in one fetch per partition | Small values slow catch-up |
replica.fetch.wait.max.ms | How long the leader may hold a follower’s fetch when there is no new data | Must stay well below the lag limit |
replica.socket.receive.buffer.bytes | Network buffer for replica fetching | Matters on links with longer delay |
controlled.shutdown.enable | Whether brokers hand off leadership before stopping | Reduces disruption during restarts |
auto.leader.rebalance.enable | Whether leadership is moved back to preferred brokers automatically | Can add churn during an unstable period |
broker.rack | Which zone or rack a broker belongs to | Enables placement of replicas across failure domains |
inter.broker.listener.name | Which network listener brokers use to talk to each other | Allows replication to have its own path |
| Replication throttle settings | Speed limits for data moved to or from certain brokers and partitions | Protective during moves, harmful if left on |
Producer settings
| Setting | Plain meaning | Relevance to a storm |
|---|---|---|
acks | How much confirmation the producer waits for | Decides whether writes are protected by the ISR |
enable.idempotence | Removes duplicates caused by retries | Makes retries during a storm safe |
delivery.timeout.ms | Total time allowed to deliver a message, including retries | Should be long enough to outlast short storms |
retry.backoff.ms | Delay between retries | Longer, varied delays avoid retry storms |
buffer.memory | How much data a producer may hold locally while waiting | Decides how long an application can ride out a storm before blocking |
These settings are like the safety features of a car: seat belts, airbags, brake lights and speed limiters. You seldom think about them on a sunny day, but each one changes what happens in a crash.
A sensible review routine
- List the running values of these settings on every broker and compare them with each other and with your stored configuration.
- Look for topics that override the cluster defaults, especially for minimum ISR and unclean election.
- Check producers of the most important topics for the settings above, including defaults that come from libraries.
- Note any dynamic settings, such as throttles and quotas, that were applied by hand and never removed.
- Write down the reason for every value that differs from the default.
Keep a short “why we chose this” note beside every non-default value. Six months later, during a storm, that note is worth more than the setting itself.
27Real-World Stories and Illustrative Scenarios
The stories below show the causes from earlier chapters in action. The first group reflects publicly known practices, and the rest are illustrative scenarios written to show how a typical team would meet each situation.
Public practice: alerting on under-replicated partitions
Kafka’s own documentation and the guidance published by major vendors list under-replicated partitions, ISR shrink and expand rates, offline partitions and the active controller count among the most important broker health metrics to monitor. Teams that run very large fleets rely on these same signals. The lesson: the core alert set in Chapter 14 is not exotic; it is the industry baseline.
Public practice: automated rebalancing at large scale
LinkedIn, where Kafka was created, open sourced Cruise Control to monitor load and rebalance partitions across large fleets, with throttled data moves as a built-in idea. The lesson: moving data safely needs speed limits and automation, and forgetting the limit is a hazard that large operators have had to design around.
Scenario: the certificate that expired at midnight
A payments platform renewed its broker certificates two years earlier, all in one batch, with the same expiry date. At midnight, every broker-to-broker connection failed. Within thirty seconds nearly every ISR had shrunk to the leader alone, and payment producers using full confirmation failed with not-enough-replicas errors. The team first suspected the network, then noticed authentication errors in the follower logs. They installed new certificates and let brokers reconnect one at a time. Afterward they added expiry alerts at thirty days, staggered renewal dates and rehearsed renewal in a test cluster. The lesson: a sharp start time and identical errors everywhere point to certificates or permissions.
Scenario: the throttle nobody removed
After adding brokers, a team set a low replication throttle to move partitions gently, then finished the move and forgot to clear it. For two weeks, all was well at night. Every weekday afternoon, when traffic peaked, followers on the throttled brokers could not keep up, and ISRs shrank and expanded in a daily rhythm. The team eventually found the leftover throttle settings by comparing the running configuration with their expected one. The lesson: recurring shrinkage tied to busy hours is often a limit, not a fault.
Scenario: burst credits run out
A media company ran its brokers on network disks that allowed fast speeds only while credits lasted. A big live event pushed writes higher than the volumes’ baseline for hours. The credits ran out on almost every broker within minutes of each other, disk latency climbed, and followers fell behind everywhere. The team raised provisioned throughput on the volumes, paused a large batch job and used quotas to slow a noisy client. Later they resized volumes for sustained load. The lesson: shared storage limits hit every broker at once.
Scenario: a rough night between zones
A retailer’s cluster spanned three zones. One evening, a provider network issue raised delay and packet loss between two of them. Followers in the affected zone missed their window on hundreds of partitions. The team saw that all the missing replicas lived in a single zone, contacted the provider, and, because they used three copies with a minimum of two, writes kept flowing throughout. The lesson: rack awareness and a sensible minimum ISR turned a potential outage into a warning.
Scenario: the fast rolling restart
An automated patch job restarted brokers every five minutes, regardless of health. On a busy day, restarted brokers needed twenty minutes to catch up, so at one point three brokers were behind at once. Partitions with replicas on those brokers fell below the minimum and rejected writes. The team paused the job, let the cluster recover and changed the automation to wait for zero under-replicated partitions between restarts. The lesson: a timer is not a health check.
28Design Patterns and Anti-Patterns
Patterns are habits that keep clusters healthy, and anti-patterns are traps that turn small issues into big storms.
Patterns worth adopting
Three copies, minimum two, full confirmation
The standard trio that trades a little availability for strong safety on critical topics.
Rack-aware placement
Replicas in different zones so a zone problem removes at most one copy.
Health-gated rollouts
Every change and restart waits for a healthy ISR before continuing.
Baseline-aware alerting
Alerts compare against normal shrink rates and pair shrinks with expands.
Client quotas by default
Known heavy clients are capped before they can crowd out replication.
Throttle registry
Every temporary limit has an owner and an expiry, and is checked for removal.
Backoff with jitter
Clients retry gently, so a storm does not multiply itself.
Game days
Regular rehearsals of the failures in this guide.
Anti-patterns to avoid
What it looks like
Restarting many brokers at once, or one after another on a timer, when ISRs are already unhealthy.
Why it hurts
Each restart removes replicas from ISRs and adds catch-up work, turning a small problem into a cluster-wide one.
Do this instead
Restart one broker at a time and wait for zero under-replicated partitions. During an incident, restart only a broker proven to be stuck.
What it looks like
Setting the minimum in-sync replicas to one, or allowing unclean leader election everywhere, to make errors disappear.
Why it hurts
Errors vanish, but so does protection. Confirmed data can be lost silently when a leader fails.
Do this instead
Keep the protective settings, fix the cause, and treat any emergency relaxation as temporary and approved.
What it looks like
Raising the replica lag time limit again and again until alerts go quiet.
Why it hurts
Real stalls now last longer before Kafka reacts, writers wait longer, and the underlying problem keeps growing unseen.
Do this instead
Find what makes followers slow. Change the limit only with measured evidence.
What it looks like
Leaving throttles, quotas and other emergency settings in place with no owner and no end date.
Why it hurts
They quietly cap replication or clients and cause mysterious problems months later.
Do this instead
Record every temporary setting with an owner and expiry, and audit the running configuration regularly.
What it looks like
Watching only the shrink count, or only client errors, and ignoring producers that use weak confirmation.
Why it hurts
Silent risk goes unseen. The clients without errors may be exactly the ones losing data.
Do this instead
Watch shrinks and expands together, under-minimum counts, and audit client settings.
29Best Practices and Common Mistakes
Here is a compact summary of what to do before, during and after a shrinkage storm, followed by the mistakes that trip up most teams.
Do
- Alert on under-replicated, under-minimum and offline partitions.
- Graph shrinks and expands together with a baseline.
- Group affected partitions by missing replica, leader and zone.
- Check certificates, permissions, throttles and recent changes first.
- Freeze changes and reduce load when a storm starts.
- Restart one broker at a time and wait for health.
- Keep a written timeline of actions.
Do not
- Restart brokers in bulk during an incident.
- Lower protection settings without approval.
- Raise the lag limit as a first response.
- Start large data moves in the middle of trouble.
- Leave temporary settings in place after the incident.
- Assume no client errors means no risk.
- Skip the review.
The most common mistakes
- Treating shrinkage as the cause. It is a symptom. The cause is what made followers slow or disconnected.
- Looking at brokers one by one. A cluster-wide pattern needs a cluster-wide view: group and compare.
- Forgetting the boring causes. Expired certificates, changed permissions and leftover throttles cause a surprising share of storms.
- Running too hot. With no headroom, any surge becomes a shrinkage event.
- Ignoring producer settings. Weak confirmation hides risk, and aggressive retries multiply load.
- Mixing controllers with busy brokers. Metadata slows exactly when it is needed.
- Never rehearsing. Untested runbooks fail at the worst moment.
A short pre-flight checklist
- Do critical topics use three copies, a minimum of two, and full confirmation?
- Are replicas spread evenly over zones?
- Do we alert on the metrics in Chapter 14, with links to a runbook?
- Do we know every certificate’s expiry date and every temporary throttle?
- Does our rolling restart process check the ISR state, not just a timer?
- When did we last practice this incident?
30Frequently Asked Questions
Quick answers to questions that come up during and after shrinkage incidents.
31Summary and Key Takeaways
A cluster-wide ISR shrinkage looks alarming, but it follows patterns you can learn to read. Understand the mechanism, find the shared cause, act calmly, and design so the next one is small.
Key Takeaways
- The ISR is the set of caught-up copies: a follower is dropped when it has not kept pace within the replica lag time limit, and shrinkage is Kafka honestly reporting fewer safe copies.
- Cluster-wide means shared cause: look at the network, storage, certificates, permissions, settings, throttles, the controller and recent changes before blaming individual machines.
- Read the pattern first: group affected partitions by missing replica, by leader and by zone, and use the decision tree to choose where to dig.
- Respond calmly: freeze changes, reduce load, fix the cause, and avoid bulk restarts, blanket relaxations and large data moves.
- Protect writes at the client: three copies, a minimum of two, full confirmation, no unclean election, and retries with backoff and jitter.
- Prevent with design and habits: rack awareness, capacity headroom, dedicated controllers, health-gated rollouts, certificate tracking and a registry of temporary settings.
- Learn from each event: alert on shrinks paired with expands, rehearse the runbook, and hold a blameless review that ends in owned actions.