压测实操--kafka-consumer压测方案
创始人
2024-12-16 18:35:22

作者:九月

环境信息:

操作系统centos7.9,kafka版本为hdp集群中的2.0版本。

Consumer相关参数

使用Kafka自带的kafka-consumer-perf-test.sh脚本进行压测,该脚本参数为:

请添加图片描述

请添加图片描述

请添加图片描述

thread:测试时的单机线程数;

fetch-size:抓取数据量;

partition:分区数,主要是和线程复合来测试;

replication:副本数;

througout:我们所需要的吞吐量,单位时间内处理消息的数量,可能对我们处理消息的延迟有影响;

consumer测试

fetch-size

fetch-size=524288
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --messages 10000000 --fetch-size  524288  --threads 4 
fetch-size=1048576
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --messages 10000000 --fetch-size  1048576  --threads 4 
fetch-size=2097152
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --messages 10000000 --fetch-size  2097152  --threads 4 
fetch-size=3145728
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --messages 10000000 --fetch-size  3145728  --threads 4 
fetch-size=4194304
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --messages 10000000 --fetch-size  4194304  --threads 4 
fetch-size=5242880
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --messages 1000000 --fetch-size  5242880  --threads 4 

partitions

创建不同partitions的topic
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_consumer1  --partitions 1 --replication-factor 1  /usr/hdp/3.1.5.0-152/kafka/bin/kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_consumer2  --partitions 2 --replication-factor 1  /usr/hdp/3.1.5.0-152/kafka/bin/kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_consumer3  --partitions 3 --replication-factor 1  /usr/hdp/3.1.5.0-152/kafka/bin/kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_consumer4  --partitions 4 --replication-factor 1 
topic生产数据
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-producer-perf-test.sh  --topic test_kafka_consumer1 --num-records  100000000 --record-size 687  --producer-props bootstrap.servers=172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667  batch.size=5000 --throughput 30000  /usr/hdp/3.1.5.0-152/kafka/bin/kafka-producer-perf-test.sh  --topic test_kafka_consumer2 --num-records  100000000 --record-size 687  --producer-props bootstrap.servers=172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667  batch.size=5000 --throughput 30000  /usr/hdp/3.1.5.0-152/kafka/bin/kafka-producer-perf-test.sh  --topic test_kafka_consumer3 --num-records  100000000 --record-size 687  --producer-props bootstrap.servers=172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667  batch.size=5000 --throughput 30000  /usr/hdp/3.1.5.0-152/kafka/bin/kafka-producer-perf-test.sh  --topic test_kafka_consumer4 --num-records  100000000 --record-size 687  --producer-props bootstrap.servers=172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667  batch.size=5000 --throughput 30000 
消费不同partitions的topic

消费不同partitions的topic,获取不同partition下的吞吐量

/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer1 --messages 10000000 --fetch-size  1048576  --threads 4   /usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer2 --messages 10000000 --fetch-size  1048576  --threads 4   /usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer3 --messages 10000000 --fetch-size  1048576  --threads 4   /usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer4 --messages 10000000 --fetch-size  1048576  --threads 4 

fetch-threads

fetch-thread=1
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --fetch-size 1048576  --messages 10000000  --threads 1  --num-fetch-threads 1 
fetch-thread=4
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --fetch-size 1048576  --messages 10000000  --threads 1  --num-fetch-threads 4 
fetch-thread=7
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --fetch-size 1048576  --messages 10000000  --threads 1  --num-fetch-threads 7 
fetch-thread=10
/usr/hdp/3.1.5.0-152/kafka/bin/kafka-consumer-perf-test.sh --broker-list 172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667 --topic test_kafka_consumer --fetch-size 1048576  --messages 10000000  --threads 1  --num-fetch-threads 10 

总结

使用kafka自带的kafka-consumer-perf-test.sh脚本对集群消费情况进行压测,根据业务情况设置要测试的messager条数。不同的变量因素,通过修改其中一个变量条件,固定其余变量值,获取对应的吞吐速率。整理不同条件下的指标结果,形成曲线就可以观察具体的消费趋势。

请添加图片描述

相关内容

热门资讯

“无人家务”渐行渐近 记者 李 均 宋迎迎 从AI技术的持续突破,到各类AI产品与智能终端的加速落地,再到智慧生活场景的日...
苏州工业园区 2026年防灾减... 在第18个全国防灾减灾日到来之际,5月11日,苏州工业园区2026年防灾减灾宣传周启动仪式暨AI赋能...
【好物】雅诗兰黛第7代小棕瓶京... 全网 618 大促现已正式开始,全场均年度好价,有需求的小伙伴速抢哦: 京东无门槛红包 京东无门槛...
原创 1... 2011年4月底,郴州开往湖北的火车上,一名少年满头大汗地捂着腰部,低声呻吟。列车员和周围乘客焦急地...
Geekom Air12 20... 随着中国制造商在紧凑且高性能迷你电脑领域的崛起,Geekom已成为备受瞩目的品牌之一。此前,其AMD...