On this page
Kafka Improvement Proposal
KIP-345: static membership, restart a consumer without a rebalance
KIP-345 gives a consumer a fixed identity, group.instance.id. When a static member restarts within session.timeout.ms, it rejoins under the same identity and gets the same partitions back, with no rebalance for the rest of the group. Rolling restarts and short crashes stop shuffling partitions around.
- Proposal
- KIP-345, Introduce static membership protocol to reduce consumer rebalances
- Status
- Shipped Since Kafka 2.3 (2019), opt-in with group.instance.id.
- Area
- Consumer groups and queues
- Proposal page
- KIP-345 on the Apache Kafka wiki
Why it was needed
A normal consumer gets a new member id every time it starts. A restart therefore looks like one member leaving and another joining, which means two rebalances, and with eager rebalancing the whole group pauses twice. In a rolling deploy of 50 instances that is 100 rebalances, and local state such as Kafka Streams stores may be moved to another instance for no reason.
What it changes
A consumer configured with group.instance.id is a static member. It does not send a leave request when it shuts down, and the coordinator keeps its partitions reserved until session.timeout.ms runs out. If it comes back in time it simply takes them again. If it does not, it is removed and the group rebalances as usual.
How to use it
- Give each consumer a stable, unique group.instance.id, for example the pod name of a StatefulSet.
- Raise session.timeout.ms above the time a restart takes, so a deploy finishes inside the window.
Where it stands
Shipped in Kafka 2.3 and supported on both the classic and the KIP-848 consumer protocol. Two instances with the same group.instance.id fence each other, so the id must be unique per running process.
What comes next
Stable. With KIP-848 the broker handles static members natively, and Kafka 4.4 added static membership to the streams rebalance protocol (KIP-1071).
See it in the simulator
- Kafka static membership: group.instance.id avoids rebalances (Static membership: avoid rebalance) Step 5: static member rejoins in time Open at this step: Kafka static membership: group.instance.id avoids rebalances
- Kafka static membership: group.instance.id avoids rebalances (Static membership: avoid rebalance) Step 7: outcome: rebalance vs retained Open at this step: Kafka static membership: group.instance.id avoids rebalances