Skip to main content

Benchmarks

The HiveMQtt GitHub repository provides benchmarks built using BenchmarkDotNet, a .NET library for benchmarking. These benchmarks measure the performance of various messaging operations against any MQTT broker.

Running Benchmarks

To run the benchmarks, execute the following commands:

cd Benchmarks/ClientBenchmarkApp
dotnet run ClientBenchmarkApp.csproj -c Release

Results

The benchmarks provide insights into the performance of different messaging methods under various scenarios. Below are the results obtained from running the benchmarks on a local MacBook Pro against a HiveMQ v4 broker running in a Docker container over localhost.

Legend

  • Mean: Arithmetic mean of all measurements
  • Error: Half of 99.9% confidence interval
  • StdDev: Standard deviation of all measurements
  • Median: Value separating the higher half of all measurements (50th percentile)
  • 1 us: 1 Microsecond (0.000001 sec)
  • 1 ms: 1,000 Microseconds
  • Green: Improvement
  • Red: Regression

July 25, 2024

Summary

The client has had many feature additions and improvements from March 2024 including:

  • New Back-pressure support
  • Improved QoS reliability
  • Improved Async await strategies
  • Re-architected internal queues
  • Improved event & trigger handling
  • All around better error handling

The following table shows the benchmark results compared against previous benchmark runs.

MethodAlphaMarch 2024July 2024
QoS 0 Message4.875 us9.084 us5.500 us
QoS 1 Message790.645 us1,357.063 us982.208 us
QoS 2 Message1,653.083 us1,292.396 us1,004.854 us
100 QoS 0 @ 256bNo Data79.604 us100.375 us
100 QoS 1 @ 256bNo Data42,482.520 us29,661.605 us
100 QoS 2 @ 256bNo Data85,640.167 us55,474.250 us
100 QoS 0 @ 256kNo Data69.709 us99.354 us
100 QoS 1 @ 256kNo Data266,506.583 us215,158.104 us
100 QoS 2 @ 256kNo Data296,254.688 us227,255.729 us

July Benchmark Data

The raw benchmark data from July.

MethodMeanErrorStdDevMedian
'Publish a QoS 0 message'32.59 us85.64 us252.53 us5.500 us
'Publish a QoS 1 message'6,323.30 us16,671.57 us49,156.51 us982.208 us
'Publish a QoS 2 message'6,554.90 us16,998.38 us50,120.10 us1,004.854 us
'Publish 100 256b length payload QoS 0 messages'131.73 us92.15 us271.71 us100.375 us
'Publish 100 256b length payload QoS 1 messages'35,405.71 us17,183.26 us50,665.23 us29,661.605 us
'Publish 100 256b length payload QoS 2 messages'61,955.04 us17,559.19 us51,773.66 us55,474.250 us
'Publish 100 256k length payload QoS 0 messages'129.00 us83.24 us245.42 us99.354 us
'Publish 100 256k length payload QoS 1 messages'226,498.28 us42,050.59 us123,987.13 us215,158.104 us
'Publish 100 256k length payload QoS 2 messages'244,227.03 us47,932.40 us141,329.77 us227,255.729 us

Mar 22, 2024

Publishing a QoS 2 message with the full round-trip of confirmation packets is now timed at ~1.2ms.

MethodMeanErrorStdDevMedian
'Publish a QoS 0 message'57.27 us158.55 us467.50 us9.084 us
'Publish a QoS 1 message'2,291.28 us903.01 us2,662.56 us1,357.063 us
'Publish a QoS 2 message'2,058.05 us1,048.91 us3,092.73 us1,292.396 us
'Publish 100 256b length payload QoS 0 messages'138.29 us183.38 us540.69 us79.604 us
'Publish 100 256b length payload QoS 1 messages'45,813.98 us4,838.62 us14,266.78 us42,482.520 us
'Publish 100 256b length payload QoS 2 messages'88,589.38 us3,877.02 us11,431.48 us85,640.167 us
'Publish 100 256k length payload QoS 0 messages'124.92 us173.22 us510.74 us69.709 us
'Publish 100 256k length payload QoS 1 messages'270,043.05 us8,850.72 us26,096.56 us266,506.583 us
'Publish 100 256k length payload QoS 2 messages'300,923.38 us5,704.22 us16,819.03 us296,254.688 us

See also: What is MQTT Quality of Service (QoS) 0,1, & 2? – MQTT Essentials: Part 6.

Mar 21, 2024

With release v0.11.0 there was a big performance improvement. All messaging performance was improved but particularly publishing a QoS level 2 message went from ~206ms down to ~1.6ms.

Summary

From the early version through two refactors, this table summarizes the performance improvements.

MethodOriginalFirst Pass RefactorFinal Refactor
QoS 0 Message5.646 us9.250 us4.875 us
QoS 1 Message103,536.375 us1,324.251 us790.645 us
QoS 2 Message206,959.834 us2,569.166 us1,653.083 us

Previous Performance

MethodMeanErrorStdDevMedian
'Publish a QoS 0 message'390.8 us1,842.5 us1,218.7 us5.646 us
'Publish a QoS 1 message'103,722.8 us4,330.0 us2,864.1 us103,536.375 us
'Publish a QoS 2 message'202,367.9 us26,562.9 us17,569.7 us206,959.834 us

First Pass Refactor Performance

MethodMeanErrorStdDevMedian
'Publish a QoS 0 message'401.9 us1,876.3 us1,241.0 us9.250 us
'Publish a QoS 1 message'2,140.0 us3,568.2 us2,360.1 us1,324.251 us
'Publish a QoS 2 message'4,217.2 us5,803.7 us3,838.8 us2,569.166 us

Final Refactor Performance Results (for now 👻)

MethodMeanErrorStdDevMedian
'Publish a QoS 0 message'47.11 us139.47 us411.23 us4.875 us
'Publish a QoS 1 message'1,210.71 us508.64 us1,499.75 us790.645 us
'Publish a QoS 2 message'2,080.46 us591.38 us1,743.71 us1,653.083 us