压测实操--produce压测方案

九月1年前技术文章564

环境信息:

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

Producer相关参数

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

图1.png

在producer涉及到性能的关键因素可能会存在如下几个:

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

bath-size:处理的数据批次大小;

ack:主从同步策略,在生产消息时特别需要注意,是follower收到后返回还是只是leader收到后返回,这对于吞吐量影响颇大;

message-size:单条消息的大小,要在producer和broker中设置一个阈值,且它的大小范围对吞吐量也有影响;

compression-codec:压缩方式,目前有不压缩,gzip,snappy,lz4四种方式;

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

replication:副本数;

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

linger.ms:两次发送时间间隔,满足后刷一次数据。

produce测试

目前kafka堆内存为1G下进行

图2.png

创建topic名称为test_kafka_perf1,partition=3、replication=3。

bath-size

bath-size=1000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1     --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=	1000   --throughput 30000


kafka指标

kafka仪表盘限制topic条件,获取仪表盘指标。

fetch请求延迟正增长,延迟在执行命令过程中逐渐增高

图8.png

produce请求延迟正增长,延迟在执行命令过程中逐渐增高

bath-size=2000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1     --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=2000   --throughput 30000

具体指标仪表盘与上述条件一致。

bath-size=10000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1     --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=10000   --throughput 30000

bath-size=20000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1     --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=20000   --throughput 30000

ack

ack=0

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=0   --throughput 30000

ack=1

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1   --throughput 30000

ack=-1

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=-1   --throughput 30000

message-size

record-size =687

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=-1  --throughput 30000

record-size =454

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --num-records 100000000 --record-size 454  --producer-props   bootstrap.servers=172.16.120.30:6667,172.16.120.36:6667,172.16.120.37:6667  batch.size=5000 acks=-1  --throughput 30000

compression-codec

compression.type=none

batch.size=5000,并发量在30000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1 compression.type=none  --throughput 30000

batch.size=10000,并发量在50000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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=10000 acks=1 compression.type=none  --throughput 50000

compression.type=gzip

batch.size=5000,并发量在30000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1 compression.type=gzip  --throughput 30000

batch.size=10000,并发量在50000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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=10000 acks=1 compression.type=gzip  --throughput 50000

compression.type=snappy

batch.size=5000,并发量=30000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1 compression.type=snappy  --throughput 30000

compression.type=lz4

batch.size=5000,并发量=30000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1 compression.type=lz4  --throughput 30000

partition

partition=1

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf1  --partitions 1 --replication-factor 1
./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1 compression.type=lz4  --throughput 30000


partition=2

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf1  --partitions 2 --replication-factor 1
./kafka-producer-perf-test.sh  --topic test_kafka_perf2 --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 acks=1 compression.type=lz4  --throughput 30000

partition=3

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf1  --partitions 3 --replication-factor 1
./kafka-producer-perf-test.sh  --topic test_kafka_perf3 --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 acks=1 compression.type=lz4  --throughput 30000

replication

replication=1

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf1  --partitions 1 --replication-factor 1
./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1 compression.type=lz4  --throughput 30000

replication=2

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf4  --partitions 1 --replication-factor 2
./kafka-producer-perf-test.sh  --topic test_kafka_perf4 --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 acks=1 compression.type=lz4  --throughput 30000


replication=3

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf5  --partitions 1 --replication-factor 3
./kafka-producer-perf-test.sh  --topic test_kafka_perf5 --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 acks=1 compression.type=lz4  --throughput 30000

throughput

./kafka-topics.sh --create  --zookeeper mutong01:2181,mutong02:2181,mutong03:2181  --topic test_kafka_perf1  --partitions 1 --replication-factor


throughput=10000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1  --throughput 10000

throughput=30000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1  --throughput 30000

throughput=50000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1  --throughput 50000

throughput=80000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1  --throughput 80000


throughput=100000

./kafka-producer-perf-test.sh  --topic test_kafka_perf1 --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 acks=1  --throughput 100000

结论:

使用kafka自带的kafka-producer-perf-test.sh脚本对集群生产消息情况进行压测,根据业务情况设置要测试的num-records条数。不同的变量因素,通过修改其中一个变量条件,固定其余变量值,获取对应的吞吐速率。比如修改batch-size条件,其他变量保持不变,根据结果就可以获取每秒的生产消息大小和每秒的消费消息条数等指标,整理不同条件下的指标结果,形成曲线就可以观察具体的消费趋势。

比如batch-size条件下

batch-size

ack

message-size

compression-codec

partition

replication

throughput

mb/s

msgnum/s

1000

0

687

none

3

3

30000

13.1

17550

2000

0

687

none

3

3

30000

21.6

30540

5000

0

687

none

3

3

30000

21.2

30044

10000

0

687

none

3

3

30000

21.1

29987

20000

0

687

none

3

3

30000

21

30005

图12.png


相关文章

Hbase2.x 使用hbck2

Hbase2.x 使用hbck2

1、背景默认情况下apache hbase 使用hbck2时,无法使用-j 来加载hbck2的jar包,无法进行修复2、解决办法是由于默认情况下只使用自带的hbase hbck修复命令,大部分功能在2...

MySQL 自增列使用上的一些 “坑”

MySQL 自增列使用上的一些 “坑”

前言MySQL 的规范中,一般都会建议表要有主键,常使用自增列作为主键字段,这和 MySQL 属于聚簇索引表有关,顺序增长的主键比较合适。最近有研发咨询,为什么有张表的自增主键变的非常大?而且偶尔还出...

将Nexus作为容器镜像仓库的配置过程

将Nexus作为容器镜像仓库的配置过程

Docker,Helm和Kubernetes的简化容器管理Nexus Repository建立在广泛的企业存储功能之上,是适用于所有Docker镜像和Helm Chart存储库的强大的注册表。Nexu...

Kubernetes安全--基于sa和user的rbac认证机制

前言Kubernetes中的用户K8S中有两种用户(User)——服务账号(ServiceAccount)和普通意义上的用户(User)ServiceAccount是由K8S管理的,而User通常是在...

Centos系统支持TLS 1.3

Centos系统支持TLS 1.3

一、背景1、生产的 CentOS 7 服务器需要启用 TLS 1.32、Openssl介绍OpenSSL 是用于传输层安全性 (TLS) 和安全套接字层 (SSL) 协议的强大、商业级且功能齐全的工具...

Clickhouse MergeTree原理(二)—— 表和分区的维护

MergeTree是Clickhouse中最核心的存储引擎。上一篇文章中,我们介绍了MergeTree的基本结构。1、MergeTree由分区(partiton)和part组成。2、Part是Merg...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。