RabbitMQ--扩展--2.1--性能测试--window.md

RabbitMQ–扩展–2.1–性能测试–window.md


1、rabbitmq-perf-test工具

  1. 是一个测试吞吐量的性能测试工具
  2. 基于Java开发的客户端
  3. 有额外的工具可以输出成HTML图形
  4. 能够对RabbitMQ单节点和集群进行性能测试。
  5. 可以模拟下面2种负载
    1. 基本负载
    2. 高级负载

1.1、下载地址

https://github.com/rabbitmq/rabbitmq-perf-test/releases

在这里插入图片描述

在这里插入图片描述

2、安装

2.2、直接解压

在这里插入图片描述

2.2、将标红的文件贝到bin目录下

在这里插入图片描述

在这里插入图片描述

结果

在这里插入图片描述

3、使用说明

3.1、切换到bin目录下

在这里插入图片描述

3.2、查看帮助

runjava com.rabbitmq.perf.PerfTest --help

内容

D:\rabbitmq-perf-test-2.18.0\bin>runjava com.rabbitmq.perf.PerfTest --help
usage: <program>
 -?,--help                                   show usage
-a,--autoack                                auto ack(客户端在处理完messages之后会给服务端返回一个ack确认信息,服务端在收到该ack信息之后才会把messages删除)
 -A,--multi-ack-every <arg>                  (每多少条消息返回一次ack信息给服务器端,消费者可以一次确认多条消息,例如,下面是100条消息确认一次
											 runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "test-6" --id "test-6" -f persistent --multi-ack-every 100)
 -ad,--auto-delete <arg>                     should the queue be
                                             auto-deleted, default is true
 -b,--heartbeat <arg>                        heartbeat interval
 -B,--body <arg>                             (使用逗号分隔的文件列表,用在消息的内容中(这里是多个由逗号分隔开的文件名,把文件中的内容作为消息体写入到指定queue中))
 -bc,--body-count <arg>                      number of pre-generated
                                             message bodies. Use with
                                             --json-body. Default is 100.
 -bfc,--body-field-count <arg>               number of pre-generated
                                             fields and values for body.
                                             Use with --json-body. Default
                                             is 1000.
 -c,--confirm <arg>                          (未确认消息发布的最大值)
 -C,--pmessages <arg>                        (生产者要生成的消息的数量,译者注:在此次性能测试中,生产者一旦生成了指定数量的消息,就会停止。)
 -ca,--consumer-args <arg>                   consumer arguments as
                                             key/values pairs, separated
                                             by commas, e.g. x-priority=10
 -cri,--connection-recovery-interval <arg>   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 <arg>                 waiting timeout for
                                             unconfirmed publishes before
                                             failing (in seconds)
 -ctp,--consumers-thread-pools <arg>         number of thread pools to use
                                             for all consumers, default is
                                             to use a thread pool for each
                                             consumer
 -d,--id <arg>                               (本次测试的编号,身份标识)
 -D,--cmessages <arg>                        (消费者要消费的消息数量,也就是指定这次测试中消费者一共要消费多少条消息,一旦消费者消费了这么多条消息,消费者就会被停止)
 -dcr,--disable-connection-recovery          disable automatic connection
                                             recovery
 -e,--exchange <arg>                         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 <arg>                       exit when queue(s) empty or
                                             consumer(s) idle for 1
                                             second, valid values are
                                             empty or idle
 -f,--flag <arg>                             (消息标志,多个可以用逗号隔开,支持的值:persistent 和 mandatory)
 -h,--uri <arg>                              connection URI
 -H,--uris <arg>                             connection URIs (separated by
                                             commas)
 -hst,--heartbeat-sender-threads <arg>       (生产者和消费者的心跳发送者的线程数量)
 -i,--interval <arg>                         sampling interval in seconds
 -jb,--json-body                             generate a random JSON
                                             document for message body.
                                             Use with --size.
 -k,--routing-key <arg>                      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 <arg>                 consumer latency in
                                             microseconds
 -m,--ptxsize <arg>                          producer tx size
 -M,--framemax <arg>                         frame max
 -mh,--metrics-help                          show metrics usage
 -mp,--message-properties <arg>              (消息属性以逗号隔开的键值对方式,比如priority=5)
 -ms,--use-millis                            (是否收集延迟时间,单位毫秒。默认是关闭的。如果生产者和消费者在不同的主机上运行,那么就将其设置成为true。)
 -n,--ctxsize <arg>                          consumer tx size
 -na,--nack                                  nack messages, requeue them
                                             by default.
 -niot,--nio-threads <arg>                   number of NIO threads to use
 -niotp,--nio-thread-pool <arg>              size of NIO thread pool,
                                             should be slightly higher
                                             than number of NIO threads
 -o,--output-file <arg>                      output file for timing
                                             results
 -p,--predeclared                            (允许使用预定义的对象)
 -P,--publishing-interval <arg>              publishing interval in
                                             seconds (opposite of producer
                                             rate limit)
 -pi,--polling-interval <arg>                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 <arg>   max random delay in seconds
                                             to start producers
 -pst,--producer-scheduler-threads <arg>     number of threads to use when
                                             using --publishing-interval
 -q,--qos <arg>                              (消费者预读取的数量)
 -Q,--global-qos <arg>                       channel prefetch count
 -qa,--queue-args <arg>                      队列参数键值对,使用逗号隔开,例如x-max-length=10
 -qf,--queue-file <arg>                      file to look up queue names
                                             from
 -qp,--queue-pattern <arg>                   (按顺序依次创建的队列名称模式)
 -qpf,--queue-pattern-from <arg>             queue name pattern range
                                             start (inclusive)
 -qpt,--queue-pattern-to <arg>               queue name pattern range end
                                             (inclusive)
 -qq,--quorum-queue                          create quorum queue(s)
 -r,--rate <arg>                             (生产者速度限制)
 -R,--consumer-rate <arg>                    (消费者速度限制)
 -re,--requeue <arg>                         should nacked messages be
                                             requeued, default is true.
 -rkcs,--routing-key-cache-size <arg>        size of the random routing
                                             keys cache. See
                                             --random-routing-key.
 -S,--slow-start                             start consumers slowly (1 sec
                                             delay between each)
 -s,--size <arg>                             (消息大小,单位是字节)
 -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 <arg>         server names for Server Name
                                             Indication TLS parameter,
                                             separated by commas
 -sst,--servers-startup-timeout <arg>        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 <arg>                shutdown timeout, default is
                                             5 seconds
 -sul,--servers-up-limit <arg>               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 <arg>                             exchange type
 -T,--body-content-type <arg>                (消息体内容类型)
 -u,--queue <arg>                            (队列名称)
 -udsc,--use-default-ssl-context             use JVM default SSL context
 -v,--version                                print version information
 -vl,--variable-latency <arg>                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 <arg>                   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 <arg>                   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 <arg>                        (生产者数量)
 -X,--producer-channel-count <arg>           channels per producer
 -y,--consumers <arg>                        (消费者数量)
 -Y,--consumer-channel-count <arg>           channels per consumer
 -z,--time <arg>                             (运行时间,单位是秒(默认没有限制))
 
 



4、测试

4.1、案例1:一个生产者,一个消费者

4.1.1、命令

runjava com.rabbitmq.perf.PerfTest -x 1 -y 1 -h "amqp://admin:123456@192.168.187.171:5672" -u "perf-test1" -a --id "test1"

4.1.2、字段说明

-x:生产者计数
-y:消费者计数
-h:mq服务地址,amqp://用户名:密码@ip:端口 
-u:队列名
-a:自动ack回复
--id:测试id

4.1.3、测试结果

D:\rabbitmq-perf-test-2.18.0\bin>runjava com.rabbitmq.perf.PerfTest -x 1 -y 1 -h "amqp://admin:123456@192.168.187.171:5672" -u "perf-test1" -a --id "test1"
id: test1, starting consumer #0
id: test1, starting consumer #0, channel #0
id: test1, starting producer #0
id: test1, starting producer #0, channel #0
id: test1, time: 138.081s, sent: 31947 msg/s, received: 31999 msg/s, min/median/75th/95th/99th consumer latency: 1589461/1839134/1895941/1944050/1952494 ?s
id: test1, time: 139.081s, sent: 33822 msg/s, received: 33104 msg/s, min/median/75th/95th/99th consumer latency: 1467838/1550897/1577622/1604447/1655744 ?s
id: test1, time: 140.081s, sent: 32971 msg/s, received: 32993 msg/s, min/median/75th/95th/99th consumer latency: 1467385/1519428/1546238/1561932/1565299 ?s
id: test1, time: 141.081s, sent: 29078 msg/s, received: 31683 msg/s, min/median/75th/95th/99th consumer latency: 1476433/1560186/1592792/1617739/1621775 ?s
id: test1, time: 142.081s, sent: 32970 msg/s, received: 31782 msg/s, min/median/75th/95th/99th consumer latency: 1520371/1611109/1634437/1662345/1675602 ?s
id: test1, time: 143.081s, sent: 32971 msg/s, received: 33580 msg/s, min/median/75th/95th/99th consumer latency: 1480396/1558997/1582107/1601601/1613732 ?s
id: test1, time: 144.081s, sent: 33499 msg/s, received: 33631 msg/s, min/median/75th/95th/99th consumer latency: 1448887/1504363/1528815/1547203/1556099 ?s
id: test1, time: 145.081s, sent: 35991 msg/s, received: 34317 msg/s, min/median/75th/95th/99th consumer latency: 1423745/1486653/1511791/1531865/1541736 ?s
id: test1, time: 146.081s, sent: 32799 msg/s, received: 34557 msg/s, min/median/75th/95th/99th consumer latency: 1411141/1462612/1486979/1505949/1511484 ?s
id: test1, time: 147.081s, sent: 34342 msg/s, received: 33651 msg/s, min/median/75th/95th/99th consumer latency: 1417127/1483281/1502078/1523400/1533298 ?s
id: test1, time: 148.081s, sent: 31599 msg/s, received: 32514 msg/s, min/median/75th/95th/99th consumer latency: 1431218/1497915/1514489/1538726/1557954 ?s
id: test1, time: 149.081s, sent: 32885 msg/s, received: 31320 msg/s, min/median/75th/95th/99th consumer latency: 1475524/1557159/1578444/1615174/1638212 ?s
id: test1, time: 150.081s, sent: 31118 msg/s, received: 31392 msg/s, min/median/75th/95th/99th consumer latency: 1563363/1643569/1672459/1699971/1703953 ?s
test stopped (Producer thread interrupted)
id: test1, sending rate avg: 34973 msg/s
id: test1, receiving rate avg: 34644 msg/s
终止批处理操作吗(Y/N)? y

  1. 平均每秒发送34973条消息
  2. 平均接收34644条消息

4.2、案例1:一个生产者,一个消费者,消息大小从默认(12字节)更改为4kB

4.2.1、命令

runjava com.rabbitmq.perf.PerfTest -x 1 -y 1 -h "amqp://admin:123456@192.168.187.171:5672" -u "perf-test1" -a --id "test1" -s 4000

 

4.2.2、测试结果

D:\rabbitmq-perf-test-2.18.0\bin>runjava com.rabbitmq.perf.PerfTest -x 1 -y 1 -h "amqp://admin:123456@192.168.187.171:5672" -u "perf-test1" -a --id "test1" -s 4000
id: test1, starting consumer #0
id: test1, starting consumer #0, channel #0
id: test1, starting producer #0
id: test1, starting producer #0, channel #0
id: test1, time: 1.004s, sent: 6560 msg/s, received: 5739 msg/s, min/median/75th/95th/99th consumer latency: 2804/171079/184382/197525/200432 ?s
id: test1, time: 2.004s, sent: 10157 msg/s, received: 10090 msg/s, min/median/75th/95th/99th consumer latency: 17199/77096/92523/114764/135740 ?s
id: test1, time: 3.005s, sent: 11626 msg/s, received: 11479 msg/s, min/median/75th/95th/99th consumer latency: 24540/84468/104340/127107/136572 ?s
id: test1, time: 4.005s, sent: 13232 msg/s, received: 12668 msg/s, min/median/75th/95th/99th consumer latency: 19636/87173/113783/153005/161371 ?s
id: test1, time: 5.005s, sent: 11422 msg/s, received: 12182 msg/s, min/median/75th/95th/99th consumer latency: 51308/118220/131615/147402/160069 ?s
id: test1, time: 6.005s, sent: 12138 msg/s, received: 11421 msg/s, min/median/75th/95th/99th consumer latency: 14493/91343/129409/171277/188008 ?s
id: test1, time: 7.005s, sent: 10370 msg/s, received: 10827 msg/s, min/median/75th/95th/99th consumer latency: 71728/135410/148423/180399/194773 ?s
id: test1, time: 8.005s, sent: 11390 msg/s, received: 11084 msg/s, min/median/75th/95th/99th consumer latency: 94059/125762/134381/147827/159826 ?s
id: test1, time: 9.005s, sent: 11566 msg/s, received: 11331 msg/s, min/median/75th/95th/99th consumer latency: 63993/122145/141687/161723/168559 ?s
id: test1, time: 10.005s, sent: 11815 msg/s, received: 12122 msg/s, min/median/75th/95th/99th consumer latency: 37179/121867/136183/151568/161614 ?s
id: test1, time: 11.005s, sent: 11915 msg/s, received: 11776 msg/s, min/median/75th/95th/99th consumer latency: 86412/127634/140837/152584/158874 ?s
id: test1, time: 12.005s, sent: 11943 msg/s, received: 12042 msg/s, min/median/75th/95th/99th consumer latency: 65459/126079/135909/152968/157344 ?s
id: test1, time: 13.005s, sent: 11809 msg/s, received: 11650 msg/s, min/median/75th/95th/99th consumer latency: 96057/127029/135531/146032/151924 ?s
id: test1, time: 14.005s, sent: 11028 msg/s, received: 11105 msg/s, min/median/75th/95th/99th consumer latency: 92369/133962/149412/174774/196739 ?s
id: test1, time: 15.005s, sent: 12106 msg/s, received: 12186 msg/s, min/median/75th/95th/99th consumer latency: 86460/124701/137172/149078/157246 ?s
id: test1, time: 16.005s, sent: 8703 msg/s, received: 8617 msg/s, min/median/75th/95th/99th consumer latency: 51196/137118/206512/276654/285505 ?s
id: test1, time: 17.005s, sent: 11957 msg/s, received: 11862 msg/s, min/median/75th/95th/99th consumer latency: 90510/134180/148892/240991/298318 ?s
test stopped (Producer thread interrupted)
id: test1, sending rate avg: 11175 msg/s
id: test1, receiving rate avg: 11121 msg/s
终止批处理操作吗(Y/N)? y


  1. 平均每秒发送11175条消息
  2. 平均接收11121条消息
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值