FlashMQ is a multi-threaded fast lightweight MQTT broker. It was created specifically as a response to the lack of suitable offerings when dealing with high message volume clients and high connection volume and rate.

It’s written in C++, using mostly POSIX (Linux) APIs, as an event-driven multi-core state machine. By avoiding 3rd party event loop or message processing libraries, the limits are defined only by the Linux kernel, essentially. This means it can scale linearly with the amount of cores in a system, and likewise incur load linear to the amount of clients/messages. Currently, it’s capable of reaching one million messages per second at 1.3 gbit/sec on a single four core server (and play full motion ASCII video at the same time 😉 ), and handle more than four million connections on one server.

It’s similar to Mosquitto as it being a small one file executable, and depending on certain requirements, it can therefore be an (almost) drop-in replacement for Mosquitto on Linux based systems. There are binaries for ARM and it’s equally light-weight for restricted environments like Raspberry Pies.

Design goals/aspects

  • Simple yet powerful (fast and scales well).
  • One thread per CPU/core, with clients living in one thread only.
  • Event and readiness-change driven.
  • Very few dependencies, for ease of deployment and code stability.
  • Stable code base. MQTT is simple enough that you don’t need esoteric features or libraries, so using C++ and few external dependencies, it should be able to compile 20 years from now, and work consistently across OS versions.

Current Features

  • MQTT 3.1, 3.1.1 and 5.0
  • IPv4 and IPv6 support for all supported protocols.
  • Retained messages
  • Wills
  • Native HTTP1 websocket support, without external libraries. HTTP2 will not be implemented. There’s no advantage and it’s overly complex. You can always proxy with Nginx if you really want it.
  • SSL/TLS.
  • TLS x509 client verification.
  • HAproxy.
  • QoS 0, 1 and 2.
  • Authentication with plugin or ‘mosquitto_password_file’.
  • Native C++ FlashMQ authentication plugin interface.
  • (Limited) Mosquitto auth plugin version 2 compatibility. This comes with a caveat though: it must be thread safe. Config options exist to perform some serialization, but it’s not a guarantee.
  • Intel SSE4.2 (SIMD) instructions for string/topic handling.
  • Persistent state (save sessions, subscriptions and retained messages).