← Blog

· 15 min read #rust#mqtt#iot#unikernel#performance#mosquitto#open source

urMQTT against Mosquitto on two VPSes: where a unikernel broker is 3x ahead, and where it is not

One day of measurements, two rented machines (an x86_64 VPS with four cores, an ARM64 VPS with two), three brokers on each (the urMQTT release, the urMQTT build with the new TCP sending side, Mosquitto 2.0.21), each machine loaded from the other. New TLS connections per second, messages delivered under flood and at steady rates, latency, fan-out, 20,000 idle connections and the memory they cost, the broker's CPU. With cores to use urMQTT is two to three times ahead and holds 20,000 idle mTLS connections in 18 MB where Mosquitto's process takes 546 MB; on one ARM core Mosquitto still moves more QoS 0 messages, and our new build is slower than the old one on QoS 1 there. The numbers, the method, the charts and what is wrong with each of them.

The short version, for people who want one paragraph. On a rented 4-vCPU x86_64 VPS, loaded over the internet from another VPS with the same generator, the same certificates and the same suite for all three brokers, urMQTT accepted three times as many new mutual-TLS connections per second as Mosquitto 2.0.21 (1,956 against 639), delivered 3.3 times as many QoS 0 messages with sixteen clients on each side (201,000 against 60,000 per second), 2.3 times as many QoS 1 messages with sixty-four pairs, fanned out 2.7 times as many, and had the lower latency at every steady rate, with a p99 of 27 ms against 95 ms at 16,000 messages per second. Twenty thousand idle mTLS connections cost it 18 MB of memory in total; Mosquitto's process grew to 546 MB for the same connections. The one place we were behind Mosquitto in the earlier texts, a single TCP flow, is now ahead on that machine for small messages and inside Mosquitto's range for 1 KiB ones.

And the paragraph that has to stand right next to it. On the other machine, a 2-vCPU ARM64 VPS where one core does the network card, TLS, the broker and the dispatching, Mosquitto moves more QoS 0 messages than we do: 58,000 against 44,000-47,000 per second with sixteen pairs, 49,000 against 12,000-22,000 on a single flow, 6,100 against 2,000-3,000 on a single 1 KiB flow. It also fans out to a thousand slow subscribers better there. And the build with the new TCP sending side, which is the one that wins on four cores, is 10 to 30 % slower than the release on QoS 1 on that one core. Those three facts are in the same tables as the good ones, and the last one is a regression we have to fix before the next release.

Everything else in this text is how those numbers were made, what each of them means, and what is wrong with them.

Why we measured again, and why like this

The previous texts compared urMQTT with Mosquitto once, on one machine, with a load generator on a shared server that lost 60 to 77 % of its CPU to other tenants during the runs. The ranking from that session was probably right; the ranges were not something to quote. Since then the sending side of our TCP got SACK recovery, acknowledgements on arrival and a validated congestion window (ADR-265), and the network card driver asks for deeper queues (ADR-266), both measured only on a local rig. The honest way to find out what they are worth was to run the whole comparison again, properly.

"Properly" meant four things.

  1. Two machines, two architectures. The Contabo VPS of the earlier texts (x86_64, 4 vCPU AMD EPYC, KVM, 8 GiB) and the netcup VPS of the ARM64 text (2 vCPU Neoverse N1, 3.9 GiB). On the ARM machine urMQTT uses one core for everything the network and the broker do and the other for the database, so every ARM figure below is single-core broker performance against a single-core Mosquitto. On the x86 machine urMQTT has three data cores and a database core; Mosquitto is still one process on one core, because that is what Mosquitto is.
  2. Each machine measured from the other. The load generator for Contabo ran on netcup (Debian 13, our urmqtt-loadgen pinned to its two cores), and the generator for netcup ran on Contabo (two of its four cores). The two are 12 ms apart. Both generators showed 0 % steal in every run; the first pass we made from the shared build server, with 10 to 45 % steal, is kept in the repository but not used here. It made the same ranking with ranges twice as wide, which is its own small finding: the generator decides how wide your error bars are.
  3. Three brokers per machine, same everything. The release v0.4.2, the main build at 318f60b with ADR-265 and ADR-266, and Mosquitto 2.0.21 from the Debian 13 package with OpenSSL 3.5.7, installed by the script in the repository with the same CA, the same server certificate and the same ACL. On each machine the three ran one after the other, with the same generator, the same suite in the same order (handshake, throughput, latency, fanout, idle, sweep, single), three repetitions of each run; every number is a median and every range is the minimum and maximum of the three.
  4. The broker's own view, not only the generator's. During each urMQTT run a second client recorded the console and the $SYS counters (per-core CPU, memory in use, every drop counter); for Mosquitto the generator read /proc over ssh for its CPU and RSS. So "delivered" below is what arrived at the subscribers, "accepted" is what the publishers managed to send, and when they differ we can say where the difference went.

Mutual TLS 1.3 everywhere, a client certificate on every connection, no session resumption. That is the setting urMQTT is built for (devices with certificates), and it is the one where a broker's TLS implementation shows.

The charts

Every figure has the two machines side by side on one scale, the same colour for the same broker everywhere, the median as the bar or the point and the min-max of the three runs as the whisker or the band.

New mutual-TLS connections per second as the generator's concurrency grows from 32 to 128 threads. Contabo (4 vCPU) on the left, netcup (one broker core) on the right.
New mutual-TLS connections per second as the generator's concurrency grows from 32 to 128 threads. Contabo (4 vCPU) on the left, netcup (one broker core) on the right.

Handshakes first, because that is what a fleet does to a broker after a power cut: everyone comes back at once. On four cores urMQTT accepts 1,956 full handshakes a second at 128 concurrent clients, Mosquitto 639, and the TLS part of our handshake takes 35 ms against 130. On the single ARM core it is 820-923 against 419. The generator, not the broker, is close to its own limit on the x86 side (1.7 of its two cores), so the urMQTT figure there is a floor.

Messages delivered per second under flood: publishers send as fast as the broker accepts, the bars are what arrives at the subscribers.
Messages delivered per second under flood: publishers send as fast as the broker accepts, the bars are what arrives at the subscribers.

Throughput under flood. The x86 panel is the headline: 201,000 QoS 0 messages a second delivered with sixteen pairs against Mosquitto's 60,000, and the new build is 60 % ahead of the release there (125,000). With 1 KiB messages the three are equal at about 22,000 a second, which is 22 MB/s and smells like the network path, not any broker. QoS 1 with sixteen pairs is close (22,000 against 19,000 delivered); with sixty-four pairs it opens to 69,000 against 30,000. Fan-out of one publisher to a hundred subscribers under flood: 287,000 deliveries a second against 106,000.

The ARM panel is where Mosquitto wins QoS 0: 58,000 against 44,000-47,000 with sixteen pairs, 15,000 against 12,000 with 1 KiB. Look at the accepted side of those runs in the tables and the reason shows: urMQTT accepted 183,000-187,000 messages a second from the publishers on that one core and then dropped most of them to subscribers whose streams could not take them; Mosquitto accepted 60,000 and delivered 58,000. The core we spent on reading publishers that we then dropped is the core Mosquitto spent on delivering. QoS 1 and fan-out on the same core still go to urMQTT (52,000 against 20,000 with sixty-four QoS 1 pairs; 124,000 against 86,000 on fan-out).

One publisher and one subscriber: the hardest case for urMQTT in every earlier text.
One publisher and one subscriber: the hardest case for urMQTT in every earlier text.

The single flow. This is the row that was 40 % of Mosquitto's in the first comparison and the reason ADR-265 exists. On x86 the new build delivers 87,000 small messages a second on one flow against the release's 54,000 and Mosquitto's 51,000; with 1 KiB messages 10,000 against 7,200 and 12,000, inside Mosquitto's own range of 7,700-16,100. The latency on that flow halved (p50 427 to 222 ms). On the ARM core the new build doubled the release (22,000 against 12,000) and is still less than half of Mosquitto's 49,000; with 1 KiB messages both urMQTT builds deliver 2,000-3,000 against 6,100, with runs as low as 100 a second. On one flow on one core, the publisher starves the subscriber.

Delivered against offered at QoS 1: sixteen publishers at 100, 300 and 1000 messages a second each. The dashed line is "everything offered is delivered".
Delivered against offered at QoS 1: sixteen publishers at 100, 300 and 1000 messages a second each. The dashed line is "everything offered is delivered".

Steady rates with QoS 1. At 16,000 offered a second, x86: the new build delivers 15,700, the release 15,200, Mosquitto 14,300, with p99 latencies of 124 ms, 159 ms and 2.1 s. The ARM panel shows the regression: the release delivers 13,000, the new build 8,800, Mosquitto 13,000. Mosquitto's QoS 1 latency is the other story in that figure: p50 527 ms and p99 2.6 s on the ARM core, p99 2.1 s on x86, against tens of milliseconds for urMQTT at the same delivered rate. If your devices wait for PUBACKs, that is the number that decides how many messages they have in flight.

Latency at steady rates and under a single-flow flood: bars are p50, whiskers reach p99, log scale.
Latency at steady rates and under a single-flow flood: bars are p50, whiskers reach p99, log scale.

Latency more broadly. At eight pairs sending a hundred messages a second each, the quiet case, all three are within a few milliseconds of each other on p50 (6-10 ms on x86, 8-16 ms on ARM, most of it the 12 ms round trip); the p99s separate them: 20 ms for the new urMQTT build against 48 for Mosquitto on x86, and on ARM the new build is the worst of the three (218 ms p99, against 59 for the release and 140 for Mosquitto). At sixteen pairs and 16,000 a second, the new build is the best on both machines on p50 and on x86 on p99.

Memory the broker holds for idle mutual-TLS connections, 0 to 20,000, nothing published.
Memory the broker holds for idle mutual-TLS connections, 0 to 20,000, nothing published.

Memory. This is the clearest result of the day and the one our own earlier text understated. Twenty thousand idle mTLS connections cost urMQTT 17.9 MB of heap on x86 and 10.7 MB on ARM, in total, about half a kilobyte to under a kilobyte each. There is nothing else: a unikernel has no process, no page cache, no per-socket kernel state outside that heap, so that is the whole bill. Mosquitto's process grew to 546 MB on both machines, about 27 KB per connection, almost all of it OpenSSL's per-connection state, and it did not shrink when the connections closed. The earlier text compared our heap with Mosquitto's own $SYS heap counter, which reads 17 MB at 20,000 connections because it does not see OpenSSL's allocations; that comparison was wrong in Mosquitto's favour. Both brokers opened the 20,000 connections without a single error (38-40 s for urMQTT, 51 s for Mosquitto, limited by the generator).

The broker's CPU while delivering: cores busy in the first 14 s of each run.
The broker's CPU while delivering: cores busy in the first 14 s of each run.

CPU. Mosquitto is one process on one core and in every heavy run it was at 94-100 % of it; that is the ceiling you see in all of its flood figures, and no bigger machine moves it. urMQTT's cores on x86 were between half a core and 2.8 cores busy in the sampled window for 3.3 times the delivered messages; the sample is the first 14 s of each run and noisy, which is why the whiskers are wide. On the ARM core the picture is the one from the throughput chart: our one core is mostly spent accepting what it then drops.

What is wrong with each of these numbers

Caveats are what make a comparison usable, so here they are in order of importance.

  • Two machines, one day, one generator each. Three repetitions tell you the spread within a session, not between days or hosts. The ARM VPS is a shared host (its 32-thread handshake runs varied 2.5x on a different day in the earlier text); both generators were quiet during these runs, but the brokers' hosts were whatever they were.
  • The generator was the limit in some cells. On the x86 handshake run the netcup generator was at 1.7 of its two cores; on the sixteen-pair floods it was at 1.3. The urMQTT figures in those cells are floors, Mosquitto's are not affected (it was at its own ceiling).
  • "Delivered" and "accepted" are different things, and the two brokers trade them differently. For QoS 0, MQTT allows a broker to drop messages to a subscriber that cannot keep up. urMQTT does that and keeps accepting from the publisher; Mosquitto stops reading the publisher (TCP back-pressure) and delivers almost everything it accepted. On a single flow that makes urMQTT's accepted rate look very high and its delivered rate the only one that counts; on the ARM core it is the reason Mosquitto wins QoS 0 outright. Neither behaviour is wrong; ours is worse for a publisher that wants to know its messages arrived, and the change (stop reading the publisher when the subscriber is the only consumer) is the next item on our list.
  • The ARM network card offers 256 receive descriptors and no more, so ADR-266's deeper queues did nothing there. The suite also found the transmit queue full 199,000 times with the release and 261,000 times with the new build (frames/dropped/nic in the console records: frames dropped because the transmit queue was full; an earlier version of this text wrongly called it a receive-queue overrun). On Contabo the same counter was 16.
  • The new build is not uniformly better. On the one ARM core it is 10 to 30 % behind the release on QoS 1 (14,100 against 17,500 delivered with sixteen pairs; 42,000 against 52,000 with sixty-four; 8,800 against 13,000 at 16,000 offered) and behind on the handshake run (820 against 923, with a 1.1 s p99 tail that looks like a one-second retransmission timeout). The candidates are the congestion-window change (cut to 70 % on a fast retransmit, growth only while the window is used) on short QoS 1 exchanges and the per-segment acknowledgement work on a core that is already saturated. The ss -tin samples of those runs are in the repository; this is open and goes before v0.5.0.
  • Fan-out to a thousand slow subscribers is a urMQTT weakness on one core: 8,200-8,600 of 10,000 messages a second delivered with a p50 of 220 ms, where Mosquitto delivers 9,800 at 56 ms. On four cores both deliver everything and urMQTT's p50 is lower. The walk over a thousand subscriptions per message on the core that also runs the network card is the likely cost; not profiled yet.
  • Memory is heap against RSS. For urMQTT the heap in use is the whole truth; for Mosquitto RSS includes the C library's retained allocations, which is why it does not fall after the connections close. Mosquitto's own counter is the wrong number for this comparison, as explained above.
  • The first pass from the shared build server is in the raw files (contabo-*.txt without -from-netcup) and is not used here. Its medians were lower and its ranges twice as wide for the same brokers on the same machine, with 10 to 45 % steal on the generator.

What we take from it

With cores to use, urMQTT is ahead of Mosquitto by factors, not percentages, on the things a device fleet does to a broker: reconnecting all at once, publishing from many clients, holding tens of thousands of idle TLS connections, QoS 1 at a steady rate. That is the design doing what it was built for: a network stack and a TLS implementation per core, no kernel between the card and the broker, no process. The single flow, which was our worst row for a month, is now a row we win on x86 with small messages.

On one core, Mosquitto's twenty years of being a very good single-threaded C event loop show, and our one core is spent on the wrong things: polling the network card every 200 µs, copying, reading publishers whose messages we then drop. The fixes are known and listed (NOW-13 in the roadmap): back-pressure on the publisher when the subscriber is the only consumer, an interrupt instead of polling on receive, per-CPU heap caches, and the QoS 1 regression of the new TCP sending side on a saturated core. Each of them gets measured the same way, against the same files, before it is called an improvement.

The method is in the repository: scripts/x11-bench.sh runs the suite, scripts/x11-mosquitto.sh installs Mosquitto with the same TLS material, scripts/x11-report.py turns the raw files into tables and scripts/x11-charts.py into the figures above; docs/PERFORMANCE.md section 13 has every table, and docs/perf-results/x11-2026-11-07/ every raw file, including the console records with the drop counters that explain the differences. If you measure something else, we would like to see it.

urMQTT is alpha. These numbers measure a specific kernel on two specific rented machines on one day; they do not measure maturity in production.

Comments

Comment rules

Comment rules

Comments are here to share experience and questions about the topics of the blog. These rules keep the discussion useful for everyone.

  1. Be civil No insults, threats, harassment, hate speech or discrimination on any grounds. Criticise the argument, not the person.
  2. Stay on topic A comment should relate to the post or to the discussion under it.
  3. No ads or spam No advertising, chain messages or links without context. Links and images are welcome when they add to the discussion.
  4. Others' privacy Do not post other people's personal data: full names of private individuals, addresses, phone numbers, emails, photos without consent.
  5. Copyright Post only content you are allowed to share. When quoting, name the source.
  6. One identity Use one nickname and do not pose as someone else.
  7. Email confirmation A comment is published only after you confirm the link sent by email. The address is not shown and not used for anything else; unconfirmed comments are deleted after 48 hours.
  8. Moderation Comments that break the rules are hidden or deleted without notice, and a discussion may be locked. Moderators' decisions are final.
  9. Responsibility The author is responsible for the content of a comment. Comments do not reflect the views of ALDO TECH.
  10. Reporting Report inappropriate content to info@aldo.tech.