org.apache.kafka.tools.ProducerPerformance Kafka的`--num-threads`选项的替代方案

问题描述 投票:0回答:1

卡夫卡已从--num-threadsoption of org.apache.kafka.tools.ProducerPerformance中删除了Kafka 2.0选项

这个的另一个解决方案是什么?

apache-kafka kafka-producer-api
1个回答
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);

所以你现在应该只设置吞吐量的值,不要担心线程的数量。

© www.soinside.com 2019 - 2024. All rights reserved.