80
votes

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.

  1. RabbitMQ: I used a "fanout" type exchange and a queue with default configuration. I used the RabbitMQ C client library.
  2. ZeroMQ: My publisher publises to tcp://localhost:port1 with ZMQ_PUSH socket, My broker listens on tcp://localhost:port1 and resends the message to tcp://localhost:port2 and my consumer listens on tcp://localhost:port2 using ZMQ_PULL socket. I am using a broker instead of peer to to peer communication in ZeroMQ to to make the performance comparison fair to other message queue implementation that uses brokers.
  3. Qpid C++ message broker: I used a "fanout" type exchange and a queue with default configuration. I used the Qpid C++ client library.

Following is the performance result:

  1. RabbitMQ: it takes about 1 second to receive 10,000 messages.
  2. ZeroMQ: It takes about 15 milli seconds to receive 10,000 messages.
  3. Qpid: It takes about 4 seconds to receive 10,000 messages.

Questions:

  1. Have anyone run similar performance comparison between the message queues? Then I like to compare my results with yours.
  2. Is there any way I could tune RabbitMQ or Qpid to make it performance better?

Note:

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.

7
I have run simple tests months ago, with similar results. And I noticed the system is quite idle when working with RabbitMQ or Qpid. I think something must be wrong.Gary Shi
"RabbitMQ: it takes about 12 seconds to receive 10,000 messages." -- In our own tests we regularly see 20-25,000/sec ingress per CPU. So, you are doing something wrong, or using a slow client. Have you tried emailing rabbitmq-discuss with questions?user1021067
Here's a good comparison, dated April 10, 2013: x-aeon.com/wp/2013/04/10/…Daniel F
An updated version of RabbitMQ, Kafka, HornetQ, ActiveMQ, SQS and Mongo performance comparison is now here: softwaremill.com/mqperfadamw
each message was how many bytes when you did this test?arsenal

7 Answers

107
votes

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 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.

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.

33
votes

Hmm, of course ZeroMQ will be faster, it is designed to be and does not have a lot of the broker based functionality that the other two provide. The ZeroMQ site has a wonderful comparison of broker vs brokerless messaging and drawbacks & advantages of both.

RabbitMQ Blog:

RabbitMQ and 0MQ are focusing on different aspects of messaging. 0MQ puts much more focus on how the messages are transferred over the wire. RabbitMQ, on the other hand, focuses on how messages are stored, filtered and monitored.

(I also like the above RabbitMQ post above as it also talks about using ZeroMQ with RabbitMQ)

So, what I'm trying to say is that you should decide on the tech that best fits your requirements. If the only requirement is speed, ZeroMQ. But if you need other aspects such as persistence of messages, filtering, monitoring, failover, etc well, then that's when u need to start considering RabbitMQ & Qpid.

5
votes

I am using a broker instead of peer to to peer communication in ZeroMQ to to make the performance comparison fair to other message queue implementation that uses brokers.

Not sure why you want to do that -- if the only thing you care about is performance, there is no need to make the playing field level. If you don't care about persistence, filtering, etc. then why pay the price?

I'm also very leery of running benchmarks on VM's -- there are a lot of extra layers that can affect the results in ways that are not obvious. (Unless you're planning to run the real system on VM's, of course, in which case that is a very valid method).

3
votes

I've tested c++/qpid

I sent 50000 messages per second between two diferent machines for a long time with no queuing.

I didn't use a fanout, just a simple exchange (non persistent messages)

Are you using persistent messages? Are you parsing the messages?

I suppose not, since 0MQ doesn't have message structs.

If the broker is mainly idle, you probably haven't configured the prefetch on sender and receptor. This is very important to send many messages.

1
votes

We have compared RabbitMQ with our SocketPro (http://www.udaparts.com/) persistent message queue at the site http://www.udaparts.com/document/articles/fastsocketpro.htm with all source codes. Here are results we obtained for RabbitMQ:

Same machine enqueue and dequeue:

"Hello world" --
Enqueue: 30000 messages per second;
Dequeue: 7000 messages per second.

Text with 1024 bytes --
Enqueue: 11000 messages per second;
Dequeue: 7000 messages per second.

Text with 10 * 1024 bytes --
Enqueue: 4000 messages per second;
Dequeue: 4000 messages per second.

Cross-machine enqueue and dequeue with network bandwidth 100 mbps:

"Hello world" --
Enqueue: 28000 messages per second;
Dequeue: 1900 messages per second.

Text with 1024 bytes --
Enqueue: 8000 messages per second;
Dequeue: 1000 messages per second.

Text with 10 * 1024 bytes --
Enqueue: 800 messages per second;
Dequeue: 700 messages per second.

0
votes

Try to configure prefetch on sender and receptor with a value like 100. Prefetching just sender is not enough

0
votes

We've developed an open source message bus built on top of ZeroMQ - we initially did this to replace Qpid. It's brokerless so it's not a totally fair comparison but it provides the same functionality as brokered solutions.

Our headline performance figure is 140K msgs per second between two machines but you can see more detail here: https://github.com/Abc-Arbitrage/Zebus/wiki/Performance