Skip to main content

Question 25 of 50

What is Rebalance?

Mid-levelSenior

Question

"What is Rebalance, and when does it happen?"

What the interviewer wants to assess

Whether you understand rebalance as an automatic process, but with a real cost — not something transparent and without consequences.

Resposta rápida

Rebalance is the process of redistributing a topic's partitions among a Consumer Group's active consumers, triggered whenever the group's membership changes: a consumer joins, a consumer leaves, or a consumer is declared dead for not sending a heartbeat in time.

Resposta nível Sênior

The most common trigger in production isn't an abrupt process crash — it's a consumer that takes too long processing a batch of messages (exceeding max.poll.interval.ms) and gets declared dead by the group even though it's still alive, just slow. In the classic rebalance strategy (eager), every consumer in the group revokes all of its partitions at the start of the process, even the ones that will stay with the same consumer afterward — the entire group pauses processing during the reassignment window. More recent strategies (cooperative sticky) reduce that impact, only revoking the partitions that actually need to change owners.

In-depth explanation

See "What triggers a rebalance" and "The impact of a rebalance" in Chapter 6.

Exemplo financeiro

A saldo-service deploy that restarts every replica at the same time triggers a rebalance on every restart — if the deploy doesn't use a rolling update, the Consumer Group can go through multiple successive rebalances, repeatedly pausing processing during the deploy window.

"Rebalance is instant and transparent"

Rebalance is automatic, but it's neither instant nor free. During the detection and reassignment window, that group's processing (partial or total, depending on the assignor strategy) is paused — a detail often forgotten in shallow answers.

Pode vir a seguir

Likely follow-ups: "what happens when a Consumer goes down?" and "how would you reduce the impact of rebalances in production?".