Monday, November 21, 2022

MQTT performance testing - Best Practices

The MIMIC Simulator performance testing methodology attempts to overcome
common problems with published performance benchmarks, specially in the 
IoT arena. In this article we examine one recently published report and discuss 
how to make it better.
 
The main problem with any performance test is that the results apply only to the 
specific test scenario. If the test scenario is carefully selected, the results will be 
relevant for a wide variety of situations. If the test report is good, then the exact 
methodology is documented, so you can evaluate it, and determine whether the 
results can be useful for you. For example this report

https://www.researchgate.net/publication/354610718_Stress-Testing_MQTT_Brokers_A_Comparative_Analysis_of_Performance_Measurements

performed one test scenario for an uncommon situation of a small set (3) of high-
frequency publishers, and 15 mosquitto_sub subscribers. Plain text MQTT is only 
used in trivial situations, and there is no indication that TLS transport is measured.
Latency measurements suffer from the time synchronization problem on different 
systems.
 
Specifically, it says right at the beginning in the abstract
 
"The evaluation of the brokers is performed by a realistic test scenario"

 but then, in section 4.1.1. Evaluation Conditions:

"

Number of topics:                   3
                                    (via 3 publisher threads)
Number of publishers:               3
Number of subscribers:              15 (subscribing to all 3 topics)
Payload:                            64 bytes
Topic names used to publish large
number of messages:                 ‘topic/0’, ‘topic/1’, ‘topic/2’
Topic used to calculate latency:    ‘topic/latency

"
 
so rather than testing a large-scale environment, a small set (3) of high-frequency 
publishers, and 15 mosquitto_sub subscribers was used. In our experience, no 
recent broker has any problem with less than 1000 publishers.

Second, in section 4. the subscriber back-end is detailed:

"The subscriber machine used the “mosquitto_sub” command line
subscribers, which is an MQTT client for sub- scribing to topics and
printing the received messages. During this empirical evaluation, the
“mosquitto_sub” output was redirected to the null device (/dev/null)
"

using a the simple mosquitto_sub client which is single threaded. In addition,
the subscribers subscribe to all topics, probably the wildcard topic #. So, out of 
many code paths in the broker, the least commonly used is tested. If your 
application uses a topic hierarchy, with different subscribers subscribing to 
different topic trees, then topic matching performance needs to be exercised.

Third, while QOS 0, 1 and 2 seem to be tested, only a single payload size 
was used, and there is no indication that TLS transport is measured.

Fourth, they attempt to measure latency correctly, ie. section 4.1.2

"Latency is deļ¬ned as the time taken by a system to transmit a message
from a publisher to a subscriber
"

but their methodology is flawed, since it is almost impossible to synchronize the 
clocks on 2 separate systems to millisecond accuracy and in table 6 the latencies 
are in the 1ms range. So, the measurements rely on unknown synchronization. 
For an example of the MIMIC latency testing methodology see this blog post.




Friday, November 18, 2022

Migrating from shuttered IBM Watson IoT platform

In a previous article simulation was recognized as helping prevent IoT project failures
so prevalent in the industry.
 
With the recent announcements of the shuttering of the Google IoT Core and 
IBM Watson IoT platforms, we can suggest that MIMIC IoT Simulator can be used 
to help migrate from the obsolete IoT platforms to a new offering by:


1) running a facsimile of your environment in MIMIC

2) staging migration to the new platform

3) testing requirements at various scales to make it future-proof

before you impact your production network.

Thursday, November 17, 2022

How to scale your MQTT lab to 1000 sensors in minutes

TL;DR Money saved: $40,000. Time saved: immeasurable.

We needed to create a MQTT lab with 1000 sensors to test a subscriber client with
realistic telemetry. The open-source client tracks any key value, and alerts if any
arbitrarily pre-selected value exceeds a threshold.

We bought 1 real Shelly Plus H&T sensor for $40.

After you have configured it, it sends MQTT messages to the broker, but only 
every time the temperature and humidity changes. So, to test our application, we 
would have had to run to the refridgerator quite often to make it change the 
temperature.

As you can see from the screenshot


it sends JSON payloads, but very infrequently. In our case, after 6 minutes


So, every time we wanted a message, we needed to change the temperature.

To accelerate development, we used MIMIC.

First we just captured the messages with wireshark, recorded into MIMIC MQTT Simulator
and generated messages whenever and however we wanted. Rather than waiting for minutes, we can
send any message with any value in seconds, speeding up development time. Then we multiplied
the sensor 1000-fold, quickly reaching the required scalability at no additional cost.

This video shows the process in 2 minutes:


Money saved: $40,000. Time saved: immeasurable.