Kafka压力测试

https://baijiahao.baidu.com/s?id=1659440526240768516&wfr=spider&for=pc

 

Kafka性能测试内容

性能测试内容:

kafka的测试主要分为producer端的吞吐量,consumer端的吞吐量,以及判断影响两者的因素。在实际测试环境中,需根据具体情况调整测试的数据量与参数。

性能测试工具:

 

我们使用Kafka自带的性能测试工具完成本次测试,当安装了Apache 版本的Kafka时,该测试工具的位置在安装目录的bin目录下;当安装了CDH版本的Kafka时,该测试工具一般位于Kafka Parcel路径下,默认位置为:/opt/cloudera/parcels/KAFKA/lib/kafka/bin。

这里我们用到的测试工具为:

kafka-producer-perf-test.sh (生产端)

kafka-consumer-perf-test.sh (消费端)

测试脚本

kafka-producer-perf-test.sh --topic test-1 --num-records 100000 --record-size 1000  --throughput 2000 --producer-props bootstrap.servers=192.168.21.100:9092,192.168.21.101:9092,192.168.21.102:9092
参数解析:
--topic topic名称,本例为test-1
--num-records 总共需要发送的消息数,本例为100000
--record-size 每个记录的字节数,本例为1000
--throughput 吞吐量即每秒钟发送的记录数,本例为2000,内存大可以设置大点
--producer-props bootstrap.servers= 192.168.21.100:9092,192.168.21.101:9092,192.168.21.102:9092

 

测试步骤

a.Partition分区与速率的关系

1、建立两个topic,分别为test_part1与test_part2

kafka-topics.sh --zookeeper 192.168.1.81:2181 --create --topic test_part1 --partitions 1 --replication-factor 1

kafka-topics.sh --zookeeper 192.168.1.81:2181 --create --topic test_part2 --partitions 5 --replication-factor 1

2、test_part1进行测试跑批:

kafka-producer-perf-test.sh --topic test_part1 --num-records 2000000 --record-size 200 --throughput 300000 --producer-props bootstrap.servers=192.168.1.82:9092

运行结果:

2000000 records sent, 136211.945788 records/sec (25.98 MB/sec), 1002.59 ms avg latency, 2559.00 ms max latency, 801 ms 50th, 2271 ms 95th, 2538 ms 99th, 2553 ms 99.9th.

3、test_part2进行测试跑批:

kafka-producer-perf-test.sh --topic test_part2 --num-records 2000000 --record-size 200 --throughput 300000 --producer-props bootstrap.servers=192.168.1.82:9092

运行结果:

2000000 records sent, 187529.301453 records/sec (35.77 MB/sec), 520.00 ms avg latency, 2196.00 ms max latency, 336 ms 50th, 1922 ms 95th, 2159 ms 99th, 2190 ms 99.9th.

结论:Producer端传输效率和partition数成正比。

 

b.Replication与速率的关系

1、建立两个topic, 分别为test_rep1与test_rep2,两个topic除了replication数量不一致外其他参数完全一致,使用kafka-producer-perf-test.sh进行测试。

kafka-topics.sh --zookeeper 192.168.1.81:2181 --create --topic test_rep1 --partitions 1 --replication-factor 1

kafka-topics.sh --zookeeper 192.168.1.81:2181 --create --topic test_rep2 --partitions 1 --replication-factor 3

2、test_rep1进行跑批测试:

kafka-producer-perf-test.sh --topic test_rep1 --num-records 2000000 --record-size

运行结果:

2000000 records sent, 217438.573603 records/sec (41.47 MB/sec), 610.43 ms avg latency, 1387.00 ms max latency, 497 ms 50th, 1284 ms 95th, 1341 ms 99th, 1386 ms 99.9th.

3、test_rep2进行跑批测试:

kafka-producer-perf-test.sh --topic test_rep2 --num-records 2000000 --record-size 200 --throughput 300000 --producer-props bootstrap.servers=192.168.1.82:9092

运行结果:

2000000 records sent, 103423.311614 records/sec (19.73 MB/sec), 1353.03 ms avg latency, 4050.00 ms max latency, 1213 ms 50th, 3042 ms 95th, 3998 ms 99th, 4047 ms 99.9th

结论:Producer端传输效率和replication数量成反比。

posted @   碳酸H2CO3  阅读(369)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示