RabbitMQ吞吐量测试-PerfTest上
PerfTest
RabbitMQ有一个基本的吞吐量测试工具PerfTest(文档,源代码和版本),它基于Java客户端,可以配置为模拟基本工作负载。PerfTest有额外的工具可以生成输出的HTML图形。RabbitMQ集群可能受到很多因素的限制,从基础设施级限制(如网络带宽)到RabbitMQ配置和拓扑到发布和使用的应用程序。PerfTest可以演示节点或节点集群的基准性能。
安装
PerfTest也是从Bintray和 GitHub发布的二进制版本库中分发的 。 如果需要将它作为库,也可以在Maven Central上使用。
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%22
要验证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个消费者:
bin/runjava com.rabbitmq.perf.PerfTest -x 2 -y 4 -u "throughput-test-2" -a --id "test 2"
此修改将消费者切换到手动确认:
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" -
作者:全能程序猿
链接:https://www.jianshu.com/p/0f269041d2a8
共同学习,写下你的评论
评论加载中...
作者其他优质文章