On this page
Kafka Improvement Proposal
KIP-54: the sticky assignor, move as few partitions as possible
KIP-54 added the StickyAssignor to Kafka consumers. When a group rebalances, it still aims for a balanced assignment, but it keeps every member on the partitions it already owns wherever it can, so as little as possible moves. The cooperative-sticky assignor of KIP-429 uses the same logic with incremental rebalancing.
- Proposal
- KIP-54, Sticky Partition Assignment Strategy
- Status
- Shipped Since Kafka 0.11 (2017); its logic lives on in CooperativeStickyAssignor (2.4).
- Area
- Consumer groups and queues
- Proposal page
- KIP-54 on the Apache Kafka wiki
Why it was needed
The range and round-robin assignors compute a fresh layout every time, ignoring who owned what. A single consumer joining could shuffle most partitions to new owners, throwing away caches and local state and causing more reprocessing than necessary.
What it changes
The leader of the group runs the assignor with the current ownership as input. The StickyAssignor balances the partition count first and then keeps as many existing assignments as it can. It still runs on the eager protocol, so every member revokes everything during the rebalance and gets most of it back; CooperativeStickyAssignor, added in 2.4, keeps the same layout but only revokes the partitions that actually move.
How to use it
- Set partition.assignment.strategy=org.apache.kafka.clients.consumer.StickyAssignor, or better CooperativeStickyAssignor, on every member of the group.
- With group.protocol=consumer (KIP-848) client-side assignors are not used; the broker assigns partitions.
Where it stands
Shipped in Kafka 0.11. Since Kafka 3.0 the consumer default is RangeAssignor followed by CooperativeStickyAssignor. The sticky idea also guides the broker-side assignors of the new consumer group protocol.
What comes next
Client-side assignors are on their way out for KafkaConsumer: KIP-1274 deprecates partition.assignment.strategy in Kafka 5.0 together with the classic protocol, and removes it in 6.0.
See it in the simulator
- Kafka partition assignors: range vs round-robin vs sticky (Assignors: range vs round-robin vs sticky) Step 3: sticky - keeps the current layout (zero movement) Open at this step: Kafka partition assignors: range vs round-robin vs sticky
- Kafka partition assignors: range vs round-robin vs sticky (Assignors: range vs round-robin vs sticky) Step 1: range - contiguous blocks Open at this step: Kafka partition assignors: range vs round-robin vs sticky