Kafka · Producers & Consumers

What is a consumer rebalance?

Mediumrebalanceconsumer grouppartition assignment

Interview question

What is a Kafka consumer group rebalance, and what triggers it?

How to answer

The short answer

A rebalance is when Kafka redistributes assignments among members of a .

When it happens

  • A consumer joins the group
  • A consumer leaves (graceful close or crash)
  • A consumer misses heartbeats / session timeout
  • Subscription changes (subscribe to more/fewer topics)
  • Partitions added to a topic (metadata change)

Why it hurts

During classic rebalances, consumers may stop processing assigned partitions temporarily. Frequent rebalances → lag spikes and "rebalance storms."

What consumers should do

  • On revoke: commit offsets, flush local state carefully.
  • On assign: seek/initialize for new partitions.
  • Keep processing time per poll reasonable; call poll often enough for heartbeats (or use cooperative patterns / separate heartbeat thread in modern clients).

Ops tips to reduce churn

  • Stable group.id and deployment rollout strategy
  • Sensible session.timeout.ms / max.poll.interval.ms
  • Avoid unnecessary subscribe changes
  • Consider static membership and cooperative sticky assignors

Interview tip: "Rebalance = remap partitions to group members. Triggered by membership or subscription change. Too many rebalances hurt lag."