卡夫卡已从--num-threads
的option of org.apache.kafka.tools.ProducerPerformance
中删除了Kafka 2.0选项
这个的另一个解决方案是什么?
我们首先需要了解--num-threads的用途。
参数--num-threads
以前用于控制每个线程的消息吞吐量。
就像是
ProducerPerformanceThread[] producerPerformanceThreads = new ProducerPerformanceThread[numThreads];
long numRecordsPerThread = numRecords / numThreads;
int throughputPerThread = throughput <= 0 ? throughput : Math.max(throughput / numThreads, 1);
int batchSize = 1;
但是现在有了这个改变,他们已经废除了限制或控制吞吐量的原始方式,而是让你可以选择完全取消限制,你可以通过将--throughput设置为-1来完成
如果仔细观察,内部实现现在是这样的
ThroughputThrottler throttler = new ThroughputThrottler(throughput, startMs);
所以你现在应该只设置吞吐量的值,不要担心线程的数量。