Junior — Middle
What happens if multiple Consumers are run on one partition, and why can this be problematic?
sobes.tech AI
Answer from AI
In Kafka, a single partition can only be consumed by one Consumer from a single Consumer Group at a time. If multiple Consumers are started on the same partition within the same group, only one of them will actually receive messages, while the others will be idle.
Problems:
- No parallel processing within a single partition, as message order must be preserved.
- An excessive number of Consumers on a partition does not increase performance, but only complicates the architecture.
If Consumers belong to different groups, each will receive a copy of the messages, which may be undesirable.
Therefore, to scale consumption, you need to increase the number of partitions rather than running many Consumers on a single partition.