EMQX vs Mosquitto | 2023 MQTT Broker Comparison
Introduction
MQTT (Message Queuing Telemetry Transport) is a de facto standard messaging protocol for the Internet of Things (IoT). With the growth of the Internet of Things (IoT), MQTT brokers are becoming vital in connecting IoT devices and moving data between connected devices and cloud services.
EMQX and Mosquitto are two of the most popular open-source MQTT brokers. EMQX is a highly scalable, distributed MQTT broker with clustering support. Mosquitto is a lightweight MQTT broker with a small footprint and a single-threaded architecture.
This blog post will provide an in-depth comparison of the two brokers in 2023.
Mosquitto Overview
The Mosquitto project was initially developed by Roger Light in 2013 and later donated to the Eclipse Foundation, licensed under the Eclipse Public License (EPL/EDL license). As one of the world’s most widely used MQTT brokers, Mosquitto has over 7k GitHub Stars as of March 2023.
Mosquitto is written in C/C++ and uses a single-threaded architecture. Mosquitto implements MQTT protocol versions 5.0, 3.1.1, and 3.1 and supports SSL/TLS and WebSockets. Its lightweight design makes Mosquitto suitable for deployment on embedded devices or servers with limited resources.
Pros:
- Easy to setup and use
- MQTT 5.0 protocol support
- Lightweight and efficient
- Active community support
Cons:
- Limited scalability ( <100k )
- No clustering support
- Lacking enterprise features
- Limited Cloud-Native support
EMQX Overview
The EMQX project was launched on GitHub in 2012 and is licensed under Apache version 2.0. EMQX is now the world’s most scalable MQTT messaging server that supports advanced features such as MQTT 5.0, MQTT-SN, and MQTT over QUIC. It is widely used in business-critical applications in IoT, Industrial IoT (IIoT), and the Internet of Vehicles (IoV).
EMQX is written in Erlang/OTP, a programming language for building massively scalable soft real-time systems. Unlike Mosquitto, EMQX has adopted a masterless distributed architecture from its inception to achieve high availability and horizontal scalability. EMQX 5.0, the latest version, scales to establish 100 million concurrent MQTT connections with a single cluster of 23 nodes.
Further reading: Reaching 100M MQTT connections with EMQX 5.0
Pros:
- Supports large-scale deployments
- High availability
- Horizontal scalability
- High-performance and reliable
- Rich enterprise features
- Pioneering MQTT over QUIC
Cons:
- Complex to set up
- Difficult to manage effectively
Community and Popularity
EMQX is the highest-rated and most active MQTT Broker project on GitHub, with 11.4 stars and over 3,000 commits in the last 12 months.
Mosquitto is more prevalent in deployment than EMQX with its lightweight single-thread architecture, especially on embedded devices with limited resources.
Scalability and Performance
Mosquitto, as a lightweight MQTT broker, does not support clustering architecture but has excellent single-node performance. A server with a small resource footprint can support 100k concurrent MQTT connections.
EMQX, as a highly scalable distributed MQTT messaging broker, can support millions of concurrent connections on a single node and 100 million connections on a single cluster, but with much higher CPU and memory usage.
MQTT and Connectivity
Mosiquitto implements the MQTT protocol versions 3.1/3.1.1/5.0, supporting the protocol specification for will messages, retained messages, shared subscriptions, and other capabilities and supporting MQTT over WebSocket.
EMQX fully supports MQTT 3.1/3.1.1/5.0 and MQTT over Websocket protocols. EMQX 5.0 also introduces groundbreaking support for MQTT Over QUIC. With multiplexing and faster connection establishment and migration, it has the potential to become the next generation of the MQTT standard.
In addition, EMQX can be extended to support multiple protocol gateways, such as MQTT-SN, CoAP, LwM2M, and STOMP.
Security
Security is crucial for connecting IoT devices and data exchanged between connected devices and cloud services. Both Mosquitto and EMQX support secure connections based on TLS/SSL. In addition, EMQX supports QUIC transport, OCSP Stapling, Audit Logs, and source code scanning with Black Duck.
Authentication and Authorization
Regarding MQTT client authentication and access control, Mosiquitto provides a dynamic security plug-in that flexibly handles username/password authentication and access control.
EMQX has built-in support for multiple authentication mechanisms, such as username-password authentication, JWT authentication, and enhanced authentication based on the MQTT 5.0 protocol. Authentication in EMQX integrates with various data backends, including files, Redis, MySQL, PostgreSQL, MongoDB, etc.
In addition, EMQX provides flapping detect and blocklist features, enabling users to block specific clients by adding their IP address, clientId, or username to a blocklist via Dashboard and HTTP API.
Data Integration
As a lightweight broker, Mosquitto does not support data integration. Users can write code to consume MQTT messages from Mosquitto and ingest them into external databases or cloud services.
EMQX has a built-in SQL-based rule engine to help extract, filter, enrich, and transform MQTT messages in real-time within the broker.
The Enterprise Edition of EMQX can seamlessly integrate with Kafka, databases, and cloud services using the rule engine and out-of-the-box data bridges.
Operability and Observability
Mosquitto offers fundamental logging and debugging capabilities for monitoring broker status and troubleshooting issues. However, it lacks advanced management and monitoring features, making it difficult to gain insight into the running status and optimize the performance.
EMQX provides rich and visual monitoring capabilities through HTTP API and Dashboard, making it easier to monitor and manage. In addition, EMQX supports integration with Prometheus, StatsD, and Datadog, enabling O&M teams to use third-party monitoring platforms easily.
Cloud-Native and Kubernetes
EMQX and Mosquitto both support docker-based containerized deployments. EMQX has excellent Kubernetes Operator and Terraform support, making it easier to deploy and operate on public cloud platforms.
In addition, EMQX offers serverless, dedicated, and BYOC MQTT messaging services on over 17 Regions from AWS, Google Cloud, and Microsoft Azure worldwide.
EMQX Kubernetes Operator: https://github.com/emqx/emqx-operator
Bridging Mosquitto to EMQX
Although EMQX and Mosquitto are two very different MQTT brokers, they can work perfectly with the MQTT bridging approach.
We can deploy Mosquitto on embedded hardware or gateways at the IoT edge, and then aggregate and ingest IoT data into a large-scale EMQX cluster in the cloud via an MQTT bridge.
Further reading: Bridging Mosquitto MQTT Messages to EMQX
Conclusion
The comparison above shows that EMQX and Mosquitto are popular MQTT brokers catering to different needs and use cases.
Mosquitto, as a single-threaded lightweight MQTT Broker, is more suitable for deployment on embedded hardware, industrial gateways, and small servers for IoT edge.
EMQX is a highly scalable, distributed MQTT server supporting high availability and horizontal scalability. It is more suitable for cloud deployment, large-scale IoT, IIoT, and connected car applications.
In short, you can choose Mosquitto for embedded hardware and IoT edge deployments and use EMQX as a massively scalable, highly available MQTT messaging service in the cloud.
References
Originally published at https://www.emqx.com.