Webinar
Introducing EMQX 6.1: Durable MQTT Streams and Analytics-Ready Data | Register Now →

Open MQTT Benchmarking Comparison: MQTT Brokers in 2023

May JinMay Jin
May 5, 2023MQTT
Open MQTT Benchmarking Comparison: MQTT Brokers in 2023

The blog post Open MQTT Benchmark Suite: The Ultimate Guide to MQTT Performance Testing introduced the Open MQTT Benchmark Suite developed by EMQ. We defined MQTT benchmark scenarios, use cases, and observation metrics in the GitHub project. Based on the activity and popularity of the community and GitHub project, the top 4 open-source MQTT brokers in 2023 – EMQX, Mosquitto, NanoMQ, and Vernemq, were chosen to perform the benchmark test.

This blog series presents the benchmark test results and aims to help you choose a suitable MQTT broker based on your needs and use cases.

MQTT Benchmark Scenario Sets and Use Cases

The MQTT Benchmark Suite designs two sets of benchmark use cases. One is named Basic Set, which is for small-scale performance verification, and another is called Enterprise Set, which aims for enterprise level verification.

Detailed descriptions of the testing scenarios are already available on the GitHub project, for convenience we briefly list them here as well. All the tests are executed on a single node.

Use Cases

Basic Set

  • Point-to-Point: p2p-1K-1K-1K-1K
    • 1k publishers, 1k subscribers, 1k topics
    • Each publisher pubs 1 message per second
    • QoS 1, payload 16B
  • Fan-out: fanout-1-1k-1-1K
    • 1 publisher, 1 topic, 1000 subscribers
    • 1 publisher pubs 1 message per second
    • QoS 1, payload 16B
  • Fan-in: sharedsub-1K-5-1K-1K
    • 1k publishers, 1k pub topics
    • 5 subscribers consume all messages in a shared subscription way
    • Publish rate: 1k/s (each publisher pubs a message per second)
    • Shared subscription’s topic: $share/perf/test/#
    • Publish topics: test/$clientid
    • QoS 1, payload 16B
  • Concurrent connections: conn-tcp-10k-100
    • 10k connections
    • Connection rate (cps): 100/s

Enterprise Set

  • Point-to-Point: p2p-50K-50K-50K-50K
    • 50k publishers, 50k subscribers, 50k topics
    • Each publisher pubs 1 message per second
    • QoS 1, payload 16B
  • Fan-out: fanout-5-1000-5-250K
    • 5 publishers, 5 topics, 1000 subscribers (each sub to all topics)
    • Publish rate: 250/s, so sub rate = 250*1000 = 250k/s
    • QoS 1, payload 16B
  • Fan-in: sharedsub-50K-500-50K-50K
    • 50k publishers, 50k pub topics
    • Publish rate: 50k/s (each publisher pubs a message per second)
    • Use a shared subscription to consume data (to avoid slow consumption by subscribers affecting broker performance, 500 subscribers are used to share the subscription)
    • Shared subscription’s topic: $share/perf/test/#
    • Publish topics: test/$clientid
    • QoS 1, payload 16B
  • Concurrent connections: conn-tcp-1M-5K
    • 1M connections
    • Connection rate (cps): 5000/s

Common MQTT Config

ConfigValue
keep alive300s
clean sessiontrue
authentication enablementno
TLS authentication enablementno
test duration30 minutes

Testbed

The test environment is configured on AWS, and all virtual machines are within a VPC (virtual private cloud) subnet.

Broker Machine Details

  • Public cloud: AWS
  • Instance type: c5.4xlarge 16C32G
  • OS: Ubuntu 22.04.1 amd64

Test Tool

XMeter is used in this benchmark test to simulate various business scenarios. XMeter is built on top of JMeter but with enhanced scalability and more capabilities. It provides comprehensive and real-time test reports during the test. Additionally, its built-in monitoring tools are used to track the resource usage of the EMQX/Mosquitto server, enabling a comparison with the information provided by the operating systems.

XMeter provides a private deployment version (on-premise) and a public cloud SaaS version. A private XMeter is deployed in the same VPC as the MQTT broker server in this testing.

SW Version

BrokerVersion
EMQX4.4.16
Mosquitto (with persistence disabled)2.0.15
NanoMQ0.17.0
VerneMQ1.12.6.2
XMeter3.2.4

Benchmarking Results

CPU and Memory consumption for the message throughput scenarios are counted for the phase of message sending & receiving. For the concurrent connection test, they are counted in the connection phase.

Basic Set

point-to-point: 1K:1K

Average pub-to-sub latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedAvg memory used
Mosquitto0.250%0%278M254M
NanoMQ0.251%0%271M270M
EMQX0.274%2%510M495M
VerneMQ0.410%6%1.3G1.2G

Fan-out 1k QoS 1

Average pub-to-sub latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedAvg memory used
Mosquitto5.730%0%270M260M
NanoMQ13.660%0%271M263M
EMQX32%1%475M460M
VerneMQ21.554%2%1.2G1.1G

Fan-in 1k - shared subscription QoS 1

Average pub-to-sub latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedAvg memory used
Mosquitto0.200%0%281M246M
NanoMQ0.180%0%294M267M
EMQX0.193%2%468M460M
VerneMQ0.346%5%1.3G1.2G

10K connections cps 100

Average latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedMemory used Stable at
Mosquitto0.60%0%306M264M
NanoMQ0.590%0%320M320M
EMQX0.742%1%540M510M
VerneMQ0.893%0%1.1G1.0G

Enterprise Set

point-to-point: 50K:50K QoS1

Metrics
Actual msg rateAverage pub-to-sub latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedAvg memory used
Mosquitto37k:37k353.826%6%341M318M
NanoMQ50k:50k9135%30%1.33G1.3G
EMQX50k:50k1.5888%80%5.71G5.02G
VerneMQ50k:50k2136.6291%90%6.30G6.02G

In this scenario, Mosquitto cannot reach to the target message rate. It stabilized at 37300/s for both pub and sub. VerneMQ is able to handle the expected 50k message incoming and outgoing throughput, but the latency was quite high.

pub-to-sub latency percentiles

Latency (ms)EMQXMosquittoNanoMQVerneMQ
p50136182467
p7513671712,937
p9023722106,551
p9543782259,517
p991841725116,500

Fan-out 250k QoS 1

Metrics
Actual msg rateAverage pub-to-sub latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedAvg memory used
Mosquitto81k12,240.837%6%355M341M
NanoMQ250k13.9173%71%781M682M
EMQX250k1.9973%71%530M483M
VerneMQ80k11,802.1193%92%3.01G2.94G

In this scenario, Mosquitto and VerneMQ cannot reach to the target message rate. The throughput of Mosquitto and VerneMQ have been fluctuating around 80,000/s.

pub-to-sub latency percentiles

Latency (ms)EMQXMosquittoNanoMQVerneMQ
p50212,3781411,966
p75212,5221812,551
p90312,5712113,060
p95312,5962313,357
p99412,6272613,884

Fan-in 50k - shared subscription QoS 1

Metrics
Actual msg rateAverage pub-to-sub latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedAvg memory used
Mosquittopub: 50k
sub: 40k
12,723.077%7%485M456M
NanoMQpub: 50k
sub: 50k
2.7634%34%795M783M
EMQXpub: 50k
sub: 50k
1.4794%93%8.19G6.67G
VerneMQpub: 7.6k
sub: 3.5k
116,888.6183%74%12.16G8.38G
pub-to-sub latency percentiles

Latency (ms)EMQXMosquittoNanoMQVerneMQ
p50113,1382128,251
p75113,2813132,047
p90213,4234135,239
p95213,5265137,106
p991913,73621140,528

1M connections cps 5k

Metrics
Average latency (ms)Max CPU user+systemAvg CPU user+systemMax memory usedMemory used Stable at
Mosquitto5.742%2%1G1G
NanoMQ3.165%4%6.9G6.9G
EMQX2.435%22%10.77G8.68G
VerneMQ2.4744%25%22.4Gnot stable

During a 30-minute’s test of VerneMQ, the memory used keeps increasing. It rose from 18GB when 1 million connections were completed to 22.4GB at the end of the test.

latency percentiles

Latency (ms)EMQXMosquittoNanoMQVerneMQ
p502222
p752222
p902222
p952223
p993933

Conclusion

The above benchmark results indicate that there is not much difference in the performance of the four brokers in basic use case set, and except for the fan-out scenario, the latency is within milliseconds. Mosquitto and NanoMQ have the least CPU and memory usage, EMQX is slightly higher, and VerneMQ has the highest usage.

In enterprise level set, EMQX and NanoMQ perform the best in all use cases. Both can support the target throughput and higher, and the latency is reasonable, within milliseconds or tens of milliseconds. In summary, EMQX, Mosquitto, NanoMQ, and VerneMQ are the top four MQTT brokers in the open-source community in 2023. You can choose the most suitable one according to your actual needs and usage scenarios.

Try EMQX Enterprise for Free
Connect any device, at any scale, anywhere.
Get Started →

Related Posts