I have a kakfa topic with 20 partitions and 5 conusmers belonging to the same consumer group. It means that we have 4 partitions per consumer. Lets say:
- consumer-0 is assigned to the partition-0, partition-1, partition-2 and partition-3
- consumer-1 is assigned to the partition-4, partition-5, partition-6 and partition-7
- consumer-2 is assigned to the partition-8, partition-9, partition-10 and partition-11
- consumer-5 is assigned to the partition-12, partition-13, partition-14 and partition-15
- consumer-4 is assigned to the partition-16, partition-17, partition-18 and partition-19
The producer evenly send 10 messages to the topic. In this case, only partitions 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 are going to receive messages. The remaining ones will be empty. Our problem is that consumer-0 and consumer-1 will process 4 messages and in the same time, consumer-2 will process two messages. Also, consumer 4 and 5 will do any treatement since their partitions are idle.
At the producer side, we are working with the DefaultPartitioner (kafka-client 2.3.1) so that the record are evenly sent to the partitions. We would like to ask if it is possible to produce messages fairly based on kafka consumer rather than partitions. With this manner, each consumer will process only two messages and the process complexity will be fairly distributed between consumers.