Junior — Middle
Explain the concept of consumer groups in Apache Kafka and their role
sobes.tech AI
Answer from AI
In Apache Kafka, a consumer group is a set of one or more consumers that jointly read data from topics. Each consumer in the group gets a unique set of topic partitions, allowing messages to be processed in parallel without duplication.
Roles of consumer groups:
- Scaling processing: multiple consumers in a group can read different partitions in parallel.
- Ensuring fault tolerance: if one consumer fails, its partitions are redistributed among the remaining consumers.
- Guaranteeing unique processing: each message is processed by only one consumer in the group.
Example: if a topic has 4 partitions and the group consists of 2 consumers, each will get 2 partitions to read.