Scrivio Interview library
ScenarioIntermediate6 min read · updated 13 November 2026

A consumer group reading a 48-partition topic tops out at 20 MB/s although brokers and network have plenty of headroom.

Metrics show fetch-size-avg around 60 KB, fetch-latency-avg of 3 ms, a few hundred fetches per second, and poll-idle-ratio-avg near 0.05. Where is the bottleneck and what do you change?

poll-idle-ratio-avg near 0.05 means the consumer threads spend about 95 percent of their time processing records between polls and only 5 percent waiting for data, so the bottleneck is processing, not fetching; the small 60 KB fetches with 3 ms latency are a symptom of rare polls, not the cause. Fix processing first: batch writes to the sink, remove per-record synchronous calls, add consumers up to the 48 partitions, or process in parallel inside each consumer. Only once the idle ratio is high while lag still grows should we tune fetching, for example raising fetch.min.bytes to 64 KB to 1 MB.

Why this question is asked

When a consumer cannot keep up, the instinct is to tune the fetch settings, because fetching is the Kafka part and processing feels like 'our code'. Interviewers ask this scenario with real metric values to see whether we read the evidence before turning knobs. In this answer, we will recap what each metric measures, read them together to find the bottleneck, confirm it, fix processing, and see when fetch tuning finally matters.

1A Quick Recap of the Metrics

fetch-size-avg is the average number of bytes returned per fetch request. fetch-latency-avg is the average time a fetch request takes, from send to response. The fetch rate is how many fetch requests the consumer sends per second. poll-idle-ratio-avg is the fraction of time the consumer's application thread spends inside poll() waiting, as opposed to outside poll() running our code. A ratio near 1 means the thread is mostly waiting for data; near 0 means it is mostly busy processing.

A related metric, time-between-poll-avg, measures how long our code takes between two poll() calls, which is the processing time per batch.

2Reading the Numbers Together

Start with poll-idle-ratio-avg at 0.05. The application threads spend 95 percent of their time in our processing code. If fetching were the bottleneck, they would be sitting in poll() waiting for data, and the ratio would be high.

The fetch numbers agree. A 3 ms fetch latency means the brokers answer immediately; they are not slow and there is no long-poll waiting, because there is always data available. A few hundred fetches per second at 60 KB is roughly 12 MB to 20 MB per second, matching the observed throughput. Fetches are small because the consumer only fetches for partitions whose buffered data has been consumed, and our slow processing consumes it a little at a time, so each new fetch only refills a little. The network could deliver far more; the consumer simply does not ask for more because it cannot use it.

What the metrics say
MetricValueMeaning
poll-idle-ratio-avgabout 0.0595% of time spent processing: processing-bound
fetch-latency-avg3 msbrokers answer at once; not a broker problem
fetch-size-avgabout 60 KBsmall refills of a buffer that drains slowly
fetch ratea few hundred per secondmultiplied by 60 KB, about the observed 20 MB/s

3Confirming the Diagnosis

Before changing anything, we confirm with two more measurements. time-between-poll-avg should be large and close to the batch processing time. And timing inside our code, for example a Micrometer timer around each stage, should show where the time goes: deserialisation, a lookup call, the sink write. A profiler snapshot under load, with async-profiler or Java Flight Recorder, often shows the answer in one picture, such as most of the CPU in JSON parsing or most of the wall time blocked in a JDBC call.

Remember that decompression and deserialisation run in the client, on our processing time. With compressed topics, a significant share of 'processing' can be the consumer decoding batches, which is another reason not to blame the network.

4Fixing the Processing

The usual culprits are per-record synchronous calls. Writing one row per record to a database, with a round trip each, caps throughput at one row per round trip. Batching the writes turns hundreds of round trips into one.

Java
// before: one round trip per record, about 2 ms each -> 500 records/s per thread
for (ConsumerRecord<String, Event> r : records) {
jdbc.update("INSERT INTO events VALUES (?, ?, ?)", r.key(), r.value().type(), r.value().json());
}
// after: one batched round trip per poll -> tens of thousands of records/s per thread
jdbc.batchUpdate("INSERT INTO events VALUES (?, ?, ?)",
records.stream().map(r -> new Object[]{ r.key(), r.value().type(), r.value().json() }).toList());

Notice that this change alone can multiply throughput many times without touching a single Kafka setting. Other fixes in the same spirit: replace per-record lookups with a cache or a batched lookup, and move heavy CPU work off the polling thread.

5Adding Parallelism

If processing is already efficient, we add parallelism. The simplest step is more consumers in the group: with 48 partitions, the group can use up to 48 consumer threads, for example 8 instances with a Spring Kafka concurrency of 6. Beyond the partition count, extra consumers sit idle, so further parallelism has to happen inside a consumer, for example processing records of different keys on a worker pool while keeping each key's records in order, with commits only up to the lowest unfinished offset.

Step throughFinding and fixing the bottleneck
  1. Is poll-idle-ratio-avg low?
    YesProcessing-bound: profile our codeNoConsumer waits for data
  2. Batch sink writes, remove per-record callsbiggest wins usually here
  3. Add consumers up to 48 partitionsthen parallelise inside each consumer
  4. Idle ratio high and lag still growing?
    YesNow tune fetch settingsNoDone: processing keeps up

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

Fetch tuning is the last step, not the first.

6When Fetch Tuning Does Matter

Once processing is fast, the picture flips: poll-idle-ratio-avg rises because the threads wait for data, and if lag is still growing, fetching has become the limit. Then raising fetch.min.bytes, for example to 64 KB or up to 1 MB, with a modest fetch.max.wait.ms such as 100 ms to 500 ms, makes the brokers send fewer, fuller responses, and a larger max.partition.fetch.bytes lets each partition contribute more per fetch. Each change should be measured against throughput and memory, since bigger fetches also mean a bigger buffer.

7Follow-up questions

Why not raise max.poll.records to get more per poll?

It only changes how many buffered records each poll() hands to our code, not how fast we process them. Here the time is in processing, so bigger batches per poll would just make each loop longer, and might push the consumer past max.poll.interval.ms.

Could the brokers still be the limit with 3 ms fetch latency?

Very unlikely. A broker under pressure shows higher fetch latency and request queue times, and with a low idle ratio the consumer is not waiting for brokers anyway. We would check broker request metrics only if the consumer evidence were ambiguous.

8Conclusion

In this answer, we read the metrics together. A poll-idle-ratio-avg of 0.05 means the threads spend nearly all their time processing, 3 ms fetch latency means brokers answer at once, and small 60 KB fetches are just refills of a slowly draining buffer, so the bottleneck is processing. We confirm with time-between-poll and stage timings, fix processing by batching sink writes and removing per-record calls, then add consumers up to the 48 partitions or parallelise within them. Fetch settings such as fetch.min.bytes become worth tuning only when the idle ratio is high and lag still grows.

What to say in the interviewAbout 80 seconds aloud

Open with

The key number is poll-idle-ratio-avg near 0.05. That metric is the share of time the consumer thread spends waiting inside poll, so 0.05 means 95 percent of the time is spent in our processing code between polls.

Then, if they want more

If fetching were the problem, threads would be waiting for data and the ratio would be high. The other numbers fit: a 3 millisecond fetch latency means the brokers answer immediately, and a few hundred fetches a second at about 60 kilobytes each is the 20 megabytes a second we see.

The fetches are small because the consumer only refills partitions whose buffered data has been used, and slow processing uses it a bit at a time. So it is a symptom, not the cause. I would confirm with time-between-poll-avg and timers around each processing stage, maybe a profiler snapshot, remembering that decompression and deserialisation also count as processing.

Then fix processing: batch the writes to the sink instead of one round trip per record, remove per-record synchronous calls, add consumers up to the 48 partitions, and parallelise inside a consumer by key if needed.

Only when the idle ratio goes up and lag still grows would I tune fetching, raising fetch.min.bytes to somewhere between 64 kilobytes and a megabyte with a moderate fetch.max.wait.ms.

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 "Metrics show fetch-size-avg around 60 KB, fetch-latency-avg of 3 ms, a few hundred...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-clients-in-depth/d9cb17211e/