On this page
Kafka Improvement Proposal
KIP-429: cooperative rebalancing, stop only what has to move
KIP-429 ended the stop-the-world rebalance for classic consumer groups. With the old eager protocol every member gave up all of its partitions whenever someone joined or left. With the cooperative-sticky assignor from KIP-429, members keep the partitions they will still own and only the partitions that move pause.
- Proposal
- KIP-429, Kafka Consumer Incremental Rebalance Protocol
- Status
- Shipped Since Kafka 2.4 (2019), opt-in through the cooperative-sticky assignor.
- Area
- Consumer groups and queues
- Proposal page
- KIP-429 on the Apache Kafka wiki
Why it was needed
In the eager protocol a rebalance starts with every member revoking every partition, then the leader computes a new assignment and hands partitions out again. Consumption stops for the whole group for the length of the rebalance, even if one new member only needs one partition. In large groups, or during a rolling restart that triggers one rebalance per instance, those pauses add up to minutes of lag.
What it changes
Rebalancing becomes two short rounds. In the first, every member reports what it owns and the assignor computes a sticky target; members keep everything that stays theirs and revoke only what moves. In the second round, the revoked partitions are handed to their new owners. Partitions that do not change owner are consumed without a pause the whole time.
How to use it
- Set partition.assignment.strategy=org.apache.kafka.clients.consumer.CooperativeStickyAssignor on every member.
- To migrate a live group, roll the members once with both the old assignor and CooperativeStickyAssignor in the list, then roll again with only the cooperative one.
- Kafka Streams uses cooperative rebalancing by default since 2.4.
Where it stands
Shipped in Kafka 2.4. Since Kafka 3.0 the consumer default list is RangeAssignor followed by CooperativeStickyAssignor, so dropping RangeAssignor switches a group to cooperative rebalancing with one rolling restart. It remains the best option for groups on the classic protocol.
What comes next
KIP-848 is the successor: it moves assignment to the broker and makes every rebalance incremental. KIP-1274 (accepted) sets the end of the classic protocol in KafkaConsumer: Kafka 4.3 recommends the new protocol in the logs, Kafka 5.0 makes group.protocol=consumer the client default and deprecates classic, and Kafka 6.0 removes classic from KafkaConsumer. Brokers keep supporting classic groups for other clients.
See it in the simulator
- Kafka eager vs cooperative rebalancing (cooperative-sticky) (Rebalance: eager vs cooperative) Step 6: Cooperative rebalance - only the mover stops Open at this step: Kafka eager vs cooperative rebalancing (cooperative-sticky)
- Kafka eager vs cooperative rebalancing (cooperative-sticky) (Rebalance: eager vs cooperative) Step 3: Eager rebalance - stop-the-world Open at this step: Kafka eager vs cooperative rebalancing (cooperative-sticky)
The simulator labels a cooperative-sticky group with the KIP-848 consumer protocol. In Kafka, cooperative-sticky is an assignor of the classic protocol.
Sources
- KIP-429: Kafka Consumer Incremental Rebalance Protocol
- KIP-1274: Deprecate and remove support for Classic rebalance protocol in KafkaConsumer