Senior
How will a topic with 2 partitions and 4 application instances in one consumer group distribute partitions?
sobes.tech AI
Answer from AI
In Kafka, when a topic has 2 partitions and there are 4 application instances in the same consumer group, the partitions are distributed among the instances as follows:
- Each partition can only be assigned to one consumer in the group.
- Since there are fewer partitions than instances (2 partitions and 4 instances), only 2 of the 4 instances will receive data.
- The remaining 2 instances will have no assigned partitions and will be idle.
Thus, the load will be distributed to 2 active instances, each reading from one partition, while the other 2 instances will not receive messages until the number of partitions or instances changes.