kafka压测工具及实践指南

2021-08-26 19:57:16 浏览数 (2)

消费性能压测

压测命令

1.获取metada数据: ./tools getMetadata 127.0.0.1:9092 格式:./tools getMetadata 实例地址 例子:./tools getMetadata 127.0.0.1:9092 2. 测试指定分区的消费速度: 格式:./tools partitionConsumerRate 实例地址 topic名称 分区号 kafka版本(1.1.1和0.10.2) 例子:./tools partitionConsumerRate 127.0.0.1:9092 topic1 0 1.1.1

工具包请联系作者。

单个partition的压测

压测命令

timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 150

输出

[root@cs3 /tmp/ckafka_tools_0.0.1/bin]# timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 150 命令行的参数有 5 brokerList:11.187.29.197:9092 topic:ods_finder_log_19501_sec_i partition:150 kafka version:1.1.1 brokerList array:[11.187.29.197:9092] time:2021-08-26 17:57:02,count:18022,size=19638986 time:2021-08-26 17:57:03,count:46739,size=51057033 time:2021-08-26 17:57:04,count:62756,size=68746666 time:2021-08-26 17:57:05,count:61760,size=67774557 time:2021-08-26 17:57:06,count:61126,size=67806610 time:2021-08-26 17:57:07,count:61734,size=67773129

当前时间:time:2021-08-26 17:57:02

这一秒消费的条数:count:18022

这一秒消费的消息总大小:size=19638986

topic全部partition压测

并发压测topic所有partition,比如topic ods_finder_log_19501_sec_i 总共300个partition,用20台机器压测,每台机器启动15个进程,每个进程分配一个partition

为每台机器分配好partition,生成并行消费命令,分发到目标机器

timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 135 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 136 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 137 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 138 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 139 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 140 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 141 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 142 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 143 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 144 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 145 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 146 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 147 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 148 &timeout 120 ./tools partitionConsumerRate 11.187.29.197:9092 ods_finder_log_19501_sec_i 149 &wait

并行执行压测脚本,并对结果进行汇总

汇总所有机器的压测结果

#!/usr/bin/python result = {} with open("result") as fobj: for line in fobj: if not line.startswith("time"): continue time = line.split(',')[0].split(' ')[1] count = line.split(',')[1].split(':')[1] result[time] = result.get(time, 0) int(count) result = list(result.items()) result.sort(key=lambda one:one[1]) for time, count in result print(time, count)

压测结果举例

时间 消费条数

17:04:42 3463576 17:04:43 3402268 17:04:44 3368537 17:04:45 3404570 17:04:46 3335707 17:04:47 3352064 17:04:48 3413013 17:04:49 3341554 17:04:50 3355119 17:04:51 3391788 17:04:52 3382863 17:04:53 3264890 17:04:54 3397239

0 人点赞