I am using Mosquitto as a MQTT broker for my home automation infrastructure. I run Mosquitto inside a Docker container on Raspberry Pi. I have been recommending this approach in the past since I think it is a great idea. During some discussion some of you raised concerns whether Raspberry Pi is capable of reliably running Mosquitto or if Docker is going to eat up all the little resources the RPi has. I decided to run some tests and measurements to back my arguments pro RPi / Docker.

In the beginning I want to get some things out of the way. I am using Raspberry Pi to keep the costs at bay of running Mosquitto 24/7. Obviously one gets better performance from a 1.500 USD laptop than a 35 USD credit card sized computer. The following image shows the voltage and current measurements I took while pushing 1.000 messages per second on the RPi. RPi is running at about 1.98 Watt. This means I can run my home automation at a cost of about 5 USD per year.

0.39 A during benchmarking is great.

I used mqtt-malaria to run the MQTT benchmarking tests. Here the command for your reference to run a 1000 messages-per-second test.

$ malaria publish -t -n 3000 -P 10 -s 100 -T 100 -H <hostname>

The CPU measurements I have been taken clearly show that my infrastructure can process 1000 messages per second without breaking a sweat. With my installation I do not even intent to go anyway near this number. Of cause if my RPi can not handle the load any more I will go shopping for some bigger - probably a mini ITX.

The following table shows some measurements RPI vs. a quad core ultrabook. Please keep in mind that these measurements are not scientific and a bit unfair. The laptop runs much more stuff than the RPI and different network latencies have not been considered.

msg/s 10 100 1000
RPi CPU 2-3% 6-7% 23-24%
PC CPU 4% 5-6% 10-11%

Even if my measurements only provide a very approximate figure I think they clearly demonstrate that the RPi is capable of running Mosquitto in a Docker container at the scale of a home automation infrastructure just fine.

Best, Mark

Resources

  • http://mosquitto.org/
  • https://www.docker.com/
  • https://github.com/remakeelectric/mqtt-malaria

© 2016. All Rights Reserved.

Ghostium Theme

Proudly published using buccaneer static site generator