为什么kafka生产者(性能测试)具有如此低的吞吐量/高延迟?

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

我是kafka的新手,正在运行一些性能测试。我正在运行一个由两台计算机组成的集群,其中包括我的笔记本电脑和一个覆盆子pi零W(1 GHz,单核CPU,512 MB RAM,802.11n无线局域网)。最终pi将运行单个生产者(java),该生产者将二进制传感器数据(最好是较小的记录,例如10 kb,尽快)发送到kafka,然后由消费者在我的笔记本电脑或其他pi上读取。一个单独的应用程序随后离线处理数据。我只有1个主题,带有1个分区,没有复制。

我目前正在尝试对生产者的性能进行基准测试/了解其功能。这是kafka-producer-perf-test.sh的输出,表明存在相当大的延迟,但吞吐量却不高。我玩过各种设置(例如linger.ms,batch.size,acks,吞吐量和记录大小),似乎记录大小越大,吞吐量就越高(直到〜750 kb,然后减小),但是延迟大约相同或实际上减少。

我只能达到〜0.6 MB / sec,这对于我正在处理的应用程序来说太慢了。当我减小记录大小时,吞吐速率甚至更低,为〜0.10 MB /秒。由于我是kafka的新手,所以我想知道这是使用pi zero w时应该期待的还是我的设置/生产者属性不理想的东西等等?

pi@raspberrypi:~/Kafka/kafka_2.12-2.4.0 $ bin/kafka-producer-perf-test.sh --topic perf_test --num-records 100 --thughput 1000000 --producer-props bootstrap.servers=192.168.0.170:9092,192.168.0.172:9092 --record-size 750000
OpenJDK Zero VM warning: G1 GC is disabled in this release.
2 records sent, 0.3 records/sec (0.25 MB/sec), 4439.5 ms avg latency, 4607.0 ms max latency.
5 records sent, 0.9 records/sec (0.62 MB/sec), 6909.0 ms avg latency, 9180.0 ms max latency.
5 records sent, 0.8 records/sec (0.58 MB/sec), 12783.4 ms avg latency, 15075.0 ms max latency.
5 records sent, 0.8 records/sec (0.59 MB/sec), 18587.0 ms avg latency, 21165.0 ms max latency.
5 records sent, 0.9 records/sec (0.62 MB/sec), 24551.2 ms avg latency, 26851.0 ms max latency.
4 records sent, 0.8 records/sec (0.55 MB/sec), 30048.0 ms avg latency, 31850.0 ms max latency.
5 records sent, 0.9 records/sec (0.62 MB/sec), 35323.4 ms avg latency, 37657.0 ms max latency.
5 records sent, 0.9 records/sec (0.63 MB/sec), 41030.4 ms avg latency, 43266.0 ms max latency.
5 records sent, 0.8 records/sec (0.59 MB/sec), 46736.6 ms avg latency, 49240.0 ms max latency.
5 records sent, 0.9 records/sec (0.62 MB/sec), 51716.2 ms avg latency, 53756.0 ms max latency.
5 records sent, 0.9 records/sec (0.63 MB/sec), 53765.8 ms avg latency, 53848.0 ms max latency.
5 records sent, 0.9 records/sec (0.61 MB/sec), 53506.2 ms avg latency, 53731.0 ms max latency.
4 records sent, 0.8 records/sec (0.55 MB/sec), 53638.3 ms avg latency, 54029.0 ms max latency.
5 records sent, 0.9 records/sec (0.62 MB/sec), 53690.4 ms avg latency, 54003.0 ms max latency.
5 records sent, 0.9 records/sec (0.64 MB/sec), 53371.6 ms avg latency, 53703.0 ms max latency.
5 records sent, 0.9 records/sec (0.62 MB/sec), 52922.0 ms avg latency, 53008.0 ms max latency.
4 records sent, 0.7 records/sec (0.53 MB/sec), 53774.3 ms avg latency, 53805.0 ms max latency.
5 records sent, 0.9 records/sec (0.63 MB/sec), 53788.6 ms avg latency, 53827.0 ms max latency.
5 records sent, 0.9 records/sec (0.64 MB/sec), 53317.2 ms avg latency, 53698.0 ms max latency.
5 records sent, 0.8 records/sec (0.60 MB/sec), 53373.2 ms avg latency, 53406.0 ms max latency.
5 records sent, 0.9 records/sec (0.63 MB/sec), 53441.8 ms avg latency, 53476.0 ms max latency.
100 records sent, 0.816993 records/sec (0.58 MB/sec), 42056.90 ms avg latency, 54029.00 ms max latency, 52990 ms 50th, 53805 ms 95th, 54029 ms 99th, 54029 ms 99.9th.
apache-kafka raspberry-pi kafka-producer-api
1个回答
0
投票

将邮件批量发送,然后再发送到Kafka。批处理中的消息数量越多,一次发送就可以发送越多,吞吐量就越高。

如果要增加邮件大小,那么还必须增加batch.size,以便每个批次在其中分配更多数量的邮件。

根据您粘贴的代码,没有设置batch.size的属性,因此它将是默认值,即16384字节(16KB),比消息大小(750 kb)小得多,因此这就是为什么您看到0.3记录/秒,依此类推。

batch.size documentation

不会尝试批大于该大小的记录。

因此,您可以尝试增加batch.size来分配更多消息,例如,大约10Mb并检查。

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