skip to content

What problem does Kafka 4.0's new consumer group protocol (KIP-848, group.protocol=consumer) solve compared with the classic rebalance protocol?

level: juniorimportance: should knowfreq 55%

answer

  1. no more group-wide barrier
  2. who computes the assignment now
  3. one heartbeat RPC does everything
  4. only affected members move partitions

basics

~20 s

It removes the classic protocol's group-wide rebalance barrier and its client-side leader: the broker's group coordinator computes assignments, and each consumer reconciles incrementally through heartbeats, so one member's change no longer stalls the whole group.

solid answer

~40 s

Under the classic protocol every rebalance is a group-wide barrier: all members rejoin with JoinGroup, a member acting as leader runs the client-side assignor, and SyncGroup hands out the result, so one slow or flapping member stalls everybody and the assignment logic lives in every client. KIP-848, generally available since Kafka 4.0, moves assignment onto the broker's group coordinator, which runs a server-side assignor (`uniform` by default, or `range`). Each consumer talks to it through a single RPC, `ConsumerGroupHeartbeat`: it reports the partitions it owns, receives its target, revokes what it must give up and picks up new partitions once their previous owner has released them. Members untouched by a change simply keep consuming. A consumer opts in with `group.protocol=consumer`; in 4.x the client default is still `classic`.

go deeper

for a junior

Recall the one-line contrast: classic rebalances stop the whole group at a barrier with a client leader; Kafka 4.0's consumer protocol lets the broker assign partitions and moves only the members affected.

for a middle

Explain the heartbeat-driven loop: report owned partitions, receive a target, revoke first, then take freed partitions. Know that group.protocol=consumer is opt-in in 4.x.

for a senior

Show you know what does not change, such as single ownership per partition, offsets and listener callbacks, and where cost moves: assignment now runs on the broker's coordinator.

for a principal

Frame the protocol as a shift of control from application teams to the cluster operator: broker configs now decide assignment and liveness for every group, which simplifies clients but centralises risk.

## Why the classic protocol hurt A Kafka **consumer group** spreads the partitions of the subscribed topics across its members so that each partition has exactly one owner at a time. The original way of agreeing on who owns what is now called the **classic protocol**. Its rebalance works as a **synchronization barrier**: - every member must send a JoinGroup request and wait until all the others have joined too; - one member, elected as **leader**, runs the assignor named in its own `partition.assignment.strategy` and computes the plan for the whole group; - the plan travels back through SyncGroup to every member. Three things follow. A single slow, paused or crash-looping member delays the rebalance for all members. The assignment logic is code inside every client, so fixing an assignor bug means upgrading every application. And the timing knobs (heartbeat interval, session timeout) are chosen per client, so two deployments of the same group can disagree. Incremental cooperative rebalancing softened the first problem by letting members keep partitions that do not move, but members still have to go through the join barrier, and a moved partition needs a second rebalance round. ## What KIP-848 changes **KIP-848**, "The Next Generation of the Consumer Rebalance Protocol", became **generally available in Apache Kafka 4.0** after an early-access release in 3.7. The Kafka documentation describes it as fully incremental, with no global synchronization barrier. It changes who does what: | Concern | Classic protocol | Consumer protocol (`group.protocol=consumer`) | |---|---|---| | Who computes the assignment | a client acting as leader | the broker's group coordinator | | Assignor | client-side `partition.assignment.strategy` | server-side `uniform` or `range`, picked with `group.remote.assignor` | | RPCs for membership and assignment | JoinGroup, SyncGroup, Heartbeat | `ConsumerGroupHeartbeat` only | | Heartbeat interval and session timeout | client configs | broker configs `group.consumer.heartbeat.interval.ms` and `group.consumer.session.timeout.ms` | | Effect of one member changing | every member goes through the barrier | only the members whose partitions move do any work | ## What travels in the heartbeat The single `ConsumerGroupHeartbeat` RPC replaces JoinGroup, SyncGroup and Heartbeat. To keep it cheap, most request fields are sent only when they change: - the request carries the **member epoch**, the subscribed topic names or regex, an optional **server-side assignor** name, the rebalance timeout and the partitions the member currently owns; - the response carries the member's new epoch, the **heartbeat interval** the broker wants, and, when it changes, the assignment the member may use immediately. Because the client always reports what it owns, the coordinator can tell exactly when a partition has been given up and is safe to hand to someone else. ## How one change flows through the group Suppose a new consumer joins a group of five: 1. The new member sends `ConsumerGroupHeartbeat` with member epoch 0, meaning "I want to join", and its subscription. 2. The coordinator records the change, bumps the **group epoch** and computes a new **target assignment** with the server-side assignor. 3. The members that must give up a partition learn it from their next heartbeat response, finish the work on it and stop reporting it as owned. 4. Once a partition has been released, the coordinator gives it to its new owner in that member's next heartbeat response. 5. The members that keep all their partitions just carry on fetching. Nobody waits for anybody they do not exchange partitions with. That is the core improvement: rebalance cost scales with what changes, not with the size of the group. ## Opting in, and where the defaults stand On the broker side the protocol is switched on automatically once a cluster's upgrade to 4.0 is finalized; it is governed by the `group.version` feature. On the client side it is **opt-in**: the `KafkaConsumer` config `group.protocol` still defaults to `classic` in every 4.x release, and you set `group.protocol=consumer` to use the new protocol. The documented timeline, from KIP-1274, is expected to be: - **3.7** early access; - **4.0** GA, production-ready; - **5.0** `KafkaConsumer` defaults to the consumer protocol while still supporting classic; - **6.0** `KafkaConsumer` supports only the consumer protocol, while the broker keeps classic for older clients. ## What stays the same The new protocol changes how membership and assignment are agreed, not what a consumer group is: - each partition still has exactly one owner inside the group, so per-partition ordering works as before; - offsets are still committed to `__consumer_offsets`, and committed offsets are not reset by switching protocols; - your `ConsumerRebalanceListener` callbacks still fire when partitions are revoked, assigned or lost; - the `poll()` loop and `max.poll.interval.ms` still matter for liveness. A different kind of group in which several consumers share one partition and acknowledge records individually also arrived in Kafka 4.x; that is share groups, a separate feature with its own consumer class, not a mode of this protocol.

  • Does switching to group.protocol=consumer change how offsets are committed or stored?
    No. Offsets are still committed to `__consumer_offsets` with `commitSync`, `commitAsync` or auto-commit, and existing committed offsets carry over. What changes is fencing: under the consumer protocol each commit carries the member epoch, and the coordinator rejects a commit for a partition the member no longer owns or is no longer revoking.
  • Is the consumer protocol on by default once the brokers run Kafka 4.0?
    Only on the broker side. When the 4.0 upgrade is finalized the coordinator accepts consumer-protocol members, but every `KafkaConsumer` keeps using `classic` until it is configured with `group.protocol=consumer`. KIP-1274 plans the client default to flip in 5.0.

Classic rebalancing is a fire drill where the whole office must reach the car park before anyone may go back in; the new protocol is a desk-booking system where only the people swapping desks get up, each when their new desk is free.

  • The consumer protocol is the default for every KafkaConsumer since Kafka 4.0
  • Under the new protocol a client-side group leader still computes the assignment
  • KIP-848 lets several consumers in one group read the same partition
  • The new protocol still makes every member rejoin when one member joins
  • Switching protocols resets the group's committed offsets

Assumes Kafka 4.0 or later: KIP-848 is GA there, while the KafkaConsumer default for group.protocol is still classic in 4.x.