Sobes.tech
Senior

Kafka: a topic with 3 partitions and 4 consumers in one group — what will happen?

sobes.tech AI

Answer from AI

In Kafka, if you have a topic with 3 partitions and 4 consumers in one group, the distribution will be as follows:

  • Each partition can be assigned to only one consumer in the group.
  • Since there are fewer partitions than consumers, 3 consumers will receive data from the partitions, and the 4th consumer will remain unassigned and idle.

Result:

  • The maximum number of active consumers that can read data simultaneously is equal to the number of partitions.
  • Excess consumers in the group will not receive messages until a partition is freed (for example, if one of the active consumers disconnects).

This behavior is important to consider when designing the system to avoid creating an excessive number of consumers in the group, as some will remain idle without load.