Scrivio Interview library
DebuggingIntermediate7 min read · updated 13 November 2026

Producer p99 latency on a cluster jumps from 8 ms to 450 ms whenever an analytics job starts re-reading five days of history from a busy topic.

Disk read IOPS on the brokers rise from almost zero to their limit. Explain the mechanism and your options.

Consumers that keep up read from the page cache, but the analytics job reads five-day-old segments that are only on disk. Its reads saturate the disks and push recent pages out of the cache, so producer writes, follower fetches and tail consumers all wait on the same busy disks, and acks=all latency rises everywhere. We throttle the backfill with a consumer_byte_rate quota, move history reads to tiered storage or another copy of the data, and in the longer term add memory, faster disks or follower fetching for heavy readers.

Why this question is asked

This is one of the classic Kafka incidents: nothing is wrong with the producers, nothing changed in the cluster, and yet the latency of a critical service jumps by fifty times whenever someone runs a big replay. Interviewers like it because the cause is invisible unless we understand how Kafka uses memory and disks, and because the right answer combines an immediate fix with a design change. In this answer, we will recap why healthy Kafka reads almost never touch the disk, follow what the backfill does step by step, see how it reaches the producers, prove the cause, and then go through our options.

1A Quick Recap: Why Healthy Brokers Barely Read From Disk

Kafka writes records through the OS page cache, the memory Linux uses to hold recently used file blocks, and does not cache data on its own heap. A consumer that is a few seconds behind the producers asks for data written a few seconds ago, and those pages are still in memory. So in a healthy cluster, disk read IOPS are close to zero even when consumers read hundreds of MB per second. That is exactly what our brokers showed before the job started.

The disks are still busy with writes, because Linux flushes dirty pages, pages that were written in memory but not yet on disk, in the background. Producers with acks=all also wait for followers to fetch and append the new data before the leader answers. All of that assumes the disks have time to spare.

2What the Backfill Does to the Brokers

The analytics job starts reading from five days ago. Those segments were evicted from the page cache long ago, so every fetch becomes a real disk read. The job reads as fast as it can, often across many partitions at once, and disk read IOPS climb from nearly zero to the device limit.

Step throughHow a history read slows down producers
  1. Backfill fetches 5-day-old offsetsPages not in cache, so reads go to disk
  2. Disk read IOPS hit the device limitQueue depth and service time rise
  3. Old pages fill the page cacheRecent pages are evicted to make room
  4. Writes and flushes wait behind readsSame disks, same queues
  5. Followers and tail consumers miss the cacheTheir fetches now read from disk too
  6. acks=all waits for slow followersProducer p99 goes from 8 ms to 450 ms

6 steps in order. Play them, or step through them one at a time.

Two separate effects hurt the rest of the cluster. The first is contention: the same disks now serve heavy reads and the normal writes, so flushes and appends wait in longer queues. The second is cache pollution: every old block read by the backfill lands in the page cache and pushes out a recent block. Followers and tail consumers, which used to read recent data from memory, now sometimes miss and read from disk as well, adding even more load.

Producers feel it through acks=all. The leader answers a produce request only after all in-sync replicas have fetched the new records. If followers are slow because their fetches and writes are queued behind the backfill's reads, every produce waits longer, and p99 latency jumps from 8 ms to 450 ms. The producers did nothing wrong; they share disks with a reader that took them over.

3Proving the Page Cache Is the Cause

Before changing anything, we want evidence that ties the latency to the backfill and the cache, not just a coincidence. We line up the start and end times of the analytics job with the latency graph, then look at the brokers themselves.

Java
# Disk: reads jump, utilisation and wait time rise when the job starts
iostat -x 5 # r/s from ~0 to the device limit, %util near 100, r_await up
# Page cache hit ratio over time (bcc tools)
cachestat 5 # HITS drop and MISSES jump while the backfill runs
# Which segment files are in memory, for a recent and an old segment
fincore /var/kafka/data/events-3/00000000000081200000.log # recent: mostly resident
fincore /var/kafka/data/events-3/00000000000052000000.log # old: being pulled in
# Kafka side
# kafka.network RequestMetrics: Produce RemoteTimeMs p99 up (waiting for followers)
# Fetch LocalTimeMs up for followers; consumer lag for the analytics group falling fast

If disk reads, cache misses and produce RemoteTimeMs (the time a produce waits for replicas) all rise together when the job starts and fall when it stops, we have our mechanism. A strong confirmation is to run the same replay in staging with a quota, then without one, and watch the same metrics move.

4Immediate Fix: Throttle the Backfill With a Quota

Kafka client quotas limit how many bytes per second a client may produce or fetch. When a client goes over, the broker delays its responses so its average rate stays under the limit. We apply a consumer quota to the analytics job's user or client id.

Text
kafka-configs.sh --bootstrap-server broker1:9092 --alter \
--entity-type users --entity-name analytics-backfill \
--add-config 'consumer_byte_rate=20971520' # 20 MB/s per broker
# Completed updating config for user analytics-backfill.

We pick the number from the disks' headroom: if each broker's disks can comfortably serve 60 MB/s of extra reads, a 20 MB/s limit leaves plenty of room. The job takes longer, but producers stay at their normal latency. Notice that the quota applies per broker, so a job reading from all twelve brokers can still read up to twelve times the limit in total.

5Structural Fixes: Serve History Somewhere Else

Quotas protect the cluster but make history slow. If replays are a regular need, we stop serving them from the brokers' local disks. Tiered storage moves older segments to object storage such as S3; a replay then reads from the remote store through a separate thread pool, without competing for local disks or polluting the page cache with five-day-old blocks. Another option is to land the topic in a data lake (Iceberg tables on object storage, for example) and point analytics there, so Kafka only serves real-time readers.

In the longer term, more memory per broker gives the page cache more room, faster NVMe disks raise the I/O ceiling, and scheduling big replays off-peak reduces the overlap with the busiest producer hours. We can also let heavy readers fetch from follower replicas (client.rack with a rack-aware replica selector), which takes their load off the leaders, though the followers still share disks with their own replication work.

6Follow-up questions

How would you prove the page cache is the cause before changing anything?

We correlate the job's start and end with the latency spike, then show the mechanism on the brokers: iostat shows read IOPS and await time rising to the device limit, cachestat shows the page cache hit ratio dropping, fincore shows old segment files being pulled into memory, and Kafka's request metrics show produce RemoteTimeMs and follower fetch times rising. If all of these move together and return to normal when the job stops, the cause is clear. Reproducing it in staging, with and without a quota, makes it certain.

Would adding more partitions or brokers fix it?

More brokers spread the history reads over more disks and add more page cache, so the effect shrinks, but a fast enough replay can still saturate them. Partitions alone do not help, because the problem is disk and cache capacity, not parallelism. Separating the workloads with quotas or tiered storage is cheaper and more reliable.

Why do consumers near the head suffer too?

Because the backfill's reads evict recent pages from the page cache. A tail consumer that is a minute behind may find some of its data has been pushed out and must now read it from disk, behind the backfill's own requests.

7Conclusion

In this answer, we saw how a historical replay hurts a whole cluster: its reads go to disk, saturate the devices and pull old blocks into the page cache, so writes, follower fetches and tail consumers all slow down, and acks=all turns that into producer latency. We prove it by lining up disk, cache and request metrics with the job, contain it with a consumer_byte_rate quota, and fix it properly by serving history from tiered storage or a separate copy, with more memory, faster disks and careful scheduling as longer-term help.

What to say in the interviewAbout 90 seconds aloud

Open with

The key fact is that healthy Kafka consumers read from the page cache, which is why disk reads are almost zero normally. The analytics job reads five-day-old data that is only on disk, so every fetch becomes a disk read and the disks hit their IOPS limit.

Then, if they want more

Two things follow. The producers' writes and the followers' replication now queue behind those reads on the same disks. And the old blocks being read fill the page cache and push out recent ones, so even followers and consumers near the head start missing the cache.

With acks=all the leader waits for the followers, so producer p99 jumps from 8 ms to 450 ms. Before changing anything, I would prove it: line up the job's timing with the latency, then show iostat reads and await going up, cachestat hit ratio dropping, and produce RemoteTimeMs rising, all together.

The immediate fix is a consumer_byte_rate quota on the analytics user, sized to the disk headroom, remembering that it applies per broker. The job runs slower but producers are safe. If replays are a regular thing, I would move them off local disks: tiered storage, so old segments come from object storage, or a lake copy for analytics.

Longer term, more RAM, faster disks, off-peak scheduling, and maybe follower fetching for heavy readers.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Disk read IOPS on the brokers rise from almost zero to their limit. Explain the...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-internals/2d6afda9c6/