Video in progress
What's the difference between eager and cooperative (incremental) rebalancing, and how do you enable it in a Spring application?
In eager, when a rebalance starts every consumer gives up its partitions and the whole group stops. In cooperative, only the partitions that must move to another consumer are given up, and the rest keep being read.
📖 Answer
Eager (RangeAssignor, RoundRobinAssignor) is "stop the world". With 6 pods and 60 partitions, when one more pod joins, everyone releases all 60 partitions and takes them again.
Cooperative (CooperativeStickyAssignor) works in two phases: first it determines which partitions have to move and revokes only those, then in the next phase hands them to their new owner. The other 50 partitions don't stop for even a second.
spring:
kafka:
consumer:
properties:
partition.assignment.strategy: org.apache.kafka.clients.consumer.CooperativeStickyAssignor
In the Kafka 3.x client the default list is RangeAssignor, CooperativeStickyAssignor, which means eager is still used, but the path to cooperative is open.
Be careful when migrating a running group: all members must use the same protocol. The safe way is a two-step rolling deploy: first add both to the list, then remove the old one.
In Kafka 4.0 the new consumer rebalance protocol (KIP-848, group.protocol=consumer) became GA, and there the assignment is computed on the broker side. If you're on a newer version, look into that.
Sign up to mark studied questions and save your progress.