Kafka已从Kafka 2.0的--num-threads
中删除了option of org.apache.kafka.tools.ProducerPerformance
的选项
这又是什么解决方案?
答案 0 :(得分:0)
我们首先需要首先了解--num-threads的用途。
参数pi@raspberrypi:/tmp $ gcc -pedantic -Wextra b.c
pi@raspberrypi:/tmp $ ./a.out
enter the number of elements
1
enter the array elements
1
1
pi@raspberrypi:/tmp $ ./a.out
enter the number of elements
2
enter the array elements
1 2
1 2
pi@raspberrypi:/tmp $ ./a.out
enter the number of elements
2
enter the array elements
2 1
1 2
pi@raspberrypi:/tmp $ ./a.out
enter the number of elements
4
enter the array elements
4 3 2 1
1 2 3 4
以前用于控制每个线程的消息吞吐量。
类似
--num-threads
但是,现在通过此更改,他们已经取消了节流或控制吞吐量的粗略方法,而是给了您完全取消节流的选项,您可以通过将--throughput设置为值来完成-1
如果仔细看,内部实现现在是这样的
ProducerPerformanceThread[] producerPerformanceThreads = new ProducerPerformanceThread[numThreads];
long numRecordsPerThread = numRecords / numThreads;
int throughputPerThread = throughput <= 0 ? throughput : Math.max(throughput / numThreads, 1);
int batchSize = 1;
因此,您现在应该只设置吞吐量值,而不用担心线程数。