Quick revision
The short answer
I would not approve 960 partitions until we know where the time goes. Partitions are the unit of ordering and parallelism, but each one costs the brokers memory, files, replication and metadata, and small partitions make small batches. If consumers mostly wait on I/O per record, the fix is parallel processing by key inside each consumer, sized to the real throughput, with a migration to a smaller topic and a platform rule for future requests.
What to remember
In this answer, we saw that partitions are the unit of ordering and parallelism but carry real costs in broker resources, batching and rebalance time. We measure first, and when consumers mostly wait on I/O we add parallelism by key inside each consumer, batch writes to the sink and size partitions to the real throughput. Reducing the count needs a new topic and a careful migration. Share groups or a queue suit work without ordering, and platform guidance keeps the next team from repeating the pattern.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would not approve 960 partitions until we know where the time goes. Partitions are the unit of ordering and parallelism, but each one costs the brokers memory, files, replication and metadata, and small partitions make small batches. If consumers mostly wait on I/O per record, the fix is parallel processing by key inside each consumer, sized to the real throughput, with a migration to a smaller topic and a platform rule for future requests.
Why this question is asked
Growing partitions is the easy answer to a slow consumer, and it works for a while, which is why teams keep doing it. The bill arrives later as slow rebalances, broker strain and rising latency, exactly as in this scenario. Interviewers ask it to see whether we can push back with data and offer something better rather than just saying no. In this answer, we will look at what a partition really costs, how to measure where the consumer spends its time, the alternative design, how to reduce the partition count, when share groups fit, and the guidance a platform team should set.
1What a Partition Really Costs
A partition is an ordered, replicated log. Kafka gives each partition to exactly one consumer in a group, so the partition count sets the maximum number of consumers that can work in parallel. That is why teams add partitions when processing is slow.
But every partition replica is a set of log segment files with open file handles and index memory on a broker, a follower fetching it, an entry in the cluster metadata, and a leader that must be elected when a broker restarts. At 480 partitions with replication factor 3, the brokers carry 1,440 replicas for this one topic. Producers also batch per partition, so spreading the same traffic over more partitions makes each batch smaller, which means more requests, worse compression and higher latency. And a consumer group with hundreds of members and partitions takes longer to rebalance, which is the minutes-long pause the team is seeing.
| Effect | 480 partitions | 960 partitions |
|---|---|---|
| Replicas on brokers (RF 3) | 1,440 | 2,880 |
| Average producer batch size | baseline | about half |
| Consumers that can run in parallel | 480 | 960 |
| Rebalance work | large | larger |
| Time per record in a consumer | unchanged | unchanged |
2Measuring Where the Time Goes
Before deciding anything, we measure one consumer: time in poll(), time per record split into CPU and waiting, and the downstream calls it makes. Suppose each record does a 40 ms database write and 2 ms of CPU. Then one consumer thread handles about 24 records per second, and the topic needs 480 consumers because 95 percent of their time is spent waiting.
That waiting is the real problem. More partitions add more consumers that wait the same way. Instead, one consumer can keep many requests in flight, so the throughput per partition rises by an order of magnitude without touching the topic.
3The Alternative: Parallelism Inside the Consumer
We propose a design where the consumer processes records concurrently while keeping order per key. The poll thread hands each record to a lane chosen by a hash of its key; lanes run asynchronously or on virtual threads; completed offsets are tracked per partition and committed only below the oldest unfinished record. Where the sink allows it, we batch writes, for example 500 rows per database statement instead of 500 statements, which often cuts the cost per record far more than any threading change.
With 100 concurrent requests per consumer instead of one, 48 partitions with headroom would comfortably carry what 480 do today. We size the new partition count from the measured peak throughput and a target throughput per partition, plus room for two or three years of growth.
4Getting From 480 Back Down
Kafka cannot reduce the partition count of an existing topic, so going down means a new topic. Changing the count also moves keys to different partitions, which matters for ordering. A safe migration starts by deploying the new parallel consumer on the current topic, to prove the throughput. Then we create the new topic with, say, 48 partitions, switch producers to it, let consumers finish draining the old topic before they start on the new one so that per-key order holds, and delete the old topic once its retention has passed.
- Measure time per recordCPU vs waiting on I/O
- Mostly waiting on I/O?YesAdd parallelism inside the consumerNoProfile and fix the CPU cost
- Is per-key ordering needed?YesKey-based lanes in each consumerNoConsider share groups or a queue
- Size partitions to throughputMeasured peak plus headroom
- Migrate to a new topicDrain old, switch producers, retire
5 steps in order. Play them, or step through them one at a time.
5When Ordering Is Not Needed at All
Sometimes the answer is that nobody needs order. If records are independent jobs, consumers do not need to own partitions. Kafka's share groups, added through KIP-932, let many consumers read the same partitions and acknowledge records one by one, like a queue. They were early access in Kafka 4.0, so we check how mature they are in our version and whether our client supports them before relying on them. A dedicated queue is the other option for job-style work.
6Setting Platform Guidance
One rejected request does not stop the next one. The platform team should publish guidance: partition counts are sized from target throughput per partition with headroom, any request above a threshold (for example 100 partitions) gets a short review with the measurements, and a reference consumer with key-based parallelism is available so teams do not reach for partitions first.
7Follow-up questions
Would the new KRaft-based Kafka just handle 960 partitions?
KRaft, the built-in metadata quorum that replaced ZooKeeper in Kafka 4, handles far more partitions per cluster than before, so the controller is less of a limit. But the per-partition costs on brokers, the small batches and the consumer rebalance work remain, and none of it fixes a consumer that waits on I/O.
Would the new consumer rebalance protocol fix the minutes-long rebalances?
The newer group protocol from KIP-848, which moves assignment to the broker and rebalances incrementally, can shorten the pauses considerably, so it is worth enabling where our version and clients support it. It treats a symptom, though; the topic would still be far larger than the work needs.
What if the team cannot change its consumer soon?
Then we agree a small, temporary increase only if the measurements show it helps, and record a date for the parallel consumer work, so the exception does not become the design.
8Conclusion
In this answer, we saw that partitions are the unit of ordering and parallelism but carry real costs in broker resources, batching and rebalance time. We measure first, and when consumers mostly wait on I/O we add parallelism by key inside each consumer, batch writes to the sink and size partitions to the real throughput. Reducing the count needs a new topic and a careful migration. Share groups or a queue suit work without ordering, and platform guidance keeps the next team from repeating the pattern.
Open with
I would not approve 960 straight away, because partitions are not free. Each one is replicated log files, file handles, metadata and leader elections on the brokers, and spreading the same traffic over more partitions makes producer batches smaller and rebalances longer, which matches what the team is seeing.
Then, if they want more
So first I measure a consumer: if, say, 95 percent of its time per record is waiting on a database or an HTTP call, more partitions only add more waiting consumers.
The better design is parallelism inside the consumer: route records to lanes by a hash of the key so per-key order holds, keep many calls in flight, commit offsets only below the oldest unfinished record, and batch writes to the sink. With that, a few dozen partitions can carry what 480 carry today.
Kafka cannot shrink a topic, so we would migrate to a new topic sized from measured throughput plus headroom, draining the old one before switching to keep order. If the work does not need ordering at all, share groups, once mature in our version, or a queue can scale consumers beyond partitions.
Finally I would set platform guidance, with a review for any request above about 100 partitions and a reference parallel consumer.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Kafka 4.0
- 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 "Brokers carry many small partitions, rebalances take minutes, and end-to-end latency has...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-clients-in-depth/28e6c6b8ce/