num.stream.threads 创建空闲线程
num.stream.threads creating idle threads
我有一个 spring boot kafka stream 应用程序,有 2 个主题,考虑主题 A 和 B.Topic A 有 16 个分区,主题 B 有 1 个 partition.Consider 应用程序部署在 1 个实例中num.stream.threads
=16。
我 运行 kafka-consumer-groups.bat 命令检查线程如何分配给组中的分区,得到以下 output.Topic 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?
您可以在实际输入绑定上设置并发性属性。例如spring.cloud.stream.kafka.streams.bindings.<input-binding-name>.consumer.concurrency
。每个输入绑定都会在幕后映射到 num.stream.threads
。看看这是否有效,如果您发现任何问题,请告诉我们。
我有一个 spring boot kafka stream 应用程序,有 2 个主题,考虑主题 A 和 B.Topic A 有 16 个分区,主题 B 有 1 个 partition.Consider 应用程序部署在 1 个实例中num.stream.threads
=16。
我 运行 kafka-consumer-groups.bat 命令检查线程如何分配给组中的分区,得到以下 output.Topic 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?
您可以在实际输入绑定上设置并发性属性。例如spring.cloud.stream.kafka.streams.bindings.<input-binding-name>.consumer.concurrency
。每个输入绑定都会在幕后映射到 num.stream.threads
。看看这是否有效,如果您发现任何问题,请告诉我们。