Quick revision
The short answer
Within a consumer group, each partition is assigned to exactly one consumer, so a group can never have more active consumers than the topic has partitions. Four pods with concurrency 3 create 12 consumers, but the topic has only 6 partitions, so only 6 consumers receive data and the other 6 sit idle. A rebalance reassigns partitions when members join, leave, or miss heartbeats or max.poll.interval.ms; the classic eager protocol revokes everything first, the cooperative sticky assignor moves only what must move, and Kafka 4 makes the broker-driven consumer group protocol of KIP-848 generally available.
What to remember
In this answer, we saw that a consumer group assigns each partition to exactly one member, so 4 pods with concurrency 3 give 12 consumers of which only 6 receive data from a 6-partition topic. Rebalances happen when members join, leave, or miss heartbeats or max.poll.interval.ms. The eager protocol revokes everything first, the cooperative sticky assignor moves only the partitions that change owner, Kafka 4 makes the broker-computed KIP-848 protocol generally available, and static membership avoids rebalances during rolling restarts.
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.
Within a consumer group, each partition is assigned to exactly one consumer, so a group can never have more active consumers than the topic has partitions. Four pods with concurrency 3 create 12 consumers, but the topic has only 6 partitions, so only 6 consumers receive data and the other 6 sit idle. A rebalance reassigns partitions when members join, leave, or miss heartbeats or max.poll.interval.ms; the classic eager protocol revokes everything first, the cooperative sticky assignor moves only what must move, and Kafka 4 makes the broker-driven consumer group protocol of KIP-848 generally available.
Why this question is asked
Scaling consumers is one of the first things teams try when a Kafka topic falls behind, and it often does nothing. Interviewers ask this question because the answer needs a clear model of how a group shares partitions and of what a rebalance costs, and the arithmetic catches people who think concurrency always adds throughput. In this answer, we will recap consumer groups, do the calculation for the question's setup, walk through what triggers a rebalance, compare the eager, cooperative and new broker-driven protocols, and see how static membership helps during rolling restarts.
1A Quick Recap of Consumer Groups
A topic is split into partitions, ordered logs that are the unit of parallelism in Kafka. Consumers that share the same group.id form a consumer group, and together they consume the topic once: each partition is assigned to exactly one member of the group at a time, so each record is processed by one member. A consumer may own several partitions, but a partition is never shared between two members of the same group. That one rule explains the whole question: the number of partitions is the ceiling on how many consumers in one group can do useful work.
In Spring Kafka, a @KafkaListener with concurrency = 3 creates a ConcurrentMessageListenerContainer with three child containers, and each child has its own KafkaConsumer and its own thread. So each pod contributes three group members, not one.
2Doing the Arithmetic
Four pods each start three consumers, all in the same group, so the group has 4 x 3 = 12 members. The topic has 6 partitions. The assignor hands one partition to each of 6 members and nothing to the remaining 6. Those idle consumers still poll, send heartbeats and take part in every rebalance, but they never receive a record.
| Pod | Consumer threads | Partitions received |
|---|---|---|
| pod-a | c1, c2, c3 | p0, p1, p2 |
| pod-b | c4, c5, c6 | p3, p4, p5 |
| pod-c | c7, c8, c9 | none (idle) |
| pod-d | c10, c11, c12 | none (idle) |
Notice the last comment. The assignment is by member, not by pod, so the work may be spread unevenly between pods, with some pods fully idle. If we want 12 consumers to work, the topic needs at least 12 partitions. If 6 partitions are enough, then 2 pods with concurrency 3, or 3 pods with concurrency 2, would do the same work with fewer idle resources.
3What Triggers a Rebalance
A rebalance is the process of recomputing which member owns which partition. It happens when the group's membership or the topic changes. A new member joins, such as a pod starting. A member leaves cleanly, such as a pod shutting down. A member is considered dead, either because it stopped sending heartbeats for longer than session.timeout.ms (45 seconds by default in recent clients), or because it did not call poll() within max.poll.interval.ms (5 minutes by default), which means its processing is stuck or too slow. Partitions are added to a subscribed topic, or a new topic matches a pattern subscription.
While partitions are being moved, the affected ones are not consumed, and the offsets that the old owner had processed but not committed will be processed again by the new owner. So frequent rebalances mean lost throughput and duplicate processing.
4Eager, Cooperative and the New Protocol
With the classic eager protocol, used by the range and round-robin assignors, every rebalance starts by every member revoking all its partitions. The group then waits for all members to rejoin, the leader computes a new assignment and everyone starts again. For a short moment, nobody in the group consumes anything, even if only one partition needed to move. This is often called a stop-the-world rebalance.
The cooperative sticky assignor, CooperativeStickyAssignor, makes rebalances incremental. Members keep the partitions they will still own and only give up the ones that must move, which happens over two short rounds. Consumption of unaffected partitions continues. Recent Java clients include it in the default assignor list alongside the range assignor, and Spring Kafka uses whatever the client is configured with.
Kafka 4 goes further and makes the new consumer group protocol from KIP-848 generally available. We opt in with group.protocol=consumer. The group coordinator on the broker computes assignments itself, and each member learns its changes through its regular heartbeat, so there is no group-wide synchronisation barrier and rebalances are incremental by design. Client-side assignor settings do not apply in this mode; a server-side assignor is used instead. Check that your brokers and Spring Kafka version support it before enabling it.
| Style | What moves | Who computes the assignment |
|---|---|---|
| Eager (range, round-robin) | all partitions revoked, then reassigned | group leader, a client |
| Cooperative sticky | only partitions that change owner | group leader, a client |
| KIP-848 consumer protocol | only partitions that change owner | group coordinator on the broker |
5Static Membership for Rolling Restarts
During a rolling deploy, each pod stops and starts again. Normally, the stop makes the consumer leave the group, triggering one rebalance, and the start makes it join, triggering another. With four pods and three consumers each, a deploy can cause many rebalances in a few minutes.
Static membership changes this. We give each consumer a stable group.instance.id, for example built from the pod name and the thread index. A static member that shuts down does not send a leave request, and the coordinator keeps its partitions reserved until session.timeout.ms expires. If the same instance id comes back within that time, it simply gets its old partitions back with no rebalance at all. The trade-off is that if a pod dies for good, its partitions wait for the session timeout before moving, so we set the timeout a little longer than a normal restart, for example 60 to 90 seconds.
6Follow-up questions
How would static membership (group.instance.id) help during rolling restarts?
It lets a restarting consumer rejoin under the same identity without triggering a rebalance. A static member that stops does not leave the group; the coordinator holds its partitions until session.timeout.ms passes. If the pod is back within that window with the same group.instance.id, it resumes its old partitions directly. Other members never stop or move partitions, so a rolling deploy of four pods causes no rebalances instead of eight. The instance id must be unique per consumer, so with concurrency 3 we include the thread index, and the session timeout must be longer than a typical restart but short enough that a truly dead pod's partitions are reassigned in acceptable time.
Would increasing the partition count to 12 fix the idle consumers?
Yes, all 12 consumers would then get one partition each. But adding partitions to an existing keyed topic changes which partition each key maps to, which breaks per-key ordering during the transition. If ordering by key matters, it is safer to create the topic with enough partitions from the start, or to reduce the number of consumers to match.
7Conclusion
In this answer, we saw that a consumer group assigns each partition to exactly one member, so 4 pods with concurrency 3 give 12 consumers of which only 6 receive data from a 6-partition topic. Rebalances happen when members join, leave, or miss heartbeats or max.poll.interval.ms. The eager protocol revokes everything first, the cooperative sticky assignor moves only the partitions that change owner, Kafka 4 makes the broker-computed KIP-848 protocol generally available, and static membership avoids rebalances during rolling restarts.
Open with
In a consumer group, each partition is owned by exactly one consumer at a time, so the partition count is the upper limit on active consumers. In Spring Kafka, concurrency 3 means three KafkaConsumer instances per pod, each a separate group member, so four pods give twelve members.
Then, if they want more
With six partitions, six members get one partition each and the other six are idle. And it is per member, not per pod, so a whole pod could end up idle.
A rebalance reassigns partitions when a member joins or leaves, when it misses heartbeats for longer than session.timeout.ms, or when it does not call poll within max.poll.interval.ms, and also when partitions are added. With the classic eager protocol every member revokes all partitions first, so the whole group pauses.
The cooperative sticky assignor makes it incremental: members keep what they still own and only the moved partitions pause. Kafka 4 makes the KIP-848 consumer protocol generally available with group.protocol=consumer, where the broker's group coordinator computes assignments and members get changes through heartbeats, so there is no global barrier.
For rolling restarts I would add static membership with a stable group.instance.id per consumer, so a pod that comes back within the session timeout gets its partitions back without a rebalance. And for this setup I would either reduce consumers to six or increase partitions, keeping in mind that adding partitions changes key placement.
About this answer
- Last updated
- 12 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, Spring for Apache Kafka reference
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 "Explain how a Kafka consumer group assigns partitions to consumers and what happens...": https://scrivio-interview-library.netlify.app/spring-boot/kafka/647663ff41/
Spring Boot backend interviews, question 15 of 16 Back to the path
More in Apache Kafka with Spring