Inferensys

Glossary

Message Queuing Telemetry Transport (MQTT)

Message Queuing Telemetry Transport (MQTT) is a lightweight, publish-subscribe network protocol designed for efficient machine-to-machine communication in constrained environments with low bandwidth and high latency.
Performance engineer optimizing AI latency on laptop, latency charts visible, technical optimization session.
TINYML DEPLOYMENT & MLOPS

What is Message Queuing Telemetry Transport (MQTT)?

A core protocol for machine-to-machine communication in constrained environments, essential for TinyML deployment pipelines.

Message Queuing Telemetry Transport (MQTT) is a lightweight, publish-subscribe network protocol designed for efficient machine-to-machine communication in constrained environments with low bandwidth, high latency, or unreliable networks. It operates over TCP/IP and uses a central broker to route messages between clients, which publish messages to topics or subscribe to them to receive updates. This decoupled architecture minimizes network overhead and power consumption, making it ideal for microcontroller-based Internet of Things (IoT) and TinyML deployments where devices transmit sensor telemetry or receive model updates.

In TinyML MLOps, MQTT facilitates over-the-air (OTA) updates and remote monitoring by enabling microcontrollers to publish inference results or system health metrics and subscribe to channels distributing new model binaries or configuration files. Its Quality of Service (QoS) levels guarantee message delivery, which is critical for reliable fleet orchestration. The protocol's minimal packet size and persistent session support align with the offline-first operation and power constraints of edge devices, forming a backbone for scalable, bidirectional communication in distributed intelligent systems.

PROTOCOL ARCHITECTURE

Key Features of MQTT

MQTT is engineered for constrained environments. Its core features prioritize minimal overhead, reliable message delivery, and efficient network utilization, making it the de facto standard for IoT and TinyML telemetry.

01

Publish/Subscribe Pattern

MQTT uses a publish/subscribe messaging pattern, decoupling data producers (publishers) from consumers (subscribers) via a central broker. Devices publish messages to topics (e.g., sensor/device123/temperature), and clients subscribe to topics of interest. This enables:

  • One-to-many distribution: A single message can be efficiently delivered to many subscribers.
  • Dynamic scalability: New subscribers can join without reconfiguring publishers.
  • Network efficiency: Clients only receive data they explicitly request, reducing wasted bandwidth.
02

Quality of Service (QoS) Levels

MQTT defines three Quality of Service (QoS) levels to guarantee message delivery across unreliable networks:

  • QoS 0 (At most once): Fire-and-forget. No acknowledgment. Lowest overhead, potential for message loss.
  • QoS 1 (At least once): Acknowledged delivery. The sender stores and retransmits the message until an acknowledgment (PUBACK) is received. Guarantees delivery but may cause duplicates.
  • QoS 2 (Exactly once): Assured delivery. A four-step handshake ensures the message is delivered precisely once. Highest reliability but greatest overhead. This allows developers to trade off reliability for latency and bandwidth based on use case.
03

Lightweight Packet Structure

The protocol uses a compact, binary packet format with a minimal 2-byte fixed header. This extreme efficiency is critical for:

  • Low-bandwidth networks (e.g., cellular LPWAN, satellite).
  • High-latency connections where large headers add significant delay.
  • Battery-powered devices where every transmitted byte consumes energy. For example, a simple publish message can be as small as 10-20 bytes, compared to hundreds of bytes for an HTTP request with headers.
04

Persistent Sessions & Last Will and Testament

MQTT supports persistent sessions where the broker stores subscriptions and missed messages (for QoS 1/2) for a disconnected client. Upon reconnection, the session resumes. The Last Will and Testament (LWT) is a critical feature for device health monitoring. When a client connects, it can define a pre-configured LWT message and topic. If the client disconnects ungracefully (e.g., network failure), the broker automatically publishes the LWT message, alerting the system to the device's offline state.

05

Topic Wildcards

Topic subscriptions support two wildcards for flexible filtering:

  • Single-level (+): Matches any name in a single topic level. Example: sensor/+/temperature subscribes to sensor/device1/temperature and sensor/device2/temperature but not sensor/device1/humidity/temperature.
  • Multi-level (#): Matches all subsequent levels. Must be the last character in the subscription. Example: sensor/device1/# subscribes to all subtopics under device1. This allows a single client to efficiently subscribe to data from entire device fleets or sensor hierarchies.
06

Keep Alive & Clean Session

The Keep Alive interval is a heartbeat mechanism. The client sends periodic PINGREQ packets to inform the broker it's alive. If the broker receives no packet within 1.5x the interval, it assumes the client is dead and can trigger its LWT. The Clean Session flag controls persistence. If true, the broker creates a new, transient session for the client (no state preserved). If false, the broker attempts to resume a previous persistent session, delivering any queued messages. This is essential for stateful TinyML deployments where inference results must be guaranteed.

PROTOCOL OVERVIEW

How MQTT Works: The Publish-Subscribe Mechanism

Message Queuing Telemetry Transport (MQTT) is a lightweight, publish-subscribe network protocol designed for efficient machine-to-machine communication in constrained environments with low bandwidth and high latency.

MQTT operates on a publish-subscribe (pub/sub) architecture, decoupling data producers (publishers) from consumers (subscribers) via a central broker. Devices publish messages to specific topics (e.g., sensor/temperature/room1), and the broker routes these messages to all clients that have subscribed to those topics. This model eliminates the need for direct point-to-point connections, enabling efficient one-to-many communication and dynamic scaling. The protocol uses a small header and accepts binary payloads to minimize network overhead, making it ideal for TinyML and IoT deployments on microcontrollers.

The protocol ensures reliable message delivery through Quality of Service (QoS) levels: QoS 0 (at most once), QoS 1 (at least once), and QoS 2 (exactly once). It maintains persistent sessions with Last Will and Testament (LWT) messages to notify other clients of an unexpected disconnect. For secure deployments, MQTT can operate over TLS/SSL and supports username/password authentication. Its minimal footprint and efficient handling of intermittent connectivity make it a cornerstone for over-the-air (OTA) updates and telemetry aggregation in distributed edge AI fleets.

DEPLOYMENT PROTOCOL

MQTT Use Cases in TinyML and IoT

Message Queuing Telemetry Transport (MQTT) is a lightweight, publish-subscribe network protocol designed for efficient machine-to-machine communication in constrained environments with low bandwidth and high latency. Its core principles make it the de facto standard for connecting TinyML devices to the cloud.

02

Over-the-Air (OTA) Model Updates

MQTT enables secure, targeted model distribution to microcontroller fleets. A model registry service publishes a new model binary to a topic like fleet/device-type-a/model/update. Devices subscribed to that topic receive the update payload. Quality of Service (QoS) levels guarantee delivery:

  • QoS 0 (At most once): For non-critical updates in high-loss environments.
  • QoS 1 (At least once): Ensures delivery, used for most model updates.
  • QoS 2 (Exactly once): For critical firmware or model updates where duplication is unacceptable.

This integrates with canary deployment by publishing updates to a canary subtopic first.

03

Remote Inference Triggering & Configuration

Instead of continuous streaming, MQTT allows command-and-control messaging to trigger on-device inference or reconfigure models. A cloud application publishes a command to a device-specific command topic (e.g., device/SN12345/command/infer). The device executes its local TinyML model and publishes the result back to a report topic.

  • Configuration Management: Publish new model parameters (thresholds, sampling rates) via config topics to dynamically tune device behavior without a full OTA update.
  • Power Optimization: Enables edge intelligence where devices sleep deeply, waking only to check for commands on retained messages, drastically extending battery life.
04

Health Monitoring & Alerting

TinyML devices use MQTT to publish device telemetry and model performance metrics, forming the backbone of MLOps for microcontrollers. Standard topics include:

  • $SYS-style topics for broker/client metrics.
  • device/health/battery: Reports state of charge.
  • device/model/confidence: Streams prediction confidence scores for model monitoring.
  • device/alert/anomaly: Publishes immediate alerts when an on-device anomaly detection model triggers.

This creates a real-time audit trail of device and model health, enabling proactive maintenance and detection of model drift in edge conditions.

05

Federated Learning Coordination

In federated edge learning scenarios, MQTT orchestrates the decentralized training process across a fleet. The central server publishes the initial global model weights to a federated/round/start topic. Devices perform local training on their sensor data and publish only the weight updates (gradients) to a secure, device-specific topic. The server aggregates these updates to improve the global model.

  • Privacy-Preserving: Raw sensor data never leaves the device.
  • Efficient for Constrained Networks: Only small mathematical updates are transmitted, not large datasets.
  • Handles Intermittency: The Last Will and Testament (LWT) feature can notify the server if a device drops out mid-round.
06

Gateway-to-Cloud Bridge for LPWAN

MQTT acts as the protocol bridge between local Low-Power Wide-Area Network (LPWAN) protocols (like LoRaWAN or Zigbee) and the internet. A gateway device aggregates data from many radios, translates it, and publishes it to an MQTT broker via cellular or Ethernet. This provides:

  • Unified Data Plane: Heterogeneous sensor data is normalized into MQTT topics for cloud processing.
  • Reliability: The broker's persistent sessions and retained messages ensure no data is lost if the cloud service restarts.
  • Interoperability: Decouples the choice of edge radio protocol from the cloud backend architecture.
PROTOCOL COMPARISON

MQTT vs. Other IoT Communication Protocols

A technical comparison of MQTT against other common protocols used for machine-to-machine communication in constrained IoT and TinyML environments.

Feature / MetricMQTTHTTP/1.1CoAPAMQP

Primary Communication Pattern

Publish/Subscribe

Request/Response

Request/Response & Observe

Publish/Subscribe & Point-to-Point

Transport Protocol

TCP/IP

TCP/IP

UDP/IP

TCP/IP

Header Overhead (Typical)

< 10 bytes

700 bytes

< 10 bytes

100 bytes

Quality of Service (QoS) Levels

3 (0,1,2)

0 (Relies on TCP)

2 (Confirmable/Non-confirmable)

3 (At-most-once, At-least-once, Exactly-once)

Built-in Last Will & Testament

Session State Awareness

Native Support for Binary Data

Typical Power Consumption

Low

High

Very Low

Medium

Latency (Typical, LAN)

< 10 ms

50 ms

< 10 ms

< 20 ms

Standard Port

1883 (8883 for TLS)

80 (443 for TLS)

5683 (5684 for DTLS)

5672 (5671 for TLS)

IETF Standard

Yes (v5: RFC 9326)

Yes (RFC 9110-9112)

Yes (RFC 7252)

Yes (v1.0: ISO/IEC 19464)

Ideal Use Case

Telemetry from constrained devices, bi-directional command/control

Web APIs, device management where HTTP is mandated

Very constrained sensor nodes (e.g., 6LoWPAN), simple GET/POST

Enterprise messaging, complex routing, financial transactions

MQTT

Frequently Asked Questions

Message Queuing Telemetry Transport (MQTT) is a foundational protocol for machine-to-machine communication in constrained environments. These FAQs address its core mechanics, security, and role in TinyML deployment pipelines.

Message Queuing Telemetry Transport (MQTT) is a lightweight, publish-subscribe messaging protocol designed for efficient machine-to-machine (M2M) communication in constrained environments with low bandwidth, high latency, or unreliable networks. It operates on a central broker model where clients connect as publishers, subscribers, or both. A publisher sends a message (a payload) to a specific topic (a hierarchical string like sensor/device123/temperature). The broker receives the message and forwards it to all clients that have subscribed to that topic. This decouples the data producers from the consumers, enabling scalable and flexible communication for IoT and edge computing systems.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.