Bird
Raised Fist0
Kafkadevops~20 mins

Group coordinator in Kafka - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Kafka Group Coordinator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this Kafka group coordinator state transition?
Consider a Kafka consumer group coordinator handling a rebalance. What will be the final state of the coordinator after the following sequence of events?
Kafka
States: INITIALIZING -> PREPARING_REBALANCE -> COMPLETING_REBALANCE -> STABLE
Events: Start -> Prepare -> Complete

Transition:
INITIALIZING --Start--> PREPARING_REBALANCE
PREPARING_REBALANCE --Prepare--> COMPLETING_REBALANCE
COMPLETING_REBALANCE --Complete--> STABLE
APREPARING_REBALANCE
BSTABLE
CINITIALIZING
DCOMPLETING_REBALANCE
Attempts:
2 left
💡 Hint
Follow the event sequence step-by-step through the state transitions.
🧠 Conceptual
intermediate
1:30remaining
Which component is responsible for managing group membership in Kafka?
In Kafka's group coordinator architecture, which component manages the membership and heartbeat of consumers in a group?
AGroup Coordinator Broker
BKafka Producer
CZookeeper
DKafka Topic Partition
Attempts:
2 left
💡 Hint
Think about which broker handles consumer group coordination.
🔧 Debug
advanced
2:00remaining
What error occurs when a consumer fails to send heartbeats to the group coordinator?
Given a Kafka consumer that stops sending heartbeats, what error will the group coordinator raise?
AGroupInstanceIdNotFoundException
BCommitFailedException
CGroupCoordinatorNotAvailableException
DGroupRebalanceInProgressException
Attempts:
2 left
💡 Hint
Missing heartbeats cause the coordinator to trigger a rebalance.
📝 Syntax
advanced
2:30remaining
Which option correctly initializes a Kafka group coordinator client in Java?
Select the correct Java code snippet to create a Kafka consumer with a group coordinator configuration.
Kafka
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "my-group");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

KafkaConsumer<String, String> consumer = ???;
Anew KafkaConsumer<>(props);
Bnew KafkaConsumer(props);
Cnew KafkaConsumer<String, String>(props);
DKafkaConsumer<String, String> consumer = KafkaConsumer(props);
Attempts:
2 left
💡 Hint
Remember to specify generic types when creating the consumer.
🚀 Application
expert
3:00remaining
How many partitions can a Kafka consumer group coordinator assign if the group has 3 consumers and the topic has 10 partitions?
Given a Kafka topic with 10 partitions and a consumer group with 3 consumers, how many partitions will each consumer be assigned if the coordinator uses the default range assignor?
AConsumer 1: 4, Consumer 2: 3, Consumer 3: 3
BConsumer 1: 3, Consumer 2: 3, Consumer 3: 4
CConsumer 1: 3, Consumer 2: 4, Consumer 3: 3
DConsumer 1: 3, Consumer 2: 3, Consumer 3: 3
Attempts:
2 left
💡 Hint
The default range assignor distributes partitions as evenly as possible, assigning extra partitions to the first consumers.

Practice

(1/5)
1. What is the main role of the group coordinator in Kafka consumer groups?
easy
A. It manages the membership and partition assignments of consumers in a group.
B. It stores all messages produced to Kafka topics.
C. It handles the replication of Kafka brokers.
D. It monitors the health of Kafka brokers.

Solution

  1. Step 1: Understand the group coordinator's function

    The group coordinator is responsible for managing consumer group membership and partition assignments.
  2. Step 2: Differentiate from other Kafka components

    Storing messages, replication, and broker health are handled by other Kafka components, not the group coordinator.
  3. Final Answer:

    It manages the membership and partition assignments of consumers in a group. -> Option A
  4. Quick Check:

    Group coordinator = manages consumer group membership [OK]
Hint: Group coordinator manages consumers, not brokers or data storage [OK]
Common Mistakes:
  • Confusing group coordinator with Kafka broker
  • Thinking it stores messages
  • Mixing it with replication controller
2. Which configuration must be set in a Kafka consumer to join a consumer group?
easy
A. bootstrap.servers
B. group.id
C. auto.offset.reset
D. key.deserializer

Solution

  1. Step 1: Identify the configuration for group membership

    The group.id setting defines the consumer group the consumer belongs to.
  2. Step 2: Understand other configurations

    bootstrap.servers sets Kafka servers, auto.offset.reset controls offset behavior, and key.deserializer handles message key decoding.
  3. Final Answer:

    group.id -> Option B
  4. Quick Check:

    Set group.id to join a consumer group [OK]
Hint: Set group.id to join a consumer group in Kafka [OK]
Common Mistakes:
  • Confusing bootstrap.servers with group.id
  • Using auto.offset.reset to join group
  • Not setting group.id at all
3. Given the following Kafka consumer code snippet, what will happen when two consumers with the same group.id subscribe to the same topic with 4 partitions?
consumer1 = KafkaConsumer('my-topic', group_id='group1')
consumer2 = KafkaConsumer('my-topic', group_id='group1')
medium
A. Each consumer will receive all messages from all partitions.
B. Only one consumer will receive messages; the other will be idle.
C. The consumers will share the partitions so each gets a subset of messages.
D. The consumers will cause a conflict and fail to consume.

Solution

  1. Step 1: Understand consumer group behavior

    Consumers in the same group share partitions so that each partition is consumed by only one consumer.
  2. Step 2: Apply to given scenario

    With 4 partitions and 2 consumers in the same group, partitions will be divided between them, each getting a subset.
  3. Final Answer:

    The consumers will share the partitions so each gets a subset of messages. -> Option C
  4. Quick Check:

    Same group.id means partition sharing [OK]
Hint: Same group.id consumers share partitions, not duplicate messages [OK]
Common Mistakes:
  • Thinking each consumer gets all messages
  • Assuming conflict causes failure
  • Believing only one consumer works
4. You have a Kafka consumer group but notice that one consumer is not receiving any messages even though the topic has many partitions. What is a likely cause related to the group coordinator?
medium
A. The topic has no messages to consume.
B. The group coordinator failed and was not re-elected.
C. The consumer has a different group.id than the others.
D. The consumer is assigned zero partitions due to group rebalancing.

Solution

  1. Step 1: Understand partition assignment by group coordinator

    The group coordinator assigns partitions to consumers; sometimes a consumer may get zero partitions after rebalancing.
  2. Step 2: Analyze the symptom

    If a consumer is in the group but gets no partitions, it won't receive messages even if the topic has many partitions.
  3. Final Answer:

    The consumer is assigned zero partitions due to group rebalancing. -> Option D
  4. Quick Check:

    Zero partition assignment means no messages for that consumer [OK]
Hint: Zero partitions assigned means consumer gets no messages [OK]
Common Mistakes:
  • Assuming consumer left group due to different group.id
  • Thinking group coordinator failure stops all consumers
  • Ignoring partition assignment in rebalancing
5. You want to ensure smooth failover in a Kafka consumer group when one consumer crashes. How does the group coordinator help achieve this?
hard
A. It automatically detects the failure and triggers a rebalance to assign partitions to remaining consumers.
B. It stores the crashed consumer's messages until it recovers.
C. It restarts the crashed consumer automatically.
D. It duplicates messages to all consumers to avoid data loss.

Solution

  1. Step 1: Understand group coordinator's role in failure

    The group coordinator monitors consumer membership and triggers rebalancing when a consumer leaves or crashes.
  2. Step 2: Explain failover mechanism

    On failure detection, the coordinator reassigns partitions to remaining consumers to continue processing without data loss.
  3. Final Answer:

    It automatically detects the failure and triggers a rebalance to assign partitions to remaining consumers. -> Option A
  4. Quick Check:

    Group coordinator triggers rebalance on consumer failure [OK]
Hint: Group coordinator triggers rebalance on consumer failure [OK]
Common Mistakes:
  • Thinking it stores messages for crashed consumers
  • Assuming it restarts consumers
  • Believing it duplicates messages to all consumers
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