rabbitmq性能测试PerfTest吞吐率最全评测

rabbitmq性能测试PerfTest吞吐率最全评测

用了几年了,还是四五年前做的性能测试。目前遇到性能瓶颈,为了找出真因,不得不测试下,得到基准线,再根据测试基准线寻求优化。

测试结果:

direct 类型 比 topic 吞吐率快2倍左右;自动ack 比 手动ack 吞吐率快2倍左右;短期消息持久化对吞吐率无明显影响;

rabbitmq使用建议:无额外需求,建议采用direct类型,且自动ACK;

备注:消息量超过2KB后,吞吐较低的原因目前来看,大部分因素的网卡流量问题,4*2KB队列,网卡流量已达到400Mb/S,与峰值几乎一致。其CPU与内存用量未达顶峰。

一、工具准备

服务器环境:Docker Rabbitmq,垃圾硬件,CPU:4U,RAM:6092MB,硬盘:HDD

客户端环境:Windows11

工具:PerfTest (rabbitmq官方推荐)

下载:https://www.rabbitmq.com/java-tools.html#using-perf-test

二、工具使用

博主帮助:

命令:runjava com.rabbitmq.perf.PerfTest

参数:

-x:生产者计数

-y:消费者计数

-h:mq服务地址

-u:队列名

-a:自动ack回复

--id:测试id

-f persistent:消息持久化

原生帮助:

\rabbitmq-perf-test-2.17.0.RC4-bin\rabbitmq-perf-test-2.17.0.RC4\bin>runjava com.rabbitmq.perf.PerfTest --help

usage:

-?,--help show usage

-a,--autoack auto ack

-A,--multi-ack-every multi ack every

-ad,--auto-delete should the queue be

auto-deleted, default is true

-b,--heartbeat heartbeat interval

-B,--body comma-separated list of files

to use in message bodies

-bc,--body-count number of pre-generated

message bodies. Use with

--json-body. Default is 100.

-bfc,--body-field-count number of pre-generated

fields and values for body.

Use with --json-body. Default

is 1000.

-c,--confirm max unconfirmed publishes

-C,--pmessages producer message count

-ca,--consumer-args consumer arguments as

key/values pairs, separated

by commas, e.g. x-priority=10

-cri,--connection-recovery-interval connection recovery interval

in seconds. Default is 5

seconds. Interval syntax,

e.g. 30-60, is supported to

specify an random interval

between 2 values between each

attempt.

-ct,--confirm-timeout waiting timeout for

unconfirmed publishes before

failing (in seconds)

-ctp,--consumers-thread-pools number of thread pools to use

for all consumers, default is

to use a thread pool for each

consumer

-d,--id test ID

-D,--cmessages consumer message count

-dcr,--disable-connection-recovery disable automatic connection

recovery

-e,--exchange exchange name

-E,--exclusive use server-named exclusive

queues. Such queues can only

be used by their declaring

connection!

-env,--environment-variables show usage with environment

variables

-ew,--exit-when exit when queue(s) empty or

consumer(s) idle for 1

second, valid values are

empty or idle

-f,--flag message flag(s), supported

values: persistent and

mandatory. Use the option

several times to specify

several values.

-h,--uri connection URI

-H,--uris connection URIs (separated by

commas)

-hst,--heartbeat-sender-threads number of threads for

producers and consumers

heartbeat senders

-i,--interval sampling interval in seconds

-jb,--json-body generate a random JSON

document for message body.

Use with --size.

-k,--routing-key routing key

-K,--random-routing-key use random routing key per

message

-l,--legacy-metrics display legacy metrics

(min/avg/max latency)

-L,--consumer-latency consumer latency in

microseconds

-m,--ptxsize producer tx size

-M,--framemax frame max

-mh,--metrics-help show metrics usage

-mp,--message-properties message properties as

key/value pairs, separated by

commas, e.g. priority=5

-ms,--use-millis should latency be collected

in milliseconds, default is

false. Set to true if

producers are consumers run

on different machines.

-n,--ctxsize consumer tx size

-na,--nack nack messages, requeue them

by default.

-niot,--nio-threads number of NIO threads to use

-niotp,--nio-thread-pool size of NIO thread pool,

should be slightly higher

than number of NIO threads

-o,--output-file output file for timing

results

-p,--predeclared allow use of predeclared

objects

-P,--publishing-interval publishing interval in

seconds (opposite of producer

rate limit)

-pi,--polling-interval time to wait before polling

with basic.get, in

millisecond, default is 0.

-po,--polling use basic.get to consume

messages. Do not use this in

real applications.

-prsd,--producer-random-start-delay max random delay in seconds

to start producers

-pst,--producer-scheduler-threads number of threads to use when

using --publishing-interval

-q,--qos consumer prefetch count

-Q,--global-qos channel prefetch count

-qa,--queue-args queue arguments as key/value

pairs, separated by commas,

e.g. x-max-length=10

-qf,--queue-file file to look up queue names

from

-qp,--queue-pattern queue name pattern for

creating queues in sequence

-qpf,--queue-pattern-from queue name pattern range

start (inclusive)

-qpt,--queue-pattern-to queue name pattern range end

(inclusive)

-qq,--quorum-queue create quorum queue(s)

-r,--rate producer rate limit

-R,--consumer-rate consumer rate limit

-re,--requeue should nacked messages be

requeued, default is true.

-rkcs,--routing-key-cache-size size of the random routing

keys cache. See

--random-routing-key.

-S,--slow-start start consumers slowly (1 sec

delay between each)

-s,--size message size in bytes

-sb,--skip-binding-queues don't bind queues to the

exchange

-se,--sasl-external use SASL EXTERNAL

authentication, default is

false. Set to true if using

client certificate

authentication with the

rabbitmq_auth_mechanism_ssl

plugin.

-sni,--server-name-indication server names for Server Name

Indication TLS parameter,

separated by commas

-sst,--servers-startup-timeout start timeout in seconds (in

case the servers(s) is (are)

not available when the run

starts). Default is to fail

immediately if the servers(s)

is (are) not available.

-st,--shutdown-timeout shutdown timeout, default is

5 seconds

-sul,--servers-up-limit number of available servers

needed before starting the

run. Used in conjunction with

--servers-start-timeout.

Default is deduced from --uri

or --uris.

-t,--type exchange type

-T,--body-content-type body content-type

-u,--queue queue name

-udsc,--use-default-ssl-context use JVM default SSL context

-v,--version print version information

-vl,--variable-latency variable consumer processing

latency with

[MICROSECONDS]:[DURATION]

syntax, where [MICROSECONDS]

integer >= 0 and [DURATION]

integer > 0. Use the option

several times to specify

several values.

-vr,--variable-rate variable publishing rate with

[RATE]:[DURATION] syntax,

where [RATE] integer >= 0 and

[DURATION] integer > 0. Use

the option several times to

specify several values.

-vs,--variable-size variable message size with

[SIZE]:[DURATION] syntax,

where [SIZE] integer > 0 and

[DURATION] integer > 0. Use

the option several times to

specify several values.

-x,--producers producer count

-X,--producer-channel-count channels per producer

-y,--consumers consumer count

-Y,--consumer-channel-count channels per consumer

-z,--time run duration in seconds

(unlimited by default)

三、测试过程

2.1 测试1

条件:使用2个发布者和4个消费者:

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://user:xxx@192.168.6.5:5672" -u "perf-test1" -x 2 -y 4 -a --id "test 2"

结果:

条件:使用1个发布者和1个消费者:

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxx:xxxxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1-1" -a --id "test 1-1"

结果:

条件:一个生产者,一个消费者,消息大小从默认(12字节)更改为4 kB

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxxxx:xxxxxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1-1-4096" -a --id "test 1-1 4096" -s 4096

结果:

条件:一个生产者,一个消费者,消息大小默认12字节,手动确认

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxx:xxxxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1-1" --id "test 1-1"

结果:

条件:一个生产者,一个消费者, 消息大小默认12字节,手动确认,使用持久队列和持久消息

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxx:xxxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1-1" --id "test 1-1" -f persistent

结果:

条件:一个生产者,一个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxx:xxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1-1" --id "test 1-1" -f persistent -a

结果:

条件:二个生产者,四个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxx:xxxxxxxx@192.168.6.5:5672" -x 2 -y 4 -u "throughput-test-1-1" --id "test 1-1" -f persistent -a

结果:

条件:二个生产者,四个消费者, 消息大小默认12字节 ,手动确认,使用持久队列和持久消息

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxxxx:xxxxx@192.168.6.5:5672" -x 2 -y 4 -u "throughput-test-1-1" --id "test 1-1" -f persistent

结果:

条件:二个生产者,四个消费者, 消息大小默认12字节 ,手动确认,使用持久队列和持久消息 ,Topic类型

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxxxx:xxxx@192.168.6.5:5672" -x 2 -y 4 -u "throughput-test-1-1" --id "test 1-1" -f persistent -t "topic"

结果:

条件:二个生产者,四个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息,Topic类型

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxx:xxxxxx@192.168.6.5:5672" -x 2 -y 4 -u "throughput-test-1-1" --id "test 1-1" -f persistent -t "topic" -a

结果:

条件:一个生产者,一个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息,Topic类型

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxxxx:xxxxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1-1" --id "test 1-1" -f persistent -t "topic" -a

结果:

条件:四个生产者,八个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息,Direct类型

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxxx:xxxxxxx@192.168.6.5:5672" -x 4 -y 8 -u "throughput-test-1-1" --id "test 1-1" -f persistent -t "direct" -a

条件:四个工具一起测试* 一个生产者,一个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息,Direct类型

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://tianhengrd:gd6pYnYw3nlVrsoi@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-2-2" --id "test 2-2" -f persistent -t "direct" -a

结果:

条件:六个工具一起测试* 一个生产者,一个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息,Direct类型

结果:

条件:八个工具一起测试, * 一个生产者,一个消费者, 消息大小默认12字节 ,自动确认,使用持久队列和持久消息,Direct类型

结果:

资源消耗:

带宽消耗:

条件:四个工具一起测试* 一个生产者,一个消费者, 消息大小4KB ,自动确认,使用持久队列和持久消息,Direct类型

命令:

runjava com.rabbitmq.perf.PerfTest -h "amqp://xxxxx:xxxxxx@192.168.6.5:5672" -x 1 -y 1 -u "throughput-test-1" --id "test 1" -f persistent -t "direct" -a -s 4096

结果:

条件:四个工具一起测试* 一个生产者,一个消费者, 消息大2KB ,自动确认,使用持久队列和持久消息,Direct类型

结果:

相关内容

世界国旗测验
365bet足球比

世界国旗测验

📅 06-29 👁️ 189
尔有信审核需要多久?好下款吗?
365bet足球比

尔有信审核需要多久?好下款吗?

📅 07-31 👁️ 630
秒 到 小时 (s ⇄ h)
365bet足球比

秒 到 小时 (s ⇄ h)

📅 07-15 👁️ 8709
翯字起名最佳配字有哪些
下载旧版365彩票网软件

翯字起名最佳配字有哪些

📅 06-27 👁️ 4623