我有一个带有 2 个主题的 Spring Boot kafka 流应用程序,考虑主题 A 和 B。主题 A 有 16 个分区,主题 B 有 1 个分区。考虑应用程序部署在num.stream.threads
= 16 的 1 个实例中。我运行 kafka-consumer-groups.bat 命令来检查线程是如何分配给组中的分区的,得到以下输出。主题 A 和 B 分配了 16 个线程,其中主题 B 中的 14 个线程空闲。
kafka-consumer-groups.bat --bootstrap-server 0.0.0.0:9092 --group <topic-AGroupName> -describe
TOPIC PARTITION CLIENT-ID
topic-A 0 topic-AGroupStreamThread-429-consumer
topic-A 10 topic-AGroupStreamThread-422-consumer
topic-A 6 topic-AGroupStreamThread-425-consumer
topic-A 14 topic-AGroupStreamThread-431-consumer
topic-A 7 topic-AGroupStreamThread-420-consumer
topic-A 8 topic-AGroupStreamThread-428-consumer
topic-A 11 topic-AGroupStreamThread-430-consumer
topic-A 4 topic-AGroupStreamThread-417-consumer
topic-A 2 topic-AGroupStreamThread-427-consumer
topic-A 1 topic-AGroupStreamThread-418-consumer
topic-A 15 topic-AGroupStreamThread-421-consumer
topic-A 3 topic-AGroupStreamThread-424-consumer
topic-A 9 topic-AGroupStreamThread-419-consumer
topic-A 12 topic-AGroupStreamThread-426-consumer
topic-A 13 topic-AGroupStreamThread-432-consumer
topic-A 5 topic-AGroupStreamThread-423-consumer
kafka-consumer-groups.bat --bootstrap-server 0.0.0.0:9092 --group <topic-BGroupName> -describe
TOPIC PARTITION CLIENT-ID
topic-BGroup-result-repartition 0 topic-BGroupStreamThread-683-consumer
topic-B 0 topic-BGroupStreamThread-678-consumer
- - topic-BGroupStreamThread-685-consumer
- - topic-BGroupStreamThread-675-consumer
- - topic-BGroupStreamThread-673-consumer
- - topic-BGroupStreamThread-680-consumer
- - topic-BGroupStreamThread-688-consumer
- - topic-BGroupStreamThread-674-consumer
- - topic-BGroupStreamThread-679-consumer
- - topic-BGroupStreamThread-677-consumer
- - topic-BGroupStreamThread-687-consumer
- - topic-BGroupStreamThread-686-consumer
- - topic-BGroupStreamThread-676-consumer
- - topic-BGroupStreamThread-684-consumer
- - topic-BGroupStreamThread-682-consumer
- - topic-BGroupStreamThread-681-consumer
如何避免主题 B 中的空闲线程,或者是否有任何选项可用于设置每个主题的 num.stream.threads?