MQTT Brokers at Scale: Performance Tuning Mosquitto, HiveMQ, and EMQX
MQTT has become the de facto protocol for IoT messaging, offering lightweight publish/subscribe communication between devices. But as deployments grow—from a few hundred devices to millions of concurrent clients—scaling MQTT brokers becomes critical.
In this guide, we’ll compare Mosquitto, HiveMQ, and EMQX, and explore performance tuning techniques to achieve high throughput, low latency, and reliable messaging at scale.
Key MQTT Scaling Challenges
- High Connection Volume – handling millions of concurrent connections.
- Message Throughput – sustaining thousands of messages per second.
- QoS Overhead – ensuring QoS 1/2 delivery without bottlenecks.
- Persistence & Storage – efficiently managing retained messages and session data.
- Clustering & High Availability – distributing load across multiple brokers.
Comparing MQTT Brokers
| Feature | Mosquitto | HiveMQ | EMQX |
|---|---|---|---|
| License | Open Source (EPL) | Commercial + Free CE | Open Source + Enterprise |
| Clustering | No native clustering | Yes, built-in cluster support | Yes, scalable clustering |
| Scalability | Lightweight, best for small-medium workloads | Enterprise-grade, millions of connections | Horizontally scalable to millions |
| Plugins/Extensibility | Limited | Rich plugin system (security, extensions) | Plugins + rule engine |
| Best Use Case | Edge deployments, lightweight brokers | Enterprise IoT platforms | Large-scale IoT backends, cloud-native |
Performance Tuning Mosquitto
Mosquitto is lightweight and reliable, but requires careful tuning for high throughput:
- Network Settings:
- Increase file descriptors:
ulimit -n 65535 - Optimize TCP settings:
- Increase file descriptors:
net.core.somaxconn = 65535 net.ipv4.tcp_tw_reuse = 1
- Persistence: Disable unless needed (
persistence false) to reduce disk I/O. - Message Queues: Adjust
max_inflight_messagesandmax_queued_messages. - TLS Overhead: Use session resumption & hardware crypto accelerators for secure deployments.
🔗 Mosquitto Performance Tuning Guide
Performance Tuning HiveMQ
HiveMQ is designed for mission-critical IoT at scale:
- Cluster Scaling: Horizontal scaling with shared-nothing architecture.
- Persistence: Uses distributed storage for session data → tune persistence layers based on workload.
- Extensions: Offload authentication/authorization logic using HiveMQ’s Extension SDK.
- Monitoring: Use HiveMQ Control Center & Prometheus integration to detect bottlenecks early.
- Network Optimization: Tune JVM settings (
-Xms,-Xmx) to match broker workload.
🐦 Tweet insight:
“HiveMQ supports millions of concurrent MQTT connections with linear scalability in enterprise IoT deployments.” — @HiveMQ
Performance Tuning EMQX
EMQX is an open-source, cloud-native MQTT broker built for extreme scale:
- Clustering: Scales horizontally with Mnesia database for distributed routing.
- Load Balancing: Deploy behind NGINX, HAProxy, or Kubernetes ingress controllers.
- Performance Settings:
- Tune
max_packet_sizeto balance large messages. - Increase
max_connectionsinemqx.conf.
- Tune
- Persistence & Retained Messages: Use Redis or Cassandra for distributed storage.
- Monitoring: EMQX Dashboard + Prometheus/Grafana integration.
🐦 Tweet insight:
“EMQX has been benchmarked to 100M concurrent MQTT connections in distributed environments.” — @emqtt
📊 Benchmark Snapshot
| Broker | Connections Tested | Peak Throughput | Latency (QoS 0) |
|---|---|---|---|
| Mosquitto | ~200K | ~100K msgs/sec | ~5–10 ms |
| HiveMQ | ~5M+ | ~1M msgs/sec | < 5 ms |
| EMQX | ~100M (clustered) | ~2M msgs/sec | < 3 ms |
(Sources: HiveMQ benchmark reports, EMQX cluster testing, Mosquitto community results)
Scaling Strategies
- Use Clustering: HiveMQ and EMQX support it natively. For Mosquitto, scale with external load balancers.
- QoS Considerations: Use QoS 0 for telemetry; QoS 1/2 only where necessary.
- Monitoring & Metrics: Prometheus + Grafana dashboards for real-time broker health.
- Edge vs Cloud: Use Mosquitto at the edge (lightweight devices), and HiveMQ/EMQX in the backend for aggregation.
- Kubernetes Deployments: EMQX and HiveMQ provide Helm charts for auto-scaling.
Final Thoughts
- Mosquitto is perfect for edge deployments and lightweight use cases.
- HiveMQ shines in enterprise-scale IoT with strong reliability and clustering.
- EMQX dominates extreme-scale, cloud-native workloads with proven 100M+ connection benchmarks.
Choosing the right broker depends on your scale, deployment model, and budget. With the right performance tuning, all three can deliver stable and efficient MQTT messaging at scale.



