rabbitmq性能测试工具rabbitmq-perf-test(官网阅读笔记)

Java Tools

翻译:limuitech

时间:201811月

官网连接:http://www.rabbitmq.com/java-tools.html

以下内容为官网资料,非全部翻译,只是自己在阅读的时候,随手在关键部分加了自己的翻译。

翻译英文技术文档的难点除了语言之外,更重要的是对语言内容的理解,否则翻译出来也会觉得别扭。翻译能力有限,如果有问题,请大家指正;

 

This page documents some Java-based utility programs (PerfTest, Tracer).

PerfTest

RabbitMQ has a basic throughput testing tool, PerfTest (docs, source code and releases), that is based on the Java client and can be configured to simulate basic workloads. PerfTest has extra tools that produce HTML graphs of the output. A RabbitMQ cluster can be limited by a number of factors, from infrastructure-level constraints (e.g. network bandwidth) to RabbitMQ configuration and topology to applications that publish and consume. PerfTest can demonstrate baseline performance of a node or a cluster of nodes.PerfTest能够演示对一个rabbitmq节点或集群节点的基准性能测试;

 

Installation

PerfTest is distributed as a binary build archive from Bintray and GitHub releases as well. It is also available on Maven Central if one needs to use it as library. Note the documentation below can cover features available only in milestone releases or release candidates, available in our Java Tools milestones repository and in GitHub releases as well.

The distribution contains a script (bin/runjava or bin/runjava.bat) to run Java with the class path correctly configured, e.g. bin/runjava com.rabbitmq.perf.PerfTest runs the PerfTest Java class.

To verify a PerfTest installation, use

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

 

下载2.0.0版本:

RabbitMQ Performance Testing Tool 介绍:

https://www.rabbitmq.com/java-tools.html

RabbitMQ Performance Testing Tool 下载:

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

https://bintray.com/rabbitmq/java-tools/perf-test

cd /opt/software

wget https://github.com/rabbitmq/rabbitmq-perf-test/releases/download/v2.0.0/rabbitmq-perf-test-2.0.0-bin.tar.gz

tar -xvz -f ./rabbitmq-perf-test-2.0.0-bin.tar.gz

cd ./rabbitmq-perf-test-2.0.0

 

Using PerfTest

The most basic way of running PerfTest only specifies a URI to connect to, a number of publishers to use (say, 1) and a number of consumers to use (say, 2). Note that RabbitMQ Java client can achieve high rates for publishing (up to 80 to 90K messages per second per connection), given enough bandwidth and when some safety measures (publisher confirms) are disabled, so overprovisioning publishers is rarely necessary (unless that's a specific objective of the test).

执行PerfTest最基本的方法是指定要使用的URL(ampq(s)://username:password@host:port/vhostname)、生产者数量(比如说1)和消费者数量(比如2)。注意,rabbitmq java客户端能够达到较高的发布速度(每个connection每秒发布可以达到80000到90000个消息),这是在带宽充足,并且关闭了一些安全措施(生产者确认),因此,没必要提供过量的生产者(除非那是一个确定的测试目标)。

The following command runs PerfTest with a single publisher without publisher confirms, two consumers (each receiving a copy of every message) that use automatic acknowledgement mode and a single queue named “throughput-test-x1-y2”. Publishers will publish as quickly as possible, without any rate limiting. Results will be prefixed with “test 1” for easier identification and comparison:

下面的命令在关闭了生产者确认机制的情况下,执行性能测试(PerfTest),这个测试中有1个生产者、2个消费者(每个消费者接收每条消息的一个副本)和一个名为“throughput-test-x1-y2”的队列,其中,消费者开启了自动的确认机制(acknowledgement mode)模式。生产者将会尽快发布消息,没有任何速度限制。结果以“test 1”位前缀用来更容易验证和对比:

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

选项说明:

-x,--producers <arg> producer count(生产者数量)

-y,--consumers <arg> consumer count(消费者数量)

-u,--queue <arg> queue name(队列名称)

-a,--autoack auto ack,客户端在处理完messages之后会给服务端返回一个ack确认信息,服务端在收到该ack信息之后才会把messages删除;

-d,--id <arg> test ID(本次测试的编号,身份标识)

This modification will use 2 publishers and 4 consumers, typically yielding higher throughput given enough CPU cores on the machine and RabbitMQ nodes:下面修改为2个生产者和4个消费者,如果机器上的CPU核数和RabbitMQ节点数量充足的话,明显会产生更高的吞吐量。

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

This modification switches consumers to manual acknowledgements:这里把消费者切换为手动确认(译者注:去掉了-a选项)。

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

译者注:

为了保证数据不被丢失,RabbitMQ支持消息确认机制,即ack。为了保证数据能被正确处理而不仅仅是被Consumer收到,我们就不能采用no-ack或者auto-ack,我们需要手动ack(manual-ack)。在数据处理完成后手动发送ack,这个时候Server才将Message删除。()

This modification changes message size from default (12 bytes) to 4 kB:这里把消息的大小改为了4kb(默认值为12字节):

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

选项说明:

-s,--size <arg> message size in bytes(消息大小,单位是字节)

PerfTest can use durable queues and persistent messages:PerfTest可以使用持久化的队列和持久化的消息(注意:queue和message是两个不同的概念):

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

选项说明:

-f,--flag <arg> message flag(s) separated by commas. Supported values: persistent and mandatory(消息标志,多个可以用逗号隔开,支持的值:persistent 和 mandatory)

译者注:

消息持久化和队列持久化是两个操作,队列持久化了,不代表消息也会持久化,二者的持久化需要在代码中各自独立的配置。(我有个疑问:publisher和consumer的持久化配置与否,跟rabbitmq集群中的disk节点有什么关系?与设置镜像队列策略有什么关系?在使用2个ram节点+1个disk节点的rabbitmq集群的时候,如果用户的应用没有设置队列和消息的持久化,那么这些消息和队列是否会写入磁盘?从网上找到的资料:RabbitMQ对于queue中的message的保存方式有两种方式:disc和ram。如果采用disc,则需要对exchange/queue/delivery mode都要设置成durable模式。也就是说,rabbitmq服务器设置了磁盘节点,还要配合publisher应用和consumer应用对相关元素的持久化设置才能实现真正的持久化。那默认值是什么?)

 

如过将queue的持久化标识durable设置为true,则代表是一个持久的队列,那么在服务重启之后,也会存在,因为服务会把持久化的queue存放在硬盘上,当服务重启的时候,会重新什么之前被持久化的queue。队列(queues)是可以被持久化,但是里面的消息(messages)是否为持久化那还要看消息的持久化设置。也就是说,重启之前那个queue里面存在还没有发出去的消息的话,重启之后那队列里面是不是还存在原来

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值