Bird
Raised Fist0
Kafkadevops~20 mins

Cooperative vs eager rebalancing in Kafka - Practice Questions

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Kafka Rebalance Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of consumer group rebalance with eager strategy

Consider a Kafka consumer group with two consumers consuming from four partitions. The group uses eager rebalancing. What is the expected behavior during a rebalance when a new consumer joins?

Kafka
Consumer group with 2 consumers consuming 4 partitions.
New consumer joins triggering eager rebalance.
What happens to partition assignment during rebalance?
AAll consumers stop consuming, partitions are revoked from all, then reassigned to all consumers.
BOnly the new consumer starts consuming immediately, others continue without interruption.
CPartitions are reassigned incrementally without stopping any consumer.
DConsumers continue consuming old partitions until manually restarted.
Attempts:
2 left
💡 Hint

Think about how eager rebalancing handles partition revocation and assignment.

❓ Predict Output
intermediate
2:00remaining
Output behavior with cooperative rebalancing

In a Kafka consumer group using cooperative rebalancing, what happens when a new consumer joins the group?

Kafka
Consumer group with 3 consumers consuming 6 partitions.
New consumer joins triggering cooperative rebalance.
What is the behavior during partition reassignment?
APartitions are revoked and reassigned incrementally, allowing consumers to continue processing some partitions without interruption.
BAll partitions are revoked from all consumers before reassignment, causing a full stop.
CNew consumer cannot join until all consumers restart manually.
DPartitions are duplicated temporarily to all consumers during rebalance.
Attempts:
2 left
💡 Hint

Cooperative rebalancing tries to minimize disruption. How does it do that?

🧠 Conceptual
advanced
2:00remaining
Why choose cooperative over eager rebalancing?

Which of the following is the main advantage of cooperative rebalancing compared to eager rebalancing in Kafka consumer groups?

AIt guarantees faster rebalancing by revoking all partitions at once.
BIt requires fewer network resources by disabling partition reassignment.
CIt allows consumers to consume duplicate partitions temporarily.
DIt reduces consumer downtime by allowing incremental partition revocation and assignment.
Attempts:
2 left
💡 Hint

Think about how downtime affects consumer processing.

❓ Predict Output
advanced
2:00remaining
Error raised when using cooperative rebalancing with unsupported client

What error will a Kafka consumer raise if it tries to use cooperative rebalancing but the client library does not support it?

Kafka
KafkaConsumer consumer = new KafkaConsumer(props);
consumer.subscribe(topics, new CooperativeRebalanceListener());
consumer.poll(Duration.ofMillis(100));
Ajava.lang.NullPointerException
Borg.apache.kafka.common.errors.UnsupportedVersionException
Corg.apache.kafka.common.errors.TimeoutException
DNo error, cooperative rebalancing silently falls back to eager
Attempts:
2 left
💡 Hint

Check what happens when a feature is not supported by the Kafka broker or client.

🚀 Application
expert
3:00remaining
Designing a consumer group for minimal downtime during rebalance

You are designing a Kafka consumer group for a critical application that must minimize downtime during rebalances caused by scaling consumers up or down. Which rebalance strategy and configuration should you choose?

AUse eager rebalancing but increase session timeout to delay rebalances.
BUse eager rebalancing with default full partition revocation and assignment.
CUse cooperative rebalancing with incremental partition revocation and assignment enabled.
DDisable rebalancing and manually assign partitions to consumers.
Attempts:
2 left
💡 Hint

Consider which strategy reduces consumer downtime and supports dynamic scaling.

Practice

(1/5)
1. What is the main advantage of cooperative rebalancing in Kafka consumer groups?
easy
A. It reduces consumer pause time by reassigning partitions gradually.
B. It reassigns all partitions at once for faster processing.
C. It eliminates the need for consumer group coordination.
D. It increases the number of partitions automatically.

Solution

  1. Step 1: Understand cooperative rebalancing behavior

    Cooperative rebalancing allows consumers to leave partitions gradually, which reduces the pause time during rebalancing.
  2. Step 2: Compare with eager rebalancing

    Eager rebalancing reassigns all partitions at once, causing longer pauses, unlike cooperative rebalancing.
  3. Final Answer:

    It reduces consumer pause time by reassigning partitions gradually. -> Option A
  4. Quick Check:

    Cooperative rebalancing = gradual partition reassignment [OK]
Hint: Cooperative means gradual, eager means all at once [OK]
Common Mistakes:
  • Confusing eager with cooperative rebalancing
  • Thinking cooperative rebalancing eliminates coordination
  • Assuming rebalancing increases partitions
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

  1. Step 1: Identify the correct property for assignment strategy

    Kafka uses partition.assignment.strategy to set the rebalance strategy class.
  2. Step 2: Recognize the cooperative assignor class

    The cooperative rebalancing strategy is implemented by org.apache.kafka.clients.consumer.CooperativeStickyAssignor.
  3. Final Answer:

    partition.assignment.strategy = 'org.apache.kafka.clients.consumer.CooperativeStickyAssignor' -> Option D
  4. 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

  1. Step 1: Understand eager rebalancing behavior on consumer leave

    In eager rebalancing, when any consumer leaves, all partitions are reassigned immediately to maintain balance.
  2. Step 2: Recognize the impact on consumer pause

    This immediate reassignment causes a pause for all consumers during the rebalance.
  3. Final Answer:

    All partitions in the group are reassigned immediately, causing a pause. -> Option A
  4. 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

  1. Step 1: Check the assignor configuration

    If long pauses occur despite expecting cooperative rebalancing, the consumers might be using the eager assignor by mistake.
  2. Step 2: Understand the impact of eager assignor

    Eager assignor causes all partitions to reassign at once, leading to longer pauses.
  3. Final Answer:

    Consumers are using the eager assignor instead of cooperative assignor. -> Option C
  4. 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

  1. Step 1: Identify the goal

    The goal is to minimize downtime during frequent consumer group changes.
  2. Step 2: Choose the appropriate rebalance strategy

    Cooperative rebalancing reduces pause time by reassigning partitions gradually, which suits frequent joins/leaves.
  3. Step 3: Select the correct configuration

    Using CooperativeStickyAssignor enables cooperative rebalancing in Kafka consumers.
  4. Final Answer:

    Use cooperative rebalancing with CooperativeStickyAssignor to reduce pause time. -> Option B
  5. Quick Check:

    Minimize downtime = cooperative rebalancing + correct assignor [OK]
Hint: CooperativeStickyAssignor minimizes downtime with frequent changes [OK]
Common Mistakes:
  • Choosing eager rebalancing for low downtime
  • Disabling rebalancing causing stale assignments
  • Misconfiguring session timeout instead of strategy
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard