liveBook · Manning

CooperativeStickyAssignor

As explained in Apache Kafka in Action

The Cooperative Sticky Assignor is a Kafka partition-assignment algorithm that minimizes assignment changes and permits unaffected partitions to keep being consumed during rebalancing.

When a new consumer joins a Kafka consumer group, partitions may need to move between consumers. A conventional rebalance can pause consumption across the group, even when most assignments will not change. Cooperative Sticky Assignor minimizes assignment changes and lets consumers keep reading partitions that are unaffected by the move. section 9.4.2

Sticky Assignor tries to retain existing assignments, but still stops consumption during a rebalance. Cooperative Sticky Assignor adds a cooperative protocol: consumers first release partitions that must move, then a subsequent rebalance assigns those released partitions to their new consumers. Consumption pauses for the moving partitions, not the entire group. section 9.4.2

A third consumer joins

Two consumers are reading three partitions. When a third consumer joins, the first rebalance removes Partition 3 from Consumer 2. A second rebalance assigns that partition to Consumer 3. The other partitions continue to be consumed while Partition 3 changes hands. section 9.4.2

Figure 9.7 The Cooperative Sticky Assignor avoids stopping the world and rebalances by replacing a single rebalance by two consecutive ones. During the first rebalance, consumers are asked to let go of the partitions that should be moved to another consumer; in the second rebalance, the now dangling partitions are assigned to the consumers.
A screenshot of a computer game

AI-generated content may be incorrect.

Follow the two consecutive rebalances: first release the partition that must move, then assign it to its new consumer. section 9.4.2

Use CooperativeStickyAssignor as the consumer-group assignment strategy when reducing rebalance disruption matters. Still monitor rebalance counts, failures, and latency: frequent or slow rebalances can indicate group problems. Check assigned-partition metrics too, especially if a consumer receives no partitions for an extended period. section 9.4.2 section 15.3.3

How Apache Kafka in Action covers it

How deep it goes
Explains assignment retention and a two-rebalance handoff with a worked group example; does not provide configuration commands.
Examples
Tracks a third consumer joining a two-consumer, three-partition group and receiving a partition through two rebalances.
What it assumes
Builds on partitions, consumer groups, and rebalances, introduced as part of Kafka’s consumption workflow.
What you can do after
Operate/configure it as a consumer-group assignment strategy and monitor rebalances for disruption or anomalies.
How it connects
Connects consumer groups and the Kafka Rebalance Protocol with Sticky Assignor, Round Robin Assignor, static membership, and rebalance metrics.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.