ZeroMQ、RabbitMQ 和 Apache Qpid 之间的性能比较 [英] Performance comparison between ZeroMQ, RabbitMQ and Apache Qpid
问题描述
我的应用程序需要高性能消息总线,因此我正在评估 ZeroMQ
、RabbitMQ
和 Apache Qpid
的性能.为了测量性能,我正在运行一个测试程序,该程序使用其中一个消息队列实现发布 10,000 条消息,并在同一台机器上运行另一个进程来使用这 10,000 条消息.然后我记录发布的第一条消息和收到的最后一条消息之间的时间差.
I need a high performance message bus for my application so I am evaluating performance of ZeroMQ
, RabbitMQ
and Apache Qpid
. To measure the performance, I am running a test program that publishes say 10,000 messages using one of the message queue implementations and running another process in the same machine to consume these 10,000 messages. Then I record time difference between the first message published and the last message received.
以下是我用于比较的设置.
Following are the settings I used for the comparison.
RabbitMQ
:我使用了扇出"类型的交换和默认配置的队列.我使用了 RabbitMQ C 客户端库.ZeroMQ
:我的发布者使用ZMQ_PUSH
套接字发布到tcp://localhost:port1
,我的代理监听tcp://localhost:port1
并将消息重新发送到 tcp://localhost:port2 并且我的消费者使用ZMQ_PULL
套接字监听tcp://localhost:port2
.我在ZeroMQ
中使用代理而不是点对点通信,以使性能比较与使用代理的其他消息队列实现公平.Qpid
C++ 消息代理:我使用了扇出"类型的交换和默认配置的队列.我使用了 Qpid C++ 客户端库.
RabbitMQ
: I used a "fanout" type exchange and a queue with default configuration. I used the RabbitMQ C client library.ZeroMQ
: My publisher publises totcp://localhost:port1
withZMQ_PUSH
socket, My broker listens ontcp://localhost:port1
and resends the message to tcp://localhost:port2 and my consumer listens ontcp://localhost:port2
usingZMQ_PULL
socket. I am using a broker instead of peer to to peer communication inZeroMQ
to to make the performance comparison fair to other message queue implementation that uses brokers.Qpid
C++ message broker: I used a "fanout" type exchange and a queue with default configuration. I used the Qpid C++ client library.
以下是性能结果:
RabbitMQ
:接收10000条消息大约需要1秒.ZeroMQ
:接收10000条消息大约需要15毫秒.Qpid
:接收10000条消息大约需要4秒.
RabbitMQ
: it takes about 1 second to receive 10,000 messages.ZeroMQ
: It takes about 15 milli seconds to receive 10,000 messages.Qpid
: It takes about 4 seconds to receive 10,000 messages.
问题:
- 有没有人在消息队列之间进行过类似的性能比较?然后我想将我的结果与你的结果进行比较.
- 有什么方法可以调整
RabbitMQ
或Qpid
以使其性能更好?
- Have anyone run similar performance comparison between the message queues? Then I like to compare my results with yours.
- Is there any way I could tune
RabbitMQ
orQpid
to make it performance better?
注意:
测试是在分配了两个处理器的虚拟机上完成的.结果可能因硬件不同而有所不同,但我主要对 MQ 产品的相对性能感兴趣.
The tests were done on a virtual machine with two allocated processor. The result may vary for different hardware, however I am mainly interested in relative performance of the MQ products.
推荐答案
RabbitMQ 可能正在对这些消息进行持久化.我认为您需要在消息中设置消息优先级或其他选项以不进行持久性.届时性能将提高 10 倍.您应该期望通过 AMQP 代理每秒至少有 100K 消息.在 OpenAMQ 中,我们获得了高达 300K 消息/秒的性能.
RabbitMQ is probably doing persistence on those messages. I think you need to set the message priority or another option in messages to not do persistence. Performance will improve 10x then. You should expect at least 100K messages/second through an AMQP broker. In OpenAMQ we got performance up to 300K messages/second.
AMQP 是为提高速度而设计的(例如,它不会为了路由消息而解包消息),但 ZeroMQ 只是在关键方面设计得更好.例如.它通过在没有代理的情况下连接节点来移除一个跃点;与任何 AMQP 客户端堆栈相比,它的异步 I/O 性能更好;它进行更积极的消息批处理.构建 ZeroMQ 所花费的时间可能有 60% 用于性能调优.这是非常艰苦的工作.它不是偶然更快.
AMQP was designed for speed (e.g. it does not unpack messages in order to route them) but ZeroMQ is simply better designed in key ways. E.g. it removes a hop by connecting nodes without a broker; it does better asynchronous I/O than any of the AMQP client stacks; it does more aggressive message batching. Perhaps 60% of the time spent building ZeroMQ went into performance tuning. It was very hard work. It's not faster by accident.
我想做但太忙的一件事是在 ZeroMQ 之上重新创建一个类似 AMQP 的代理.这里有第一层:http://rfc.zeromq.org/spec:15.整个堆栈的工作方式有点像 RestMS,传输和语义分为两层.它将提供与 AMQP/0.9.1 大致相同的功能(并且在语义上可互操作),但速度要快得多.
One thing I'd like to do, but am too busy, is to recreate an AMQP-like broker on top of ZeroMQ. There is a first layer here: http://rfc.zeromq.org/spec:15. The whole stack would work somewhat like RestMS, with transport and semantics separated into two layers. It would provide much the same functionality as AMQP/0.9.1 (and be semantically interoperable) but significantly faster.
这篇关于ZeroMQ、RabbitMQ 和 Apache Qpid 之间的性能比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!