A consumer group is a set of consumers that work together to read data from Kafka topics. Each consumer in the group reads from different partitions, allowing the group to share the workload.
Click to reveal answer
beginner
How do consumer groups enable parallel processing?
Consumer groups split the topic's partitions among their members. Each consumer reads from its assigned partitions independently, so multiple consumers process data at the same time.
Click to reveal answer
beginner
Why can't a single consumer read all partitions in parallel?
A single consumer reads partitions one by one or sequentially. It cannot process multiple partitions at the same time, so it cannot achieve parallel processing alone.
Click to reveal answer
intermediate
What happens if there are more consumers than partitions in a consumer group?
Some consumers will be idle because each partition can only be assigned to one consumer. Parallel processing is limited by the number of partitions.
Click to reveal answer
intermediate
How does Kafka ensure each message is processed once in a consumer group?
Kafka assigns each partition to only one consumer in the group, so messages in a partition are read by only one consumer, preventing duplicate processing.
Click to reveal answer
What does a Kafka consumer group do?
ADuplicates messages to all consumers
BMerges all partitions into one
CSplits topic partitions among consumers for parallel processing
DPrevents consumers from reading messages
✗ Incorrect
Consumer groups divide partitions among consumers so they can process data in parallel.
If a topic has 4 partitions and a consumer group has 2 consumers, how are partitions assigned?
AEach consumer gets 2 partitions
BOne consumer gets all 4 partitions
CPartitions are duplicated to both consumers
DConsumers share each partition simultaneously
✗ Incorrect
Partitions are divided evenly among consumers for parallel processing.
Can a single consumer process multiple partitions at the same time?
AYes, always
BNo, it processes partitions sequentially
COnly if partitions are merged
DOnly if consumer groups are used
✗ Incorrect
A single consumer reads partitions one after another, not in parallel.
What limits the maximum parallelism in Kafka consumer groups?
ANumber of partitions in the topic
BNumber of consumers in the group
CSize of messages
DNetwork speed
✗ Incorrect
Parallelism is limited by how many partitions the topic has.
Why does Kafka assign each partition to only one consumer in a group?
ATo allow multiple consumers to read the same message
BTo increase message duplication
CTo slow down processing
DTo avoid duplicate message processing
✗ Incorrect
Assigning partitions exclusively prevents duplicate processing of messages.
Explain how consumer groups in Kafka enable parallel processing of messages.
Think about how dividing work helps multiple people finish faster.
You got /3 concepts.
Describe the relationship between partitions and consumers in a Kafka consumer group.
Consider how tasks are shared among team members.
You got /3 concepts.
Practice
(1/5)
1. What is the main reason consumer groups enable parallel processing in Kafka?
easy
A. They limit the number of messages a consumer can read at once.
B. They duplicate messages to all consumers for faster processing.
C. They combine all messages into a single stream for one consumer.
D. They allow multiple consumers to read different partitions of a topic simultaneously.
Solution
Step 1: Understand consumer groups and partitions
Consumer groups split topic partitions among consumers so each reads a unique subset.
Step 2: Recognize parallel processing benefit
Because consumers read different partitions at the same time, processing happens in parallel.
Final Answer:
They allow multiple consumers to read different partitions of a topic simultaneously. -> Option D
Quick Check:
Parallel reading = multiple consumers on partitions [OK]
Hint: Think: multiple consumers share partitions, not duplicate messages [OK]
Common Mistakes:
Thinking all consumers get all messages
Believing messages are duplicated for speed
Confusing parallel with sequential processing
2. Which of the following is the correct way to assign a consumer to a group in Kafka's consumer configuration?
easy
A. group.id = "my-group"
B. consumer.group = "my-group"
C. groupName = "my-group"
D. assign.group = "my-group"
Solution
Step 1: Recall Kafka consumer configuration keys
The correct key to set the consumer group is 'group.id'.
Step 2: Match the correct syntax
Only 'group.id = "my-group"' matches Kafka's expected configuration format.
Final Answer:
group.id = "my-group" -> Option A
Quick Check:
Kafka uses 'group.id' to set consumer groups [OK]
Hint: Remember Kafka config uses 'group.id' for groups [OK]
Common Mistakes:
Using incorrect keys like 'consumer.group'
Confusing variable names with config keys
Missing quotes around group name
3. Given a topic with 4 partitions and a consumer group with 2 consumers, what will happen when both consumers start reading?
medium
A. Each consumer reads 2 unique partitions, no overlap.
B. Each consumer reads all 4 partitions simultaneously.
C. Only one consumer reads all partitions; the other waits.
D. Consumers randomly read any partition, possibly overlapping.
Solution
Step 1: Understand partition assignment in consumer groups
Partitions are divided among consumers so each partition is read by only one consumer.
Step 2: Calculate partition distribution
With 4 partitions and 2 consumers, each consumer gets 2 partitions uniquely.
Final Answer:
Each consumer reads 2 unique partitions, no overlap. -> Option A
Quick Check:
Partitions split evenly among consumers [OK]
Hint: Partitions divide evenly among consumers in a group [OK]
Common Mistakes:
Assuming consumers read all partitions
Thinking partitions overlap between consumers
Believing one consumer reads everything
4. You have 3 consumers in a group but only 2 partitions in the topic. What issue will occur?
medium
A. All consumers will share partitions equally.
B. One consumer will be idle with no partitions assigned.
C. Kafka will create a new partition automatically.
D. Consumers will read duplicate messages from partitions.
Solution
Step 1: Analyze partition to consumer ratio
There are fewer partitions (2) than consumers (3), so not all consumers get partitions.
Step 2: Understand assignment behavior
Kafka assigns partitions exclusively; one consumer will have no partition and remain idle.
Final Answer:
One consumer will be idle with no partitions assigned. -> Option B
Quick Check:
Partitions < consumers means idle consumers [OK]
Hint: More consumers than partitions means some idle consumers [OK]