今天社区有小伙伴提出Flink在消费Kafka多Topic数据时,并行度合理,但还是存在消费不均匀的情况
为什么
1 2 3 4 5 6 7 8 9 10 11
| FlinkKafkaConsumerBase.open() AbstractPartitionDiscoverer.discoverPartitions() --setAndCheckDiscoveredPartition() KafkaTopicPartitionAssigner.assign()
public static int assign(KafkaTopicPartition partition, int numParallelSubtasks) { int startIndex = ((partition.getTopic().hashCode() * 31) & 0x7FFFFFFF) % numParallelSubtasks; return (startIndex + partition.getPartition()) % numParallelSubtasks; }
|
修改