0
0
Kafkadevops~20 mins

Rebalancing behavior in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Rebalancing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output when a consumer group rebalances?

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?

Kafka
Consumer group: 3 consumers
Topic partitions: 6
Event: One consumer leaves

What is the new partition assignment behavior?
ARemaining consumers evenly redistribute all 6 partitions among themselves.
BPartitions are reassigned randomly without considering previous assignments.
CAll partitions are assigned to a single remaining consumer.
DPartitions assigned to the leaving consumer remain unassigned until manual reassignment.
Attempts:
2 left
💡 Hint

Think about how Kafka ensures load balancing among active consumers.

Predict Output
intermediate
2:00remaining
What error occurs if a consumer does not commit offsets before rebalancing?

A Kafka consumer processes messages but does not commit offsets before a rebalance occurs. What is the expected behavior?

Kafka
Consumer processes messages
No offset commit
Rebalance triggered

What happens next?
AConsumer will reprocess messages from the last committed offset, causing duplicates.
BConsumer loses all messages and skips to the latest offset.
CConsumer crashes with a CommitFailedException.
DConsumer automatically commits offsets before rebalance without explicit call.
Attempts:
2 left
💡 Hint

Offsets determine where consumption resumes after rebalance.

🔧 Debug
advanced
2:00remaining
Why does this Kafka consumer group experience frequent rebalances?

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
Asession.timeout.ms is too high, causing delayed detection of dead consumers.
Bmax.poll.interval.ms is less than session.timeout.ms, causing session expiration.
Cauto.offset.reset=earliest causes rebalances on startup.
Dgroup.id is not unique, causing conflicts.
Attempts:
2 left
💡 Hint

Check the relationship between poll interval and session timeout.

🧠 Conceptual
advanced
2:00remaining
How does Kafka ensure partition ownership consistency during rebalancing?

Which mechanism does Kafka use to guarantee that only one consumer owns a partition at a time during rebalancing?

AKafka uses a first-come, first-served approach without coordination.
BKafka relies on Zookeeper locks to assign partitions exclusively.
CKafka uses a group coordinator and heartbeat protocol to manage partition ownership.
DKafka assigns partitions randomly without ownership guarantees.
Attempts:
2 left
💡 Hint

Think about how Kafka tracks consumer liveness and ownership.

🚀 Application
expert
3:00remaining
How to minimize downtime during Kafka consumer group rebalancing?

You have a critical Kafka consumer group that must minimize downtime during rebalances. Which approach best achieves this?

AIncrease max.poll.records to process more messages per poll.
BSet session.timeout.ms to a very low value to detect failures faster.
CDisable heartbeats to prevent rebalances triggered by missed heartbeats.
DUse static group membership with assigned instance IDs to avoid full rebalances on consumer restarts.
Attempts:
2 left
💡 Hint

Consider Kafka features that reduce rebalance scope.