Bird
Raised Fist0
Kafkadevops~10 mins

Cooperative vs eager rebalancing in Kafka - Interactive Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the rebalance protocol to eager.

Kafka
props.put("partition.assignment.strategy", "[1]");
Drag options to blanks, or click blank then click option'
Aorg.apache.kafka.clients.consumer.CooperativeStickyAssignor
Borg.apache.kafka.clients.consumer.StickyAssignor
Corg.apache.kafka.clients.consumer.EagerAssignor
Dorg.apache.kafka.clients.consumer.RangeAssignor
Attempts:
3 left
💡 Hint
Common Mistakes
Using CooperativeStickyAssignor instead of EagerAssignor
Using RangeAssignor which is not eager
Misspelling the assignor class name
2fill in blank
medium

Complete the code to set the rebalance protocol to cooperative.

Kafka
props.put("partition.assignment.strategy", "[1]");
Drag options to blanks, or click blank then click option'
Aorg.apache.kafka.clients.consumer.CooperativeStickyAssignor
Borg.apache.kafka.clients.consumer.EagerAssignor
Corg.apache.kafka.clients.consumer.RangeAssignor
Dorg.apache.kafka.clients.consumer.StickyAssignor
Attempts:
3 left
💡 Hint
Common Mistakes
Using EagerAssignor instead of CooperativeStickyAssignor
Using StickyAssignor which is not cooperative
Using RangeAssignor which is neither cooperative nor eager
3fill in blank
hard

Fix the error in the rebalance strategy assignment to use cooperative rebalancing.

Kafka
props.put("partition.assignment.strategy", "[1]");
Drag options to blanks, or click blank then click option'
Aorg.apache.kafka.clients.consumer.CooperativeStickyAssignor
Borg.apache.kafka.clients.consumer.EagerAssignor
Corg.apache.kafka.clients.consumer.RangeAssignor
Dorg.apache.kafka.clients.consumer.StickyAssignor
Attempts:
3 left
💡 Hint
Common Mistakes
Using EagerAssignor for cooperative rebalancing
Using StickyAssignor which is not cooperative
Using RangeAssignor which is not cooperative
4fill in blank
hard

Fill both blanks to configure a Kafka consumer for cooperative rebalancing with the correct assignor and enable incremental cooperative rebalancing.

Kafka
props.put("partition.assignment.strategy", "[1]");
props.put("rebalance.protocol", "[2]");
Drag options to blanks, or click blank then click option'
Aorg.apache.kafka.clients.consumer.CooperativeStickyAssignor
Beager
Ccooperative-sticky
Dorg.apache.kafka.clients.consumer.EagerAssignor
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing eager assignor with cooperative rebalance protocol
Using 'eager' as the assignor class
Using 'cooperative-sticky' as the assignor class
5fill in blank
hard

Fill all three blanks to create a Kafka consumer configuration that uses eager rebalancing with the correct assignor, rebalance protocol, and session timeout.

Kafka
props.put("partition.assignment.strategy", "[1]");
props.put("rebalance.protocol", "[2]");
props.put("session.timeout.ms", [3]);
Drag options to blanks, or click blank then click option'
Aorg.apache.kafka.clients.consumer.CooperativeStickyAssignor
Beager
C30000
Dorg.apache.kafka.clients.consumer.EagerAssignor
Attempts:
3 left
💡 Hint
Common Mistakes
Using CooperativeStickyAssignor with eager protocol
Setting session.timeout.ms as a string instead of a number
Mixing rebalance protocols and assignors

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