What is eager rebalancing in Kafka consumer groups?
Eager rebalancing means all consumers in a group stop consuming, revoke all partitions, and then rebalance partitions from scratch. It causes a full pause in processing during rebalancing.
Click to reveal answer
beginner
What is cooperative rebalancing in Kafka consumer groups?
Cooperative rebalancing allows consumers to gradually give up partitions and assign new ones without stopping all consumption. It reduces downtime by doing partial rebalances.
Click to reveal answer
intermediate
Name one advantage of cooperative rebalancing over eager rebalancing.
Cooperative rebalancing reduces the time consumers are paused, so it improves availability and reduces message processing delays during rebalances.
Click to reveal answer
intermediate
What is a potential downside of cooperative rebalancing?
Cooperative rebalancing can be more complex and may require consumers to support incremental cooperative rebalance protocol.
Click to reveal answer
intermediate
In Kafka, which rebalancing strategy requires consumers to implement the incremental cooperative protocol?
The cooperative rebalancing strategy requires consumers to implement the incremental cooperative protocol to allow gradual partition handoff.
Click to reveal answer
What happens during eager rebalancing in Kafka consumer groups?
AConsumers gradually hand off partitions without stopping
BOnly one consumer rebalances at a time
CAll consumers stop and revoke all partitions before reassigning
DPartitions are never reassigned
✗ Incorrect
Eager rebalancing pauses all consumers and revokes all partitions before reassigning them.
Which rebalancing method reduces downtime during partition reassignment?
2. Which configuration property enables cooperative rebalancing in Kafka consumers?
easy
A. group.rebalance.strategy = 'eager'
B. rebalance.policy = 'cooperative'
C. enable.cooperative.rebalance = true
D. partition.assignment.strategy = 'org.apache.kafka.clients.consumer.CooperativeStickyAssignor'
Solution
Step 1: Identify the correct property for assignment strategy
Kafka uses partition.assignment.strategy to set the rebalance strategy class.
Step 2: Recognize the cooperative assignor class
The cooperative rebalancing strategy is implemented by org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
Final Answer:
partition.assignment.strategy = 'org.apache.kafka.clients.consumer.CooperativeStickyAssignor' -> Option D
Quick Check:
Cooperative assignor class = partition.assignment.strategy = 'org.apache.kafka.clients.consumer.CooperativeStickyAssignor' [OK]
Hint: Look for 'partition.assignment.strategy' with cooperative class [OK]
Common Mistakes:
Using incorrect property names
Confusing eager and cooperative strategy names
Assuming a boolean flag enables cooperative rebalancing
3. Given two consumers in a group using eager rebalancing, what happens when one consumer leaves?
medium
A. All partitions in the group are reassigned immediately, causing a pause.
B. Only the partitions of the leaving consumer are reassigned gradually.
C. The remaining consumer continues without any rebalancing.
D. Partitions are reassigned only after a timeout period.
Solution
Step 1: Understand eager rebalancing behavior on consumer leave
In eager rebalancing, when any consumer leaves, all partitions are reassigned immediately to maintain balance.
Step 2: Recognize the impact on consumer pause
This immediate reassignment causes a pause for all consumers during the rebalance.
Final Answer:
All partitions in the group are reassigned immediately, causing a pause. -> Option A
Quick Check:
Eager rebalancing = full immediate reassignment [OK]
Hint: Eager means all partitions reassign at once [OK]
Common Mistakes:
Thinking only leaving consumer's partitions reassign
Assuming no pause occurs
Believing reassignment waits for timeout
4. You have a Kafka consumer group using cooperative rebalancing but notice long pauses during rebalances. What is a likely cause?
medium
A. Partitions are being reassigned gradually as expected.
B. The consumer group has only one consumer.
C. Consumers are using the eager assignor instead of cooperative assignor.
D. The rebalance timeout is set too low.
Solution
Step 1: Check the assignor configuration
If long pauses occur despite expecting cooperative rebalancing, the consumers might be using the eager assignor by mistake.
Step 2: Understand the impact of eager assignor
Eager assignor causes all partitions to reassign at once, leading to longer pauses.
Final Answer:
Consumers are using the eager assignor instead of cooperative assignor. -> Option C
Quick Check:
Long pauses + cooperative expected = eager assignor used [OK]
Hint: Long pauses mean eager assignor, not cooperative [OK]
Common Mistakes:
Assuming gradual reassignment causes long pauses
Ignoring assignor configuration
Blaming rebalance timeout without checking assignor
5. You want to minimize downtime in a Kafka consumer group with frequent consumer joins and leaves. Which strategy and configuration should you choose?
hard
A. Use eager rebalancing with default assignor for simplicity.
B. Use cooperative rebalancing with CooperativeStickyAssignor to reduce pause time.
C. Disable rebalancing to avoid any pauses.
D. Use eager rebalancing but increase session timeout to reduce rebalances.
Solution
Step 1: Identify the goal
The goal is to minimize downtime during frequent consumer group changes.
Step 2: Choose the appropriate rebalance strategy
Cooperative rebalancing reduces pause time by reassigning partitions gradually, which suits frequent joins/leaves.
Step 3: Select the correct configuration
Using CooperativeStickyAssignor enables cooperative rebalancing in Kafka consumers.
Final Answer:
Use cooperative rebalancing with CooperativeStickyAssignor to reduce pause time. -> Option B