kafka性能测试

一、介绍

Kafka官方在安装包的bin目录下提供了kafka-producer-perf-test.sh和kafka-consumer-perf-test.sh两个压力测试脚本,分别用于测试生产者和消费者的性能。通过Kafka压力测试脚本,能够得知Kafka集群的性能瓶颈所在(CPU/内存/网络带宽)等,在通常情况下Kafka集群的性能瓶颈是网络带宽

二、生产者压力测试

创建一个主题test

./kafka-topics.sh --create --zookeeper 116.62.13.104:2181 --topic test --partitions 2 --replication-factor 1

开始测试:

topic指定消息存放的topic :test
record-size是一条信息有多大(单位是Byte):200B
num-records是总共发送多少条信息 :10000
throughput是每秒多少条信息

./kafka-producer-perf-test.sh  --topic test --record-size 200 --num-records 10000 --throughput 1000 --producer-props bootstrap.servers=172.30.118.68:9092  
1791 records sent, 330.5 records/sec (0.06 MB/sec), 1465.8 ms avg latency, 3629.0 max latency.
1078 records sent, 208.8 records/sec (0.04 MB/sec), 5392.9 ms avg latency, 7718.0 max latency.
1848 records sent, 308.9 records/sec (0.06 MB/sec), 9319.5 ms avg latency, 11853.0 max latency.
1386 records sent, 261.9 records/sec (0.05 MB/sec), 13290.8 ms avg latency, 15757.0 max latency.
1078 records sent, 191.8 records/sec (0.04 MB/sec), 17191.0 ms avg latency, 20301.0 max latency.
924 records sent, 181.4 records/sec (0.03 MB/sec), 21931.1 ms avg latency, 24458.0 max latency.
770 records sent, 138.9 records/sec (0.03 MB/sec), 26450.5 ms avg latency, 29244.0 max latency.
10000 records sent, 235.726746 records/sec (0.04 MB/sec), 13813.99 ms avg latency, 32619.00 ms max latency, 12140 ms 50th, 31488 ms 95th, 32521 ms 99th, 32610 ms 99.9th.

在这里插入图片描述


10000 records sent, 235.726746 records/sec (0.04 MB/sec), 13813.99 ms avg latency, 32619.00 ms max latency, 12140 ms 50th, 31488 ms 95th, 32521 ms 99th, 32610 ms 99.9th.

结果分析:
发送记录数10000条,
每秒发送记录数235.726746条,
每秒发送数据量0.04 MB,
平均每条记录延迟 13813.99ms,
最大延迟 32619.00ms

三、消费者压力测试

zookeeper指定zookeeper集群,
topic指定消费的topic,
fetch-size指定每次取出的数据大小(单位为Byte)
messages总共消费的消息个数
threads 线程数量

./kafka-consumer-perf-test.sh --zookeeper 116.62.13.104:2181 --topic test --fetch-size 200 --messages 10000 --threads 1
start.time, end.time, data.consumed.in.MB, MB.sec, data.consumed.in.nMsg, nMsg.sec
2020-09-05 16:57:13:685, 2020-09-05 16:57:30:844, 1.9073, 0.1112, 10000, 582.7845

在这里插入图片描述

结果分析:
本次消费开始时间2020-09-05 16:57:13:685
本次消费结束时间2020-09-05 16:57:30:844
消费数据量 1.9073MB,
平均每秒吞吐 0.1112MB/s,
消费记录数 10000条,
平均每秒消费 582.7845

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Liu_Shihao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值