压测rabbitmq

1、首先下载perf-test 地址

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

2、在window下运行的jar包

 3、cmd 中运行 java -jar perf-test-2.18.0.jar --help

D:\IdeaProject>java -jar perf-test-2.18.0.jar --help
usage: <program>
 -?,--help                                   show usage
 -a,--autoack                                auto ack
 -A,--multi-ack-every <arg>                  multi ack every
 -ad,--auto-delete <arg>                     should the queue be
                                             auto-deleted, default is true
 -b,--heartbeat <arg>                        heartbeat interval
 -B,--body <arg>                             comma-separated list of files
                                             to use in message bodies
 -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>                          max unconfirmed publishes
 -C,--pmessages <arg>                        producer message count
 -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>                               test ID
 -D,--cmessages <arg>                        consumer message count
 -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>                             message flag(s), supported
                                             values: persistent and
                                             mandatory. Use the option
                                             several times to specify
                                             several values.
 -h,--uri <arg>                              connection URI
 -H,--uris <arg>                             connection URIs (separated by
                                             commas)
 -hst,--heartbeat-sender-threads <arg>       number of threads for
                                             producers and consumers
                                             heartbeat senders
 -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>              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 and consumers run
                                             on different machines.
 -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                            allow use of predeclared
                                             objects
 -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>                              consumer prefetch count
 -Q,--global-qos <arg>                       channel prefetch count
 -qa,--queue-args <arg>                      queue arguments as key/value
                                             pairs, separated by commas,
                                             e.g. x-max-length=10
 -qf,--queue-file <arg>                      file to look up queue names
                                             from
 -qp,--queue-pattern <arg>                   queue name pattern for
                                             creating queues in sequence
 -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>                             producer rate limit
 -R,--consumer-rate <arg>                    consumer rate limit
 -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>                             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 <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>                body content-type
 -u,--queue <arg>                            queue name
 -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>                        producer count
 -X,--producer-channel-count <arg>           channels per producer
 -y,--consumers <arg>                        consumer count
 -Y,--consumer-channel-count <arg>           channels per consumer
 -z,--time <arg>                             run duration in seconds
                                             (unlimited by default)

4、可以开始测试了 运行 java -jar perf-test-2.18.0.jar -x 1 -y 1 -h "amqp://用户名:密码@IP地址:5672" -u "perf-test1" -a --id "test1"

一个消费,一个生产 默认12字节的消息大小 接收和发送有1w+ msg/s

D:\IdeaProject>java -jar perf-test-2.18.0.jar -x 1 -y 1 -h "amqp://guest:guest@192.168.1.90: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: 1.021s, sent: 14172 msg/s, received: 5657 msg/s, min/median/75th/95th/99th consumer latency: 37673/269203/355316/425381/455220 ?s
id: test1, time: 2.027s, sent: 11712 msg/s, received: 8700 msg/s, min/median/75th/95th/99th consumer latency: 490930/999934/1035917/1107263/1113516 ?s
id: test1, time: 3.027s, sent: 48290 msg/s, received: 8609 msg/s, min/median/75th/95th/99th consumer latency: 990630/1178701/1294480/1400124/1430065 ?s
id: test1, time: 4.027s, sent: 15442 msg/s, received: 3004 msg/s, min/median/75th/95th/99th consumer latency: 1108750/1264782/2009943/2014026/2015008 ?s
id: test1, time: 5.030s, sent: 14164 msg/s, received: 16718 msg/s, min/median/75th/95th/99th consumer latency: 1986828/2327925/2451947/2681658/2709493 ?s
id: test1, time: 6.050s, sent: 9269 msg/s, received: 13739 msg/s, min/median/75th/95th/99th consumer latency: 2739128/3101117/3319024/3556032/3580218 ?s
id: test1, time: 7.050s, sent: 9532 msg/s, received: 14624 msg/s, min/median/75th/95th/99th consumer latency: 3614169/3958753/4203691/4369429/4389317 ?s
id: test1, time: 8.070s, sent: 12395 msg/s, received: 14208 msg/s, min/median/75th/95th/99th consumer latency: 3969283/4279018/4344865/4410693/4440197 ?s
id: test1, time: 9.082s, sent: 20785 msg/s, received: 13101 msg/s, min/median/75th/95th/99th consumer latency: 4087743/4451858/4557488/4637892/4756349 ?s
id: test1, time: 10.082s, sent: 12664 msg/s, received: 13835 msg/s, min/median/75th/95th/99th consumer latency: 3961701/4278813/4464813/4710258/4743507 ?s
test stopped (Producer thread interrupted)
id: test1, sending rate avg: 16438 msg/s
id: test1, receiving rate avg: 11376 msg/s

5、一个消费,一个生产 改成 4kb的消息大小 接收和发送只有2000+msg/s

D:\IdeaProject>java -jar perf-test-2.18.0.jar -x 1 -y 1 -h "amqp://guest:guest@192.168.1.90: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.000s, sent: 1831 msg/s, received: 84 msg/s, min/median/75th/95th/99th consumer latency: 7361/342620/503366/593332/594573 ?s
id: test1, time: 2.000s, sent: 2700 msg/s, received: 845 msg/s, min/median/75th/95th/99th consumer latency: 598928/1310775/1324150/1326589/1328369 ?s
id: test1, time: 3.000s, sent: 969 msg/s, received: 2823 msg/s, min/median/75th/95th/99th consumer latency: 1284278/1322110/1323202/1326041/1326520 ?s
id: test1, time: 4.000s, sent: 2050 msg/s, received: 1665 msg/s, min/median/75th/95th/99th consumer latency: 1128777/1310435/1376572/1459399/1469318 ?s
id: test1, time: 5.000s, sent: 2698 msg/s, received: 2456 msg/s, min/median/75th/95th/99th consumer latency: 790763/862125/873616/985959/1104824 ?s
id: test1, time: 6.000s, sent: 2701 msg/s, received: 2726 msg/s, min/median/75th/95th/99th consumer latency: 861396/882842/886523/889682/890953 ?s
id: test1, time: 7.000s, sent: 2705 msg/s, received: 1952 msg/s, min/median/75th/95th/99th consumer latency: 863089/1036109/1098237/1146341/1150664 ?s
id: test1, time: 8.000s, sent: 2611 msg/s, received: 2182 msg/s, min/median/75th/95th/99th consumer latency: 1141951/1269395/1328614/1348747/1355758 ?s
id: test1, time: 9.000s, sent: 2638 msg/s, received: 2385 msg/s, min/median/75th/95th/99th consumer latency: 1340439/1380159/1419780/1435735/1437660 ?s
id: test1, time: 10.000s, sent: 2230 msg/s, received: 2776 msg/s, min/median/75th/95th/99th consumer latency: 1389868/1405928/1421188/1434390/1436514 ?s
id: test1, time: 11.000s, sent: 2122 msg/s, received: 2791 msg/s, min/median/75th/95th/99th consumer latency: 1202545/1328510/1384015/1401008/1403171 ?s
test stopped (Producer thread interrupted)
id: test1, sending rate avg: 2319 msg/s
id: test1, receiving rate avg: 2093 msg/s

撒花,有不懂的留言哦

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值