Explain consumer groups. What happens when there are more consumers than partitions?
Sketch your own answer first, then compare it with the one below.
A strong answer
A consumer group is a set of consumers that share a topic. The group assigns each partition to exactly one member, so partitions are read in order and no message goes to two members of the group. Different groups each get their own full copy of the stream.
If the group has more members than partitions, the extra members own nothing and sit idle. Adding consumers beyond the partition count does not increase throughput.
That is why the partition count deserves capacity planning. Leave room to grow, because raising it later is disruptive.
Sources
- Jay Kreps, Neha Narkhede, Jun Rao (2011). Kafka: a distributed messaging system for log processing.
- Martin Kleppmann (2017). Designing Data-Intensive Applications.