What is MQTT?

Definition

MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for low-bandwidth, high-latency, or unreliable networks. It facilitates communication between devices, particularly in the IoT (Internet of Things) ecosystem, where efficient and reliable data transfer is critical.


Key Characteristics

  • Lightweight Design: Ideal for constrained devices and low-bandwidth situations.
  • Publish/Subscribe Model: Allows devices to communicate without direct knowledge of each other, promoting decoupled systems.
  • Efficient Bandwidth Usage: Optimized for minimal overhead in message exchanges.
  • Quality of Service (QoS) Levels: Provides configurable message delivery guarantees.
  • Stateful Session Management: Supports persistent connections to reduce latency for continuous interactions.

Core Features

  1. Topic-Based Addressing: Uses topics for routing messages, allowing hierarchical and flexible structures.
  2. Quality of Service (QoS):
    • Level 0: At most once (no acknowledgment).
    • Level 1: At least once (acknowledged delivery).
    • Level 2: Exactly once (ensures single delivery without duplication).
  3. Retained Messages: Retains the last message sent to a topic for new subscribers.
  4. Will Messages: Sends a last message when a client disconnects unexpectedly.
  5. Minimal Overhead: Compact header size and lightweight protocol design.

Use Cases

  • IoT Applications: Communication between sensors, devices, and applications.
  • Remote Monitoring: Collecting data from distributed devices for analysis.
  • Smart Homes: Controlling and monitoring appliances like lights, thermostats, and cameras.
  • Healthcare: Real-time updates from medical devices.
  • Automotive: Vehicle-to-cloud data communication for diagnostics and updates.

Comparison to Traditional Methods

AspectMQTTHTTP/REST APIs
Communication ModelPublish/SubscribeRequest/Response
Bandwidth EfficiencyHighly efficientRelatively higher overhead
Connection TypePersistentStateless
Delivery GuaranteesQoS levels for reliabilityLimited to TCP/IP layer guarantees
LatencyLower latency with persistent sessionsHigher due to connection setup and teardown

NATS, in contrast, offers broader patterns (e.g., streaming, request-reply, and KV store) with simpler configuration and global scalability, making it ideal for dynamic edge-to-cloud scenarios.


Associated Components and Interoperation

  • MQTT Brokers: Central to managing connections and routing messages (e.g., Mosquitto, EMQX).
  • MQTT Clients: Devices or applications using MQTT libraries for communication.
  • Bridge to Other Protocols:
    • Integrates with NATS for edge computing, offering improved performance, reduced operational complexity, and global availability.
    • Connects with REST APIs for legacy systems.

Frequently Asked Questions

MQTT vs NATS for IoT fleet management — which is better?

NATS is better suited for fleet-scale IoT requiring bidirectional communication, command-and-control, and multiple messaging patterns on one connection. MQTT works well for constrained single-purpose sensors with simple telemetry and minimal client footprint. For workloads needing request-reply, multi-tenancy, or edge persistence, NATS provides these natively. Compare NATS and MQTT in detail

When should I use NATS instead of MQTT for IoT applications?

NATS is the stronger choice when your IoT application needs request-reply or multi-tenancy. It also provides reliability beyond QoS 1 and edge-local persistence via JetStream. NATS decentralizes routing across a mesh cluster rather than relying on a single broker. If any of these requirements apply, NATS handles them natively without additional tooling. See the full NATS vs MQTT comparison

What problems does MQTT have at scale?

NATS addresses several scaling limitations inherent in MQTT, including central broker bottlenecks and ACL synchronization complexity. MQTT also suffers from QoS 2 performance degradation at scale. It lacks native request-reply, requiring workaround topic patterns for bidirectional communication. Credential management and access control become operationally difficult as the number of connected devices grows. Read the technical comparison

Why are companies replacing MQTT with NATS for industrial IoT?

NATS offers a unified namespace without broker lock-in and decentralized security via NKeys and JWTs. It requires no central auth server and includes built-in persistence through JetStream. NATS runs as a single binary with no JVM or Erlang runtime dependency. These properties reduce operational complexity compared to managing MQTT broker clusters at scale. Learn more about NATS for manufacturing

What quality of service levels does NATS provide compared to MQTT?

NATS provides three delivery guarantee tiers that map roughly to MQTT QoS levels. Core NATS delivers at-most-once (similar to MQTT QoS 0) — messages are relayed to connected subscribers with no storage or buffering. Late subscribers never see previously published messages. The request-reply pattern adds application-level at-least-once by having receivers acknowledge messages, though late subscribers still miss them. JetStream provides native at-least-once delivery (similar to MQTT QoS 1) — messages are persisted in memory or on disk, publishers receive an ACK from the NATS server itself, and subscribers can connect later to replay messages. For exactly-once, NATS supports partial exactly-once delivery using message deduplication combined with double acknowledgments in JetStream. Exactly-once processing is more practical — consumers track message sequence IDs or the Nats-Msg-Id header to ensure duplicate deliveries are not processed twice. Learn more about JetStream delivery models

How can I authenticate MQTT clients connecting to NATS without requiring a seed?

NATS normally authenticates users with a JWT token plus a seed, where the seed signs a nonce provided by the server during connection. MQTT clients only support username and password fields — they cannot perform the additional nonce-signing step. The --bearer flag when creating NATS users solves this by indicating that only the JWT is required for authentication. Bearer-flagged users authenticate by supplying the JWT as the password with any non-empty arbitrary username. This was specifically introduced when NATS added native MQTT support. Bearer-only tokens should not be used with native NATS clients, since they skip the nonce-signing security step. However, if you need to use NATS user credentials for authenticating with other non-NATS servers, bearer tokens provide a compatible option. Learn more about NATS MQTT configuration

Last updated: March 2026


Additional Resources

  • Official MQTT Website
  • Books:
    • “MQTT Essentials” for a foundational understanding.
  • Community and Tutorials:
    • MQTT community forums and open-source brokers like Mosquitto.
  • Videos:

By leveraging protocols like MQTT alongside modern messaging systems such as NATS, developers can build scalable, real-time systems capable of handling diverse workloads efficiently.

Ready to get started with NATS?

Try Synadia Cloud for free
Cancel