Consumer and Consumer Groups

This lesson explains the concepts of consumers and consumer groups in Kafka.

Consumers, or readers, receive messages from Kafka topics. The class that represents the consumer concept is KafkaConsumer. Consumers subscribe to topics, then receive messages that producers write to a topic. Typically, each consumer belongs to a consumer group. A single producer or multiple producers may write messages to a topic faster than a single consumer can read them, causing the consumer application to fall farther and farther behind. Kafka mitigates this scenario by allowing multiple consumers in a consumer group to work together to read messages from a topic. The various configurations for consumers and partitions in a topic are discussed below:

  • Partitions in a topic and consumers in a group are equal: In this scenario, each consumer reads from one partition.

Get hands-on with 1200+ tech skills courses.