5
votes

I have succesfully configured a RabbitMQ cluster that supports MQTT via the MQTT plugin. At the moment, the MQTT messages pass a topic exchange whose binded with a work queue. So all MQTT messages are stored in this work queue.

Now I'd like to test the Input performance of this cluster by studying the graphs in the RabbitMQ management plugin. My plan was to set up 2 NodeJS MQTT publishers firing off many MQTT messages within a for loop but this fails.

When the for loop runs over 3000 times, not all messages survive... (Find my test code below) I'd like to have your opinion on this:

  1. What could be the reason messages don't survive?
  2. What is the best way to evaluate RabbitMQ/MQTT's performance?
  3. Should I use multiple publishers?

Code:

var quantity = 3000;
var mqtt = require('mqtt');
var options = {
   host: 'localhost',
   port: 1883,
   protocolId: 'MQIsdp',
   rejectUnauthorized: false,
   protocolId: 'MQIsdp',
   protocolVersion: 3
};

var client  = mqtt.connect(options);

for(var x=0; x<quantity; x++)
{
  client.publish('/WSN/N536,563E/dynamic',"22");
  console.log(x);
}

client.end();
1
Can you try using a QoS of 1 or 2?Alessandro Da Rugna
To load test your MQTT broker, you can use some tool likes github.com/emqtt/emqtt_benchmark (need Erlang installed though). Or you can do the same thing like this github.com/mqttjs/mqtt-stack/blob/master/benchmark/send.jsBlue Smith
Your questions are not clear. What exactly does "don't survive" mean? Your subscriber is not seeing all of them? Google "MQTT QOS". Performance testing is complicated. This is all our company does for 20 years. For starters, you need to ask yourself EXACTLY what you are testing. The next question is "where is the bottleneck?". The last thing you want is your test rig to be the bottleneck. For a hint at the issues see these pages: gambitcomm.blogspot.com/2017/09/… and gambitcomm.blogspot.com/2016/10/…Gambit Support

1 Answers

0
votes

Message are being packed into stream socket and actual data bytes are somewhere on the path: [your code] => [client's memory buffer] => [send-system socket buffer] => [recv-system socket buffer] => [server's code].

If you are using localhost, the chance for socket buffer for 3K messages is minimal, but exists.

I'm not very familiar with mqqt nodeJS client, but if it is doing client.end() with socket shutdown operation it is possible that some mqtt frames simply do not reach your server.

You have some options for your test like:

  • sleep a bit before client.end(), just a little;
  • use QoS=1 messages, still you have a chance to loose some unacked bytes, depending on the configuration of size of mqtt window;
  • use smth more appropriate, you may google for "mqtt load generator" for samples