Kafka Partition Rebalancing Lifecycle Visualization
Walk through the Kafka Partition Rebalancing lifecycle with guided steps for group coordinator, partition assignment, rebalance, consumer lag, heartbeat.
Continue with the guided workspace
Use the paired workspace to connect this guide's mental model with live component state, visible signals, and the outcome each step or scenario is meant to prove.
Mental Model
Kafka partition rebalancing is the mechanism by which the cluster maintains high read availability when group membership changes. When a consumer joins, leaves, crashes, or fails to send heartbeats, Kafka coordinates a rebalance to redistribute partition ownership. While rebalancing is necessary to share the workload, it introduces consumer lag and latency spikes during the pause phase.
Components and Why They Exist
Producer
The client publishing data records to topic partitions. Continuously appends records to partition logs, driving the log end offsets forward. In the demo, watch it write records, which accumulate as partition lag during rebalance pauses.
Group Coordinator (Broker 1)
The broker responsible for managing the consumer groupβs state and coordinating rebalances. Receives heartbeats, detects consumer timeouts, elects the group leader, and initiates the join/sync group protocol. In the demo, watch it trigger the rebalance sequence when Consumer 3 stops sending heartbeats.
Consumers (Consumer 1, 2, 3)
Instances within a consumer group that pull data in parallel from assigned partitions. Periodically sends heartbeats to the coordinator, handles rebalance signals, commits offsets, and fetches partition data. In the demo, watch them change status to Rebalancing (yellow), committed (green), or inactive (red).
Assignment Strategy
Decides how partitions are distributed among active group members. Calculates assignment mappings (e.g. Range, Round Robin, or Cooperative Sticky) based on active consumer counts. In the demo, watch it map topic partitions to active consumer cards.
Offset Commit Tracker
Tracks partition progress during consumer handoff. Safely commits the last processed offsets before releasing partition ownership to prevent duplicate processing. In the demo, watch consumers commit pending offsets before rejoining.
Rebalance Barrier
Coordinates the βstop-the-worldβ phase of a rebalance. Halts partition fetching until all active consumers have rejoined the group and received their assignments. In the demo, watch it block consumer fetch paths.
Edge Cases and Misconceptions
- Misconception: Rebalancing is always fast and harmless: Under classic Eager Rebalancing, all consumers must stop reading entirely, causing complete consumption halts (stop-the-world pauses). For large clusters, this can cause significant consumer lag.
- Misconception: Range assignment is always the best strategy: Range assignment allocates contiguous partitions per topic, which can cause severe consumer load imbalance if topics have differing partition sizes. Round Robin or Sticky assignment is better for even distribution.
- Edge Case: Rebalance Storm (Consumer Flapping): If a consumer is overloaded and experiences long garbage collection pauses, it may fail to send heartbeats, triggering a rebalance. When it recovers, it rejoins, triggering another rebalance. This loop is called a rebalance storm.
- Edge Case: Cooperative Sticky Rebalancing: Modern Kafka clients use Cooperative Sticky protocol, which only revokes and reassigns partitions that are actually moving, allowing unchanged assignments to continue processing during the rebalance.
Open the Kafka Partition Rebalancing simulator sandbox after the walkthrough when you want to experiment with consumer scale, failure timeouts, assignment strategies, and partition workloads.
Common Questions
What is a consumer group rebalance in Kafka?
A rebalance is the process where a cluster coordinator redistributes partition assignments among the active members of a consumer group when group membership or partition counts change.
What is the difference between Range and Round Robin assignment strategies?
Range strategy assigns contiguous segments of partitions to each consumer (e.g. C1 gets P0-P2). Round Robin interleaves partition assignments (e.g. C1 gets P0, C2 gets P1, C3 gets P2, C1 gets P3), which balances partitions more evenly.
Why does a rebalance halt consumer traffic?
During an eager rebalance, consumers must stop fetching data, commit their current offsets, and rejoin the group to receive new assignments. This prevents multiple consumers from reading the same partitions concurrently, but introduces processing pauses.
How does consumer flapping lead to a rebalance storm?
If a consumer is unstable (flapping due to garbage collection pauses, network drops, or hardware issues), it repeatedly leaves and rejoins the group. Each status change triggers a rebalance, keeping traffic halted and causing partition lag to balloon.