Chapter 4: Kafka Consumers: Reading Data from Kafka
How consumers read from Kafka: consumer groups and rebalances, the poll loop, committing offsets, and reacting when partitions are reassigned.
Read it alongside Chapter 4 of Kafka: The Definitive Guide, free from Confluent.
-
Figure 4-1
A consumer group with a single consumer
See that a consumer alone in its group owns every partition, so it has to keep up with the whole topic by itself.
-
Figure 4-2
Four partitions split between two consumers
See how adding a consumer splits the partitions between the members of a group, while each message still goes to exactly one of them.
-
Figure 4-3
Four consumers, one partition each
See that once a group has as many consumers as the topic has partitions, each consumer reads exactly one, the furthest the group can spread the work.
-
Figure 4-4
More consumers than partitions
See why a group gains nothing from more consumers than partitions: the extra consumer receives no messages at all.
-
Figure 4-5
Adding a second consumer group
See that every group gets every message in the topic, independent of the other groups, while within a group each message still goes to one consumer.
-
Companion extra
Share groups: consumers sharing a partition
See how a share group (KIP-932) lets consumers outnumber partitions by tracking every record instead of one position per partition.