Consider a Kafka consumer group with 3 consumers subscribed to a topic with 6 partitions. When one consumer leaves the group, what happens to the partition assignments?
Consumer group: 3 consumers Topic partitions: 6 Event: One consumer leaves What is the new partition assignment behavior?
Think about how Kafka ensures load balancing among active consumers.
When a consumer leaves, Kafka triggers a rebalance. The partitions previously assigned to the leaving consumer are redistributed evenly among the remaining consumers to maintain balanced consumption.
A Kafka consumer processes messages but does not commit offsets before a rebalance occurs. What is the expected behavior?
Consumer processes messages No offset commit Rebalance triggered What happens next?
Offsets determine where consumption resumes after rebalance.
If offsets are not committed before rebalance, the consumer restarts from the last committed offset, causing some messages to be processed again, resulting in duplicates.
Given the following consumer configuration, identify the cause of frequent rebalances:
group.id=my-group session.timeout.ms=10000 auto.offset.reset=earliest max.poll.interval.ms=3000
Check the relationship between poll interval and session timeout.
If max.poll.interval.ms is less than session.timeout.ms, the consumer may not poll frequently enough, causing the broker to think it is dead and triggering rebalances.
Which mechanism does Kafka use to guarantee that only one consumer owns a partition at a time during rebalancing?
Think about how Kafka tracks consumer liveness and ownership.
Kafka uses a group coordinator that tracks consumer heartbeats. If a consumer fails to send heartbeats, the coordinator triggers a rebalance to reassign partitions, ensuring exclusive ownership.
You have a critical Kafka consumer group that must minimize downtime during rebalances. Which approach best achieves this?
Consider Kafka features that reduce rebalance scope.
Static group membership allows consumers to keep their partition assignments across restarts, reducing the scope and frequency of rebalances and minimizing downtime.