Question 22 of 50
What is a Consumer Group?
Question
"What is a Consumer Group, and why does it exist?"
What the interviewer wants to assess
Whether you understand the Consumer Group as the mechanism that lets Kafka both distribute work and share data across independent systems — the central piece for explaining consumption scalability.
Resposta rápida
Consumer Group is a set of consumer instances identified by the same group.id. Kafka guarantees each
partition of a subscribed topic is assigned to exactly one consumer in the group at a time — never two
consumers from the same group reading the same partition simultaneously.
Resposta nível Sênior
Consumer Group is what makes Kafka capable of doing two things at once: distributing work (within a group, each partition goes to a single consumer, similar to what a queue does) and sharing data (different groups reading the same topic are completely independent of each other, each with its own set of committed offsets). The topic's number of partitions defines the maximum consumption parallelism within a single group — there's no way for a group to process with more parallelism than the available partitions.
In-depth explanation
See "How a Consumer Group splits the work" in Chapter 6.
Exemplo financeiro
The pix.recebido topic might have two Consumer Groups reading simultaneously: saldo-service (credits
the amount) and antifraude-service (assesses risk) — each with its own group, advancing offsets
completely independently, with no effect on the other.
"Two different Consumer Groups compete for the same messages"
No — that's exactly the most common confusion. Different Consumer Groups are completely independent; each one reads the topic in its own way. Competition for partitions only happens within the same group, among its own instances.
Pode vir a seguir
Likely follow-ups: "what happens when there are more consumers than partitions?" and "what is Rebalance?".
Related chapters