Analytics consent

We use Google Analytics for basic traffic stats. kafkahelper stores no cluster data, config input, or personal data in the app.

Back to How To

How To

How to use cooperative sticky assignor

Cooperative sticky assignor is for consumer groups where full stop-the-world rebalances are too expensive. Use it when you want membership changes to move partitions incrementally instead of shuffling the whole group at once.

The classic pain with consumer rebalances is not that they happen. It is that eager rebalances can revoke everything, pause useful work, and make even small membership changes feel bigger than they should.

Cooperative sticky assignor changes that trade-off. Instead of tearing down the entire assignment immediately, it aims to move only the partitions that actually need to move and preserve stickiness where possible.

The actual configs involved

There are two slightly different configuration paths depending on whether you are using the classic consumer group protocol or the newer consumer protocol introduced in Kafka 4.x.

For classic consumer groups, the main switch is partition.assignment.strategy. Kafka's 4.2 consumer config reference lists org.apache.kafka.clients.consumer.CooperativeStickyAssignor as a supported assignor for that property.

For the newer consumer protocol, the group is driven more from the server side. The client enables it with group.protocol=consumer, and can optionally request a specific server-side assignor with group.remote.assignor.

  • Classic protocol config: partition.assignment.strategy=org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
  • Kafka 4.2 default list for classic consumers: org.apache.kafka.clients.consumer.RangeAssignor,org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
  • New consumer protocol enablement: group.protocol=consumer.
  • Optional server-side assignor override with the new protocol: group.remote.assignor=<assignor-name>.
  • If you use Kafka Streams, do not plug in CooperativeStickyAssignor directly. KIP-429 notes that Streams has its own assignor and its own upgrade path.

When it helps

Use cooperative sticky assignor when you have long-running consumers, expensive warm-up, or frequent rolling deploys that make eager rebalances noisy and expensive.

The use case is not every consumer group by default. It helps most when the cost of revoking all partitions at once is materially worse than a more incremental reassignment strategy.

What to check before rollout

All members of the group need to be able to participate in the same rebalance protocol. Mixed assignment strategies or incomplete client upgrades can turn a rollout into more churn rather than less.

You also want to confirm that your consumer code handles incremental revocation and reassignment cleanly. The assignor reduces disruption, but it does not remove the need for correct offset commit and shutdown behavior.

If your deployment model supports stable identities, it also helps to set group.instance.id to something durable such as the hostname or the pod name from a StatefulSet in EKS. That gives Kafka a stable member identity across restarts and usually reduces unnecessary churn during rolling changes.

  • Roll it out to groups where clients are on compatible versions first.
  • Watch rebalance count, rebalance duration, and duplicate processing during the transition.
  • Do not treat assignor choice as a substitute for fixing slow polls, overloaded consumers, or bad timeout sizing.

How to roll it out safely

Kafka's consumer config docs and KIP-429 both describe a staged migration path for classic consumer groups. The important detail is that you do not jump straight from a purely eager assignor list to a purely cooperative one during a rolling deployment.

Kafka 4.2 explicitly says the default assignor list is RangeAssignor, CooperativeStickyAssignor, which is designed to make the upgrade path easier. KIP-429 goes further and describes the safe rollout as a two-bounce process.

  • First rolling bounce: keep the old eager assignor in the list and add cooperative, for example partition.assignment.strategy=org.apache.kafka.clients.consumer.RangeAssignor,org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
  • Second rolling bounce: once every member is on compatible code, remove the eager assignor and leave only org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
  • If you are using the new 4.x consumer protocol instead, the relevant controls are group.protocol=consumer and optionally group.remote.assignor, but you still want a staged rollout so the whole group is not changing behavior blindly.

What problem it does not solve

Cooperative sticky assignor can reduce the blast radius of membership changes, but it does not make unhealthy groups healthy. If consumers are timing out because processing is too slow or max poll settings are wrong, the assignor cannot hide that forever.

It is best used as part of a cleaner rebalance strategy, not as a bandage for groups that are already unstable for other reasons.

Practical rollout sequence

Start with one or two candidate groups where rebalances are painful and client versions are under control. Change the assignor deliberately, deploy the group, and compare rebalance behavior before expanding to noisier fleets.

Track the metrics KIP-429 calls out around rebalance rate and latency, and pay attention to whether consumers now spend less time in disruptive full revocations.

If the group gets quieter and partition movement becomes more incremental, keep going. If duplicate processing or rebalance instability rises, stop and inspect client compatibility, partition.assignment.strategy, group.protocol, and consumer lifecycle behavior before rolling wider.