当前位置:   article > 正文

RabbitMQ(五):RabbitMQ性能测试

rabbitmq性能测试

背景:最近需要了解RabbitMQ相关知识并对其做个简单的性能测试。RabbitMQ Performance Testing Tools(PerfTest)是一款开源的性能测试工具。

工具:rabbitmq_server-3.7.15 + centos7 + rabbitmq-perf-test-2.12.0 + Window10

1. rabbitmq-perf-test工具下载安装

RabbitMQ有一个测试吞吐量的性能测试工具PerfTest。它是基于Java开发的客户端。可以配置为模拟基本和高级两种负载。源码下载地址:https://bintray.com/rabbitmq/java-tools/perf-test/2.12.0

使用

下载后的源码目录如下:

将html目录中的数据拷贝到bin目录下:

将examples目录中的文件也拷贝到bin目录:

 

2. rabbitmq-perf-test工具使用

切换到bin目录下 runjava com.rabbitmq.perf.PerfTest --help

  1. Parsing failed. Reason: Unrecognized option: --helprunjava
  2. usage: <program>
  3. -?,--help show usage
  4. -a,--autoack auto ack
  5. -A,--multi-ack-every <arg> multi ack every
  6. -ad,--auto-delete <arg> should the queue be
  7. auto-deleted, default is
  8. true
  9. -b,--heartbeat <arg> heartbeat interval
  10. -B,--body <arg> comma-separated list of
  11. files to use in message
  12. bodies
  13. -bc,--body-count <arg> number of pre-generated
  14. message bodies. Use with
  15. --json-body. Default is
  16. 100.
  17. -bfc,--body-field-count <arg> number of pre-generated
  18. fields and values for
  19. body. Use with
  20. --json-body. Default is
  21. 1000.
  22. -c,--confirm <arg> max unconfirmed publishes
  23. -C,--pmessages <arg> producer message count
  24. -ca,--consumer-args <arg> consumer arguments as
  25. key/values pairs,
  26. separated by commas, e.g.
  27. x-priority=10
  28. -cri,--connection-recovery-interval <arg> connection recovery
  29. interval in seconds.
  30. Default is 5 seconds.
  31. Interval syntax, e.g.
  32. 30-60, is supported to
  33. specify an random
  34. interval between 2 values
  35. between each attempt.
  36. -ct,--confirm-timeout <arg> waiting timeout for
  37. unconfirmed publishes
  38. before failing (in
  39. seconds)
  40. -ctp,--consumers-thread-pools <arg> number of thread pools to
  41. use for all consumers,
  42. default is to use a
  43. thread pool for each
  44. consumer
  45. -d,--id <arg> test ID
  46. -D,--cmessages <arg> consumer message count
  47. -dcr,--disable-connection-recovery disable automatic
  48. connection recovery
  49. -e,--exchange <arg> exchange name
  50. -E,--exclusive use server-named
  51. exclusive queues. Such
  52. queues can only be used
  53. by their declaring
  54. connection!
  55. -env,--environment-variables show usage with
  56. environment variables
  57. -f,--flag <arg> message flag(s),
  58. supported values:
  59. persistent and mandatory.
  60. Use the option several
  61. times to specify several
  62. values.
  63. -h,--uri <arg> connection URI
  64. -H,--uris <arg> connection URIs
  65. (separated by commas)
  66. -hst,--heartbeat-sender-threads <arg> number of threads for
  67. producers and consumers
  68. heartbeat senders
  69. -i,--interval <arg> sampling interval in
  70. seconds
  71. -jb,--json-body generate a random JSON
  72. document for message
  73. body. Use with --size.
  74. -k,--routing-key <arg> routing key
  75. -K,--random-routing-key use random routing key
  76. per message
  77. -l,--legacy-metrics display legacy metrics
  78. (min/avg/max latency)
  79. -L,--consumer-latency <arg> consumer latency in
  80. microseconds
  81. -m,--ptxsize <arg> producer tx size
  82. -M,--framemax <arg> frame max
  83. -mc,--metrics-client enable client metrics
  84. -mcl,--metrics-class-loader enable JVM class loader
  85. metrics
  86. -mda,--metrics-datadog enable Datadog metrics
  87. -mdak,--metrics-datadog-application-key <arg> Datadog application key
  88. -mdd,--metrics-datadog-descriptions if meter descriptions
  89. should be sent to Datadog
  90. -mdh,--metrics-datadog-host-tag <arg> tag that will be mapped
  91. to "host" when shipping
  92. metrics to datadog
  93. -mdk,--metrics-datadog-api-key <arg> Datadog API key
  94. -mds,--metrics-datadog-step-size <arg> step size (reporting
  95. frequency) to use in
  96. seconds, default is 10
  97. seconds
  98. -mdu,--metrics-datadog-uri <arg> URI to ship metrics,
  99. useful when using a
  100. proxy, default is
  101. https://app.datadoghq.com
  102. -mh,--metrics-help show metrics usage
  103. -mjgc,--metrics-jvm-gc enable JVM GC metrics
  104. -mjm,--metrics-jvm-memory enable JVM memory metrics
  105. -mjp,--metrics-processor enable processor metrics
  106. (gathered by JVM)
  107. -mjt,--metrics-jvm-thread enable JVM thread metrics
  108. -mjx,--metrics-jmx enable JMX metrics
  109. -mp,--message-properties <arg> message properties as
  110. key/value pairs,
  111. separated by commas, e.g.
  112. priority=5
  113. -mpe,--metrics-prometheus-endpoint <arg> the HTTP metrics
  114. endpoint, default is
  115. /metrics
  116. -mpp,--metrics-prometheus-port <arg> the port to launch the
  117. HTTP metrics endpoint on,
  118. default is 8080
  119. -mpr,--metrics-prometheus enable Prometheus metrics
  120. -mpx,--metrics-prefix <arg> prefix for PerfTest
  121. metrics, default is
  122. perftest_
  123. -ms,--use-millis should latency be
  124. collected in
  125. milliseconds, default is
  126. false. Set to true if
  127. producers are consumers
  128. run on different
  129. machines.
  130. -mt,--metrics-tags <arg> metrics tags as key-value
  131. pairs separated by commas
  132. -n,--ctxsize <arg> consumer tx size
  133. -na,--nack nack and requeue messages
  134. -niot,--nio-threads <arg> number of NIO threads to
  135. use
  136. -niotp,--nio-thread-pool <arg> size of NIO thread pool,
  137. should be slightly higher
  138. than number of NIO
  139. threads
  140. -o,--output-file <arg> output file for timing
  141. results
  142. -p,--predeclared allow use of predeclared
  143. objects
  144. -P,--publishing-interval <arg> publishing interval in
  145. seconds (opposite of
  146. producer rate limit)
  147. -pi,--polling-interval <arg> time to wait before
  148. polling with basic.get,
  149. in millisecond, default
  150. is 0.
  151. -po,--polling use basic.get to consume
  152. messages. Do not use this
  153. in real applications.
  154. -prsd,--producer-random-start-delay <arg> max random delay in
  155. seconds to start
  156. producers
  157. -pst,--producer-scheduler-threads <arg> number of threads to use
  158. when using
  159. --publishing-interval
  160. -q,--qos <arg> consumer prefetch count
  161. -Q,--global-qos <arg> channel prefetch count
  162. -qa,--queue-args <arg> queue arguments as
  163. key/value pairs,
  164. separated by commas, e.g.
  165. x-max-length=10
  166. -qp,--queue-pattern <arg> queue name pattern for
  167. creating queues in
  168. sequence
  169. -qpf,--queue-pattern-from <arg> queue name pattern range
  170. start (inclusive)
  171. -qpt,--queue-pattern-to <arg> queue name pattern range
  172. end (inclusive)
  173. -r,--rate <arg> producer rate limit
  174. -R,--consumer-rate <arg> consumer rate limit
  175. -rkcs,--routing-key-cache-size <arg> size of the random
  176. routing keys cache. See
  177. --random-routing-key.
  178. -S,--slow-start start consumers slowly (1
  179. sec delay between each)
  180. -s,--size <arg> message size in bytes
  181. -sb,--skip-binding-queues don't bind queues to the
  182. exchange
  183. -se,--sasl-external use SASL EXTERNAL
  184. authentication, default
  185. is false. Set to true if
  186. using client certificate
  187. authentication with the
  188. rabbitmq_auth_mechanism_s
  189. sl plugin.
  190. -sst,--servers-startup-timeout <arg> start timeout in seconds
  191. (in case the servers(s)
  192. is (are) not available
  193. when the run starts).
  194. Default is to fail
  195. immediately if the
  196. servers(s) is (are) not
  197. available.
  198. -st,--shutdown-timeout <arg> shutdown timeout, default
  199. is 5 seconds
  200. -sul,--servers-up-limit <arg> number of available
  201. servers needed before
  202. starting the run. Used in
  203. conjunction with
  204. --servers-start-timeout.
  205. Default is deduced from
  206. --uri or --uris.
  207. -t,--type <arg> exchange type
  208. -T,--body-content-type <arg> body content-type
  209. -u,--queue <arg> queue name
  210. -udsc,--use-default-ssl-context use JVM default SSL
  211. context
  212. -v,--version print version information
  213. -vl,--variable-latency <arg> variable consumer
  214. processing latency with
  215. [MICROSECONDS]:[DURATION]
  216. syntax, where
  217. [MICROSECONDS] integer >=
  218. 0 and [DURATION] integer
  219. > 0. Use the option
  220. several times to specify
  221. several values.
  222. -vr,--variable-rate <arg> variable publishing rate
  223. with [RATE]:[DURATION]
  224. syntax, where [RATE]
  225. integer >= 0 and
  226. [DURATION] integer > 0.
  227. Use the option several
  228. times to specify several
  229. values.
  230. -vs,--variable-size <arg> variable message size
  231. with [SIZE]:[DURATION]
  232. syntax, where [SIZE]
  233. integer > 0 and
  234. [DURATION] integer > 0.
  235. Use the option several
  236. times to specify several
  237. values.
  238. -x,--producers <arg> producer count
  239. -X,--producer-channel-count <arg> channels per producer
  240. -y,--consumers <arg> consumer count
  241. -Y,--consumer-channel-count <arg> channels per consumer
  242. -z,--time <arg> run duration in seconds
  243. (unlimited by default)

具体使用(切换到bin目录下使用):

(1)一个生产者,一个消费者

runjava com.rabbitmq.perf.PerfTest -x 1 -y 1 -h "amqp://用户名:密码@ip:端口" -u "perf-test1" -a --id "test1"

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

解释:

-x:生产者计数

-y:消费者计数

-h:mq服务地址

-u:队列名

-a:自动ack回复

--id:测试id

测试结果:平均每秒发送6619条消息,平均接收2302条消息

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

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

测试结果:平均每秒发送1098条消息,平均接收102条消息

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/393650
推荐阅读
相关标签
  

闽ICP备14008679号