EMQX Dedicated New Feature: Event History is available for private beta test. →

Mosquitto vs EMQX | 2023 MQTT Broker Comparison

Fan Wang
Apr 10, 2023
Mosquitto vs EMQX | 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 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 2009 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.

Mosquitto

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.

See: Reaching 100M MQTT connections with EMQX 5.0

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 and configure
  • Difficult to manage effectively
  • Logs may be confusing

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.

EMQX Mosquitto
GitHub Project EMQX GitHub Mosquitto GitHub
Project Created 2012 2009
License Apache License 2.0 EPL/EDL License
Programming Language Erlang C
Latest Release v5.0.21 (March 2023) 2.0.15 (Aug 2022)
GitHub Stars 11.4k 7.2 k
GitHub Forks 2k 2.1k
GitHub Commits 14k+ 2.8k+
GitHub Commits (Last 12 Months) 3000+ 500+
GitHub Issues 3500+ 2200+
GitHub Releases 260+ 60+
GitHub PRs 6000+ 600
GitHub Contributors 100+ 110+
Community and Popularity (Mar 24, 2023)

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 over 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.

See: EMQX vs Mosquitto Performance Benchmark Report.

EMQX Mosquitto Notes & Links
Scalability - 4M MQTT connections per node
- 100M MQTT connections per cluster
<160K MQTT connections per node Reaching 100M MQTT connections with EMQX 5.0
Performance - 2 million QoS0 MQTT msgs/sec per node
- 800k QoS1 msgs/sec
- 200k QoS2 msgs/sec
- Up to 120k QoS0 MQTT msgs/sec per node
- 80k QoS1 msgs/sec
- 60k QoS2 msgs/sec
Latency Single-digit millisecond latency at scale Up to seconds latency in some scenarios
Clustering 20+ nodes of cluster Cluster Scalability
Elastic and Resilient scaling at runtime
Auto Clustering EMQX Node Discovery and Autocluster
Zero Downtime/Hot Upgrade Release Upgrade

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.

EMQX Mosquitto Notes and Links
MQTT 3.1/3.1.1 The Easy-to-understand Guide to MQTT Protocol
MQTT 5.0 MQTT 5 Explore
MQTT Shared Subscription
MQTT Add-ons - Exclusive subscription
- Delayed Publish
- Auto-subscription
- Topic rewrite
MQTT over TCP EMQX Getting Started
MQTT over TLS Enable SSL/TLS for EMQX MQTT broker
MQTT over WebSocket Connect to MQTT broker with Websocket
MQTT over QUIC EMQX is now the only MQTT broker in the world that supports QUIC transport. (MQTT over QUIC)
LB (Proxy Protocol) Proxy Protocol v1, v2 (Cluster load balancing)
IPv6 Support
Multi-protocol Gateway Extended protocol gateway
MQTT-SN MQTT-SN Gateway
CoAP CoAP Protocol Gateway
LwM2M LwM2M Protocol Gateway
STOMP Stomp Gateway

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.

EMQX Mosquitto Notes and Links
TLS/SSL EMQX: TLS 1.1, 1.2, 1.3 (Enable SSL/TLS for EMQX MQTT broker)
QUIC MQTT over QUIC: Next-Generation IoT Standard Protocol
OCSP Stapling EMQX Supports OCSP stapling
Audit Logs

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.

EMQX Mosquitto Notes & Links
Username/Password EMQX: AuthN Introduction
Mosquitto: Authentication methods
JWT EMQX:JWT Authenticaton
Mosquitto: Auth plugin for mosquitto
MQTT 5.0 Enhanced Authentication SCRAM Authentication
PSK SSL/TLS
X.509 Certificates
LDAP LDAP Authentication/ACL
Fine-grained Access Control EMQX Authorization
Authentication Backends Authentication Introduction
ACL Database Backends EMQX:Files, MySQL, PostgreSQL, MongoDB, Built-in Database, HTTP
EMQX Authorization Introduction
Flapping Detect
Block List

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.

EMQX Mosquitto Notes and Links
Webhook Webhook
Rule Engine Rule Engine
Message Codec
Data Bridge Data bridges
Confluent/Kafka ✅ (Enterprise Edition) Stream Data into Kafka
SAP Event Mesh ✅(Enterprise Edition) Ingest Data into SAP Event Mesh
Apache Pulsar ✅(Enterprise Edition) Ingest Data into Pulsar
RabbitMQ ✅(Enterprise Edition) Ingest Data into RabbitMQ
MySQL ✅(Enterprise Edition) Ingest Data into MySQL
PostgreSQL ✅(Enterprise Edition) Ingest Data into PostgreSQL
SQL Server ✅(Enterprise Edition) Ingest Data into SQL Server
MongoDB ✅(Enterprise Edition) Ingest Data into MongoDB
Redis ✅(Enterprise Edition) Ingest Data into Redis
Cassandra ✅(Enterprise Edition) Ingest Data into Cassandra
AWS DynamoDB ✅(Enterprise Edition) Ingest Data into DynamoDB
ClickHouse ✅(Enterprise Edition) Ingest Data into ClickHouse
InfluxDB ✅(Enterprise Edition) Ingest Data into InfluxDB
TimeScaleDB ✅(Enterprise Edition) Ingest Data into TimescaleDB
Oracle ✅(Enterprise Edition) Ingest Data into Oracle

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 and Datadog, enabling O&M teams to use third-party monitoring platforms easily.

EMQX Mosquitto Notes and Links
Dashboard EMQX Dashboard
Configuration HOCON Format Key-Value Fomat
HTTP API EMQX REST API
CLI Command Line Interface
Config Hot update Configuration Files
Metrics Node metrics:
Metrics
Mosquitto - $SYS topic
Grafana Integrate with Prometheus
Cluster Metrics Metrics
Alarm Alerts System Topic
Slow Subscription Monitoring Slow subscribers statistics
Prometheus Integrate with Prometheus

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 Mosquitto Notes and Links
Docker EMQX Docker
Kubernetes Operator EMQX Kubernetes Operator
Terraform EMQX Terraform
Cloud Service - Serverless
- Hosting/Dedicated
- BYOC
Hosting

EMQX Kubernetes Operator: https://github.com/emqx/emqx-operator

EMQX Kubernetes 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.

See Bridging Mosquitto MQTT Messages to EMQX

Bridging Mosquitto 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

Try EMQX Cloud for Free
No credit card required
Get Started →

Related Posts