M

MQTT

Protocol adapters available

Publish and subscribe over MQTT 3.1.1/5.0 with per-VU sessions.

Install
$ loadr plugin install mqtt
examples/plugins/mqtt.yaml
# MQTT load test, driven by the `loadr-plugin-mqtt` native protocol plugin.
#
# MQTT is NOT built into loadr core — it is a runtime-loadable plugin that
# hand-rolls the MQTT 3.1.1 control packets (CONNECT/CONNACK, PUBLISH/PUBACK,
# the QoS-2 PUBREC/PUBREL/PUBCOMP flow and SUBSCRIBE/SUBACK) directly over TCP,
# with no `rumqttc`/`paho` client and no OpenSSL. The plugin declares the
# `mqtt://` URL scheme, so once it is installed a request to an `mqtt://` URL
# routes straight to it; no explicit `protocol:` is needed.
#
# Each request runs exactly one operation from its `plugin:` block: a `publish`
# of a single message, or a `subscribe` that receives a single message. loadr
# records the round-trip latency in `mqtt_req_duration` and counts operations in
# `mqtt_reqs`. Success is status 0; a broker refusal, an unconfirmed QoS 1-2
# publish, a subscribe timeout, or a connection failure is status 1 and fails
# the request.
#
# Build + install the plugin, then run:
#   cargo build -p loadr-plugin-mqtt --release
#   mkdir -p dist && cp plugins/loadr-plugin-mqtt/plugin.toml dist/ \
#     && cp target/release/libloadr_plugin_mqtt.so dist/
#   loadr plugin install dist
#   loadr run examples/plugins/mqtt.yaml
#
# Or point the plan's `plugins:` entry at the built artifact directly (below).
name: mqtt
description: publish + subscribe against an MQTT broker via loadr-plugin-mqtt

plugins:
  # Resolve `mqtt` by name from the plugins dir (after `loadr plugin install`).
  # To run straight from a build tree instead, set:
  #   path: target/release/libloadr_plugin_mqtt.so
  - name: mqtt

scenarios:
  # Publishers push sensor readings onto per-VU topics at QoS 1, so every
  # message waits on the broker's PUBACK before the request is counted as ok.
  publish:
    executor: constant-vus
    vus: 20
    duration: 15s
    flow:
      - request:
          name: publish reading
          url: mqtt://broker.example.com:1883
          plugin:
            operation: publish
            topic: sensors/${vu}/temperature
            qos: 1
            body: '{"vu": ${vu}, "iteration": ${iteration}}'
          assert:
            - { type: status, equals: 0 }        # 0 = ok, 1 = broker error

  # Subscribers receive one message per request from a wildcard filter, at a
  # fixed arrival rate, and fail if none arrives within 250ms.
  subscribe:
    executor: constant-arrival-rate
    rate: 60
    duration: 15s
    pre_allocated_vus: 10
    max_vus: 40
    flow:
      - request:
          name: receive reading
          url: mqtt://broker.example.com:1883
          plugin:
            operation: subscribe
            topic: sensors/+/temperature
            qos: 1
            timeout: 250ms
          checks:
            - { type: status, equals: 0 }
            - { type: duration, name: delivery is fast, max: 250ms }

thresholds:
  checks: [ "rate>0.99" ]
  mqtt_req_duration: [ "p(95)<300ms" ]
  mqtt_reqs: [ "count>0" ]

A real run: install from the signed index, then watch the plugin work.

A runtime plugin, never in the binary

Installing pulls a per-platform driver from the signed index, verifies its SHA-256 and checks its ABI before it ever loads. Remove it any time with loadr plugin remove mqtt.