Mosquitto and NanoMQ are fast, lightweight open-source MQTT brokers written in C/C++, fully implementing MQTT version 3.1.1 and 5.0.
Although Mosquitto and NanoMQ are both lightweight and have a low CPU/memory footprint, they adopt very different architectural designs. Mosquitto is single-threaded, and NanoMQ is built on NNG's asynchronous I/O with a multi-threading model.
Both are suitable for industrial IoT and embedded devices with constrained resources. This blog post will compare the features, performance, tech details, and use cases of two brokers in 2023.
The Mosquitto project was initially developed by Roger Light in 2009 and later donated to the Eclipse Foundation, licensed under the Eclipse Public License (EPL/EDL license).
Mosquitto’s design is straightforward and clean. It runs as a single-threaded daemon process with epoll support. It receives incoming data from one socket and dispatches it to other sockets.
Although simple, this architectural design restricts Mosquitto from using multi-core CPUs to connect more concurrent MQTT clients. At the same time, latency will increase as throughput increases.
Pros:
- Easy to setup and use
- MQTT 5.0 protocol support
- Lightweight and fast
- Active community support
Cons:
- Limited scalability ( <100k )
- No clustering support
- Lacking enterprise features
- Limited cloud-native support
The NanoMQ project was initially developed by EMQ Technologies Inc. in 2020 to provide a lightweight and fast MQTT broker with multi-threading support for the IoT edge. The project is under the MIT license and will be donated to the LF Edge Foundation before Q3 in 2023.
Unlike Mosquitto's single-threaded design, NanoMQ built on NNG's asynchronous I/O with a built-in Actor multi-threading model. Thanks to the excellent NNG library, NanoMQ takes full advantage of multiple cores in modern SMP systems.
NanoMQ is also an edge messaging bus that converts protocols such as DDS, NNG, and ZeroMQ to MQTT, then bridges the MQTT messages between brokers or from the edge to multiple clouds via MQTT and QUIC.
In addition, NanoMQ is highly portable and can be deployed on any POSIX-compatible platform, and runs on different CPU architectures such as x86_64, ARM, MIPS, and RISC-V.
Mosquitto is one of the most popular MQTT brokers and is prevalent in deployment on embedded hardware with its lightweight design.
As a project launched in 2020, NanoMQ is in its early stages but is actively developing and evolving, with over 1000 commits in the last 12 months.
Both open-source projects are hosted on GitHub. The following community metrics are available:
Mosquitto | NanoMQ | |
---|---|---|
GitHub Project | Mosquitto GitHub | NanoMQ GitHub |
Project Created | 2009 | 2020 |
License | EPL/EDL License | MIT License |
Programming Language | C/C++ | C |
Latest Release | 2.0.15 (Aug 2022) | v0.17.0 (March 2023) |
GitHub Stars | 7.1 k | 800+ |
GitHub Commits | 2.8k+ | 1.9k+ |
GitHub Commits (Last 12 Months) | 500+ | 1200+ |
GitHub Releases | 60+ | 75+ |
GitHub PRs | 600 | 780+ |
GitHub Contributors | 100+ | 20+ |
Mosquitto and NanoMQ fully implement MQTT 3.1/3.1.1/5.0 protocol versions, supporting the protocol specification for will messages, retained messages, shared subscriptions, and other capabilities.
Regarding the transports, both support MQTT over TCP, TLS/SSL, and WebSocket. NanoMQ as the broker designed in 2020, introduces MQTT over QUIC with multiplexing and faster connection establishment and migration support.
In addition, NanoMQ provides some features for management and integration, such as HTTP API, WebHook, On/Off-line Event Hook, and Rule Engine. NanoMQ’s portfolio is one of the broadest in edge computing. So you can get the exact features you need from a single broker and get more done with less time for your newly developed edge application.
Mosquitto | NanoMQ | |
---|---|---|
MQTT 3.1.1 | ✅ | ✅ |
MQTT 5.0 | ✅ | ✅ |
MQTT over TLS/SSL | ✅ | ✅ |
MQTT over WebSocket | ✅ | ✅ |
MQTT over QUIC | ❌ | ✅ |
MQTT Bridging | ✅ | ✅ |
AWS Bridging | ❌ | ✅ |
DDS Proxy | ❌ | ✅ |
HTTP API | ❌ | ✅ |
WebHook | ❌ | ✅ |
Rule Engine | ❌ | ✅ |
On/Off-line Event Hook | ❌ | ✅ |
Message Persistence | ✅ In Files | ✅ In SQLite |
Authentication & ACL | ✅ | ✅ |
Configuration | Key-value Format | HOCON Format |
CLI | ✅ | ✅ |
Clustering | ❌ | ❌ |
Docker | ✅ | ✅ |
Cross Platform | ✅ | ✅ |
SMP Support | ❌ | ✅ |
NanoMQ, a modern designed MQTT broker for edge computing, continuously evolves to meet new performance and scalability requirements, space constraints, concurrency, and latency. With an advanced built-in Actor threading model, NanoMQ is highly versatile, can scale from single to dozens of cores, and supports superior throughput with low latency. Therefore, Users are granted maximum choices: any performance, any CPU cores, and any feature set, easy to scale and migrate when your requirements grow or change. Whether you are designing a smart home gateway or industrial robotics or drones, or even sophisticated intelligence vehicles, NanoMQ can always fit in.
Mosquitto, on the other hand, targets traditional embedded scenarios, which means it is more resource-friendly and consumes less memory and CPU. Therefore, Mosquitto is ideal for IoT sensors and devices with low processing power, while NanoMQ is suitable for high-performance gateways and servers. Additionally, Mosquitto, as an open-source project with a long legacy, assures stability; it is the best fit when users only have limited performance and feature requests and a swift project development cycle.
See: Mosquitto vs NanoMQ Performance Benchmark Report.
Mosquitto | NanoMQ | |
---|---|---|
Scalability | 160k | 160k MQTT connections per node |
Performance | Up to 120k QoS0 MQTT msgs/sec per node 80k QoS1 msgs/sec 40k QoS2 msgs/sec |
Up to 1 million+ QoS0 MQTT msgs/sec per node 800k QoS1 msgs/sec 400k QoS2 msgs/sec |
Latency | Up to seconds latency in some scenarios | Less than 10 milliseconds in most scenarios |
Mosquitto and NanoMQ have small install packages and are easy to set up. But both lack advanced management and monitoring features such as Dashboard.
Mosquitto uses a configuration file in a key-value format, making it configure intuitively. It also comes with comprehensive documentation and an active user community.
In contrast, NanoMQ may pose a challenge for beginners due to its more advanced configuration requirements. But for experienced users, it offers more control and customization options.
Mosquitto | NanoMQ | Notes and Links | |
---|---|---|---|
Configuration | Key-Value Format | HOCON Format | |
HTTP API | ❌ | ✅ | REST API |
CLI | ✅ | ✅ | Command Line Interface |
Dashboard | ❌ | ❌ | |
Grafana | ❌ | ❌ | |
Prometheus | ❌ | ❌ | |
Docker | ✅ | ✅ | NanoMQ Docker |
Cross Platform | ✅ | ✅ |
EMQX Cloud is a highly scalable MQTT messaging service built on the open-source distributed EMQX broker. We can easily bridge Mosquitto or NanoMQ at the IoT edge to the EMQX Cloud service.
Mosquitto version 2.0 introduced epoll support to address the c10k connection scalability issue.
NanoMQ is pioneering MQTT over QUIC, the most innovative advancement in the MQTT protocol since the first release of the MQTT 5.0 specification in 2017. With multiplexing and faster connection establishment and migration, MQTT over QUIC has the potential to become the next generation of the MQTT standard. NanoMQ commits minor innovations like QoS prioritization and stream-topic pairing based on QUIC to fasten the pace of QUIC adoption.
In conclusion, Mosquitto and NanoMQ are excellent lightweight MQTT brokers for messaging at the IoT edge. You can choose any for your deployments on low-power sensors, embedded hardware, and industrial IoT in 2023.
- Eclipse Mosquitto
- Mosquitto Documentation
- NanoMQ: An Ultra-lightweight MQTT Broker for IoT Edge
- NanoMQ Documentation
- NanoMQ GitHub
- Mosquitto GitHub
- Mosquitto vs EMQX | 2023 MQTT Broker Comparison