Junior — Middle
Explain how the concepts of Consumer and Consumer Group differ in message processing systems.
sobes.tech AI
Answer from AI
In message processing systems (e.g., Kafka), the concepts of Consumer and Consumer Group have the following differences:
-
Consumer — is an individual process or thread that reads messages from a topic.
-
Consumer Group — is a set of Consumers that collectively read messages from a single topic, distributing the load.
Main differences:
-
Message distribution:
- One Consumer reads all messages from a topic (or from assigned partitions).
- In a consumer group, topic partitions are distributed among Consumers so that each receives a unique set of messages.
-
Scalability:
- A Consumer Group allows scaling processing by adding new Consumers.
-
Delivery guarantee:
- Within a Consumer Group, each message is processed by exactly one Consumer.
Example: if a topic has 4 partitions and the group consists of 2 Consumers, each Consumer will read from 2 partitions, ensuring parallel processing.
This allows efficient load distribution and fault tolerance.