Bird
Raised Fist0
Kafkadevops~10 mins

Static group membership in Kafka - Interactive Code Practice

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

Complete the code to enable static group membership by setting the group instance ID.

Kafka
props.put("group.instance.id", [1]);
Drag options to blanks, or click blank then click option'
A"auto"
B"my-static-instance"
C"random"
D"dynamic"
Attempts:
3 left
💡 Hint
Common Mistakes
Using dynamic or random strings for group.instance.id
Not setting group.instance.id at all
2fill in blank
medium

Complete the code to configure the consumer to use static group membership by setting the correct property.

Kafka
consumerConfig.put([1], "my-static-instance");
Drag options to blanks, or click blank then click option'
A"group.instance.id"
B"client.id"
C"session.timeout.ms"
D"group.id"
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing group.id with group.instance.id
Setting client.id instead
3fill in blank
hard

Fix the error in the code to correctly set static group membership in the consumer properties.

Kafka
props.put("[1]", "static-instance-1");
Drag options to blanks, or click blank then click option'
Agroup.id
Bclient.id
Cgroup.instance.id
Dgroup.instance
Attempts:
3 left
💡 Hint
Common Mistakes
Using group.id instead of group.instance.id
Misspelling the property name
4fill in blank
hard

Fill both blanks to create a consumer configuration that enables static group membership with a unique instance ID.

Kafka
consumerProps.put([1], "my-group");
consumerProps.put([2], "instance-123");
Drag options to blanks, or click blank then click option'
A"group.id"
B"group.instance.id"
C"client.id"
D"session.timeout.ms"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the two property names
Using client.id instead of group.instance.id
5fill in blank
hard

Fill all three blanks to create a Kafka consumer configuration that sets the group ID, static instance ID, and client ID.

Kafka
props.put([1], "my-group");
props.put([2], "static-instance-01");
props.put([3], "client-01");
Drag options to blanks, or click blank then click option'
A"group.instance.id"
B"group.id"
C"client.id"
D"session.timeout.ms"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the property names
Not setting client.id when required

Practice

(1/5)
1.

What is the main purpose of using group.instance.id in Kafka consumer groups?

easy
A. To increase the number of partitions in a topic
B. To encrypt messages within the consumer group
C. To automatically commit offsets more frequently
D. To assign a stable identity to a consumer and enable static group membership

Solution

  1. Step 1: Understand the role of group.instance.id

    This configuration assigns a unique and stable identity to a Kafka consumer within a group.
  2. Step 2: Connect stable identity to static group membership

    With a stable identity, Kafka can avoid unnecessary rebalances when a consumer restarts briefly, improving stability.
  3. Final Answer:

    To assign a stable identity to a consumer and enable static group membership -> Option D
  4. Quick Check:

    Stable consumer identity = static group membership [OK]
Hint: Static membership means stable consumer ID to avoid rebalances [OK]
Common Mistakes:
  • Confusing group.instance.id with partition count
  • Thinking it controls offset commit frequency
  • Assuming it encrypts messages
2.

Which of the following is the correct way to set group.instance.id in a Kafka consumer configuration?

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
// What is the correct line to set static membership?
easy
A. props.put("group.instance.id", "consumer-1");
B. props.put("group.id.instance", "consumer-1");
C. props.put("static.group.id", "consumer-1");
D. props.put("group.instance", "consumer-1");

Solution

  1. Step 1: Recall the exact property name for static membership

    The correct property to set a static consumer ID is group.instance.id.
  2. Step 2: Match the correct syntax in Java Properties

    Using props.put("group.instance.id", "consumer-1") correctly sets the static ID.
  3. Final Answer:

    props.put("group.instance.id", "consumer-1"); -> Option A
  4. Quick Check:

    Correct property name = group.instance.id [OK]
Hint: Remember exact property name: group.instance.id [OK]
Common Mistakes:
  • Swapping words in the property name
  • Using incomplete or incorrect property keys
  • Confusing with group.id
3.

Consider this Kafka consumer group with static membership enabled using group.instance.id. If a consumer with group.instance.id = "consumer-1" disconnects briefly and reconnects, what happens?

medium
A. The consumer is removed permanently from the group
B. The group triggers a full rebalance and reassigns partitions
C. The consumer resumes without triggering a rebalance
D. The consumer must use a new group.instance.id to reconnect

Solution

  1. Step 1: Understand static membership behavior on brief disconnect

    Static membership keeps the consumer identity stable, so brief disconnects do not cause rebalances.
  2. Step 2: Identify the effect on partition assignment

    The consumer resumes with the same partitions without triggering a rebalance, improving latency and stability.
  3. Final Answer:

    The consumer resumes without triggering a rebalance -> Option C
  4. Quick Check:

    Static membership avoids rebalance on brief disconnect [OK]
Hint: Static ID lets consumer resume without rebalance [OK]
Common Mistakes:
  • Assuming every disconnect triggers rebalance
  • Thinking consumer is removed permanently
  • Believing new ID is required on reconnect
4.

Given this Kafka consumer config snippet, identify the error preventing static group membership:

props.put("group.id", "my-group");
props.put("group.instance.id", "consumer-1");
props.put("session.timeout.ms", "10000");
// Missing property?
medium
A. Missing group.protocol.type set to consumer
B. Missing enable.auto.commit property
C. Missing partition.assignment.strategy for static membership
D. Missing client.id property

Solution

  1. Step 1: Check required properties for static membership

    Static membership requires group.protocol.type to be set to consumer explicitly in some Kafka versions.
  2. Step 2: Identify missing property in config

    The snippet lacks group.protocol.type, which can prevent static membership from working properly.
  3. Final Answer:

    Missing group.protocol.type set to consumer -> Option A
  4. Quick Check:

    Static membership needs group.protocol.type=consumer [OK]
Hint: Set group.protocol.type=consumer for static membership [OK]
Common Mistakes:
  • Assuming auto commit affects static membership
  • Confusing client.id with group.instance.id
  • Ignoring group.protocol.type requirement
5.

You have a Kafka consumer group with 3 consumers using static membership via group.instance.id. One consumer crashes and restarts quickly with the same group.instance.id. What is the expected behavior and why is static membership important here?

hard
A. The group pauses all consumption until manual intervention
B. The group avoids a rebalance, so processing continues smoothly with minimal delay
C. The restarted consumer must use a new group.instance.id or it will be rejected
D. The group triggers a rebalance to reassign partitions to other consumers immediately

Solution

  1. Step 1: Analyze static membership effect on consumer restart

    Static membership keeps the consumer identity stable, so a quick restart does not cause a rebalance.
  2. Step 2: Understand impact on group processing

    Because no rebalance occurs, partition assignments remain unchanged, allowing smooth and low-latency processing.
  3. Final Answer:

    The group avoids a rebalance, so processing continues smoothly with minimal delay -> Option B
  4. Quick Check:

    Static membership prevents rebalance on quick restart [OK]
Hint: Static membership keeps group stable during quick restarts [OK]
Common Mistakes:
  • Expecting rebalance on every consumer restart
  • Thinking new ID is required after crash
  • Assuming group pauses automatically
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