RabbitMQ吞吐量測試-PerfTest上

RabbitMQ吞吐量測試-PerfTest上

PerfTest

RabbitMQ有一個基本的吞吐量測試工具PerfTest(文檔,源代碼和版本),它基於Java客戶端,能夠配置爲模擬基本工做負載。PerfTest有額外的工具能夠生成輸出的HTML圖形。RabbitMQ集羣可能受到不少因素的限制,從基礎設施級限制(如網絡帶寬)到RabbitMQ配置和拓撲到發佈和使用的應用程序。PerfTest能夠演示節點或節點集羣的基準性能。java

安裝

PerfTest也是從Bintray和 GitHub發佈的二進制版本庫中分發的 。 若是須要將它做爲庫,也能夠在Maven Central上使用。git

Bintray:https://bintray.com/rabbitmq/java-tools/perf-test
GitHub:https://github.com/rabbitmq/rabbitmq-perf-test/releases
Maven Central:http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.rabbitmq%22%20AND%20a%3A%22perf-test%22github

要驗證PerfTest安裝,請使用安全

bin/runjava com.rabbitmq.perf.PerfTest --help

can@can:/usr/local/mq/rabbitmq_server-3.6.14/rabbitmq-perf-test-2.0.0.RC4$ bin/runjava com.rabbitmq.perf.PerfTest --help
usage: <program>
 -?,--help                           show usage
 -A,--multi-ack-every <arg>          multi ack every
 -a,--autoack                        auto ack
 -ad,--auto-delete <arg>             should the queue be auto-deleted,
                                     default is true
 -B,--body <arg>                     comma-separated list of files to use
                                     in message bodies
 -b,--heartbeat <arg>                heartbeat interval
 -C,--pmessages <arg>                producer message count
 -c,--confirm <arg>                  max unconfirmed publishes
 -ct,--confirm-timeout <arg>         waiting timeout for unconfirmed
                                     publishes before failing (in seconds)
 -D,--cmessages <arg>                consumer message count
 -d,--id <arg>                       test ID
 -e,--exchange <arg>                 exchange name
 -f,--flag <arg>                     message flag
 -H,--uris <arg>                     connection URIs (separated by commas)
 -h,--uri <arg>                      connection URI
 -i,--interval <arg>                 sampling interval in seconds
 -K,--random-routing-key             use random routing key per message
 -k,--routing-key <arg>              routing key
 -L,--consumer-latency <arg>         consumer latency in microseconds
 -l,--legacy-metrics                 display legacy metrics (min/avg/max
                                     latency)
 -M,--framemax <arg>                 frame max
 -m,--ptxsize <arg>                  producer tx size
 -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 <arg>                  consumer tx size
 -o,--output-file <arg>              output file for timing results
 -p,--predeclared                    allow use of predeclared objects
 -Q,--global-qos <arg>               channel prefetch count
 -q,--qos <arg>                      consumer prefetch count
 -qa,--queue-args <arg>              queue arguments as key/pair values,
                                     separated by commas
 -R,--consumer-rate <arg>            consumer rate limit
 -r,--rate <arg>                     producer rate limit
 -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
 -T,--body-content-type <arg>        body content-type
 -t,--type <arg>                     exchange type
 -u,--queue <arg>                    queue name
 -udsc,--use-default-ssl-context     use JVM default SSL context
 -X,--producer-channel-count <arg>   channels per producer
 -x,--producers <arg>                producer count
 -Y,--consumer-channel-count <arg>   channels per consumer
 -y,--consumers <arg>                consumer count
 -z,--time <arg>                     run duration in seconds (unlimited by
                                     default)

使用PerfTest

運行PerfTest的最基本的方法只是指定要鏈接的URI,要使用的發佈者(好比說1)和一些消費者(好比2)。請注意,RabbitMQ Java客戶端能夠實現較高的發佈速率(每一個鏈接每秒高達80至90K條消息),給予足夠的帶寬,而且當某些安全措施(發行商確認)被禁用時,不多須要過分配置發佈者(除非這是特定的測試目標)。網絡

bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-1" -a --id "test 1"

QQ截圖20171211135939.png

使用2個發佈者和4個消費者:dom

bin/runjava com.rabbitmq.perf.PerfTest -x 2 -y 4 -u "throughput-test-2" -a --id "test 2"

此修改將消費者切換到手動確認:maven

bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-3" --id "test 3"

修改將消息大小從默認(12字節)更改成4 kB:工具

bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-4" --id "test 4" -s 4000

使用持久隊列和持久消息:性能

bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 2 -u "throughput-test-5" --id "test-5" -f persistent
相關文章
相關標籤/搜索