Consumer Group Rebalancing: Eager vs. Cooperative

Eager Rebalancing — The Naive Approach

Eager rebalance when consumer C joins a group where A owns P0, P1, P2 and B owns P3, P4. Step 1: A drops P0, P1, P2 and B drops P3, P4, so everyone stops. Step 2: wait for every member to check in, with no partition being processed. Step 3: A gets P0, P1, B gets P2, P3, C gets P4, and everyone resumes.
Eager: one consumer joins, and every consumer stops

The problem: A and B had to stop even though C's arrival didn't actually move their partitions. In a 100-consumer group, one new consumer joining pauses all 100 — 10–30 seconds of zero processing.

KIP-429: Cooperative/Incremental Rebalancing (Kafka 2.4+)

Instead of "revoke everything, then assign," figure out which partitions are actually moving, and only revoke those. Two rounds:

Cooperative rebalance (KIP-429) when consumer C joins a group where A owns P0, P1, P2 and B owns P3, P4. Round 1, the probe: everyone sends JoinGroup saying what it currently owns; the coordinator computes the target A gets P0 and P1, B gets P3 and P4, C gets P2; A revokes only P2 and B revokes nothing. Round 2, assign: everyone sends JoinGroup again, and C is assigned P2 and starts consuming. A and B keep processing P0, P1 and P3, P4 the whole time.
Cooperative: only the partition that moves stops moving
EagerCooperative
Who stops?EveryoneOnly consumers losing partitions
Rounds12
Gap in processingAll partitions, all consumersOnly partitions actually moving

Static Membership: group.instance.id

The problem: restarting one consumer causes two rebalances, even though the same worker comes straight back.

Why a restart normally costs two rebalances

By default, a consumer's identity in the group is a random member.id. It gets a new one every time it starts. So the coordinator can't tell "worker-3 restarted" apart from "worker-3 left and a stranger joined".

  1. Worker-3 shuts down. It sends LeaveGroup (or, if it crashed, its heartbeats stop and it times out). → Rebalance #1: its partitions are handed to the other consumers.
  2. Worker-3 starts again with a new member.id and sends JoinGroup. → Rebalance #2: partitions are moved again to include it.

A rolling restart of 10 consumers therefore causes about 20 rebalances.

The fix: give each consumer a fixed name

Set group.instance.id to something that stays the same across restarts, such as the pod name. Now the coordinator knows it's the same worker:

  1. Worker-3 shuts down. It does not send LeaveGroup. The coordinator keeps its partitions reserved for it. No rebalance.
  2. Worker-3 comes back within session.timeout.ms using the same group.instance.id. The coordinator hands back the same partitions. No rebalance.
  3. If it doesn't come back in time, the coordinator treats it as dead and runs one normal rebalance.
Without group.instance.idWith group.instance.id
IdentityRandom member.id, new on every startFixed name you choose (e.g. pod name)
On shutdownSends LeaveGroup → rebalanceStays silent; partitions are held for it
On restartJoins as a new member → rebalanceGets its old partitions back
Rebalances per restart20 (if back within the timeout)

The cost: while worker-3 is down, nobody reads its partitions. Their messages wait until it returns, or until the timeout expires.

partition.assignment.strategy=org.apache.kafka.clients.consumer.CooperativeStickyAssignor
group.instance.id=worker-pod-3
session.timeout.ms=45000

The two settings cover different cases:

  • Static membership removes rebalances for the common case: planned restarts and deploys.
  • Cooperative sticky assignment keeps the remaining rebalances small (scaling up or down, real failures). Only the partitions that actually move are paused, not everyone's.