As asked
Explain what a Kafka consumer group rebalance is, what triggers one, and what the practical impact is on a production streaming pipeline. What strategies do you use to minimize disruption?
Sample answer outline
A rebalance redistributes partition ownership among consumers in a group. Triggers include a consumer joining or leaving, a heartbeat timeout, or a topic partition count changing. During the rebalance all consumers stop consuming (stop-the-world by default with eager rebalancing), which causes latency spikes and can cause duplicate processing if offsets were not committed. Strong answers mention cooperative incremental rebalancing introduced in Kafka 2.4 that only moves affected partitions, static group membership to avoid rebalances on rolling restarts, tuning session.timeout.ms and max.poll.interval.ms, and idempotent consumers to handle duplicates safely.
Expect these follow-ups
- How does static group membership work, and what are its trade-offs?
- What offset commit strategies do you use to minimize data loss or duplication around a rebalance?