What is QoS Levels MQTT?
Updated: Oct 27

MQTT Quality of Service, or QoS, defines how a message is delivered between one MQTT sender and one receiver. The three levels are QoS 0, at most once; QoS 1, at least once; and QoS 2, exactly once within the protocol exchange. They differ in acknowledgement, recovery state and overhead. They do not set the priority of your broadband traffic or prove that an application has completed a command.
The distinction matters for home automation, monitoring and connected equipment. A fresh temperature reading, a recorded meter event and a command that changes a device can have different failure costs. The right choice depends on what missing, duplicated or late information would mean, together with the session, storage and application behaviour around the MQTT exchange.
MQTT QoS is a delivery agreement, not router traffic priority
In MQTT, clients publish messages to a broker, which routes them to matching subscribers. A publisher-to-broker exchange and a broker-to-subscriber exchange are separate delivery relationships. Each has its own sender, receiver and acknowledgement state.
Our MQTT guide explains that wider publish-and-subscribe model. QoS adds delivery rules to each exchange; it does not turn the broker into a guaranteed transaction coordinator for every downstream service. A publisher can finish its exchange with the broker before a subscriber completes its own application work.
The MQTT 5.0 OASIS Standard defines the three levels and their protocol flows. This article uses MQTT 5 terminology unless it explicitly says otherwise. MQTT 3.1.1 also has QoS 0, 1 and 2, but some session controls and error reporting differ, so configuration advice must match the actual protocol version.
Level | Meaning and normal successful exchange |
|---|---|
QoS 0 | At most once: PUBLISH, with no MQTT acknowledgement. |
QoS 1 | At least once: PUBLISH followed by PUBACK. Duplicate delivery is possible. |
QoS 2 | Exactly once for the single protocol exchange: PUBLISH, PUBREC, PUBREL and PUBCOMP, with additional state. |
These are MQTT control packets, not necessarily individual IP packets. An underlying stream transport can combine or divide bytes differently. Nor is MQTT QoS the same control as a router’s traffic scheduling or bandwidth-management feature, even when both use the abbreviation QoS.
QoS 0: send the current information without an MQTT receipt
A QoS 0 sender transmits PUBLISH and receives no MQTT acknowledgement for that message. MQTT does not retain an unacknowledged QoS 0 exchange for later protocol retry. The receiver obtains the message once or not at all under this service.
That does not mean every lost network packet automatically becomes a lost MQTT message. MQTT normally runs over an ordered stream such as TCP, which has its own recovery mechanisms while the connection can make progress. The TCP guide explains why transport recovery and application-message delivery are different layers.
QoS 0 can be reasonable for frequent readings where a new observation quickly replaces an old one and a missing sample is acceptable. For example, a dashboard may prefer the latest temperature over a backlog of stale readings. That is an application decision, not a promise that QoS 0 messages can never be delayed.
It is a poor fit when an individual event must be accounted for and there is no other recovery route. A reliable network also does not remove every failure window: a client can stop, a connection can break or a receiver can reject work above the transport layer.
QoS 1: obtain acknowledgement and plan for duplicates
QoS 1 associates the PUBLISH with a Packet Identifier. The receiver responds with PUBACK after accepting responsibility under the protocol. The sender keeps track of the unacknowledged exchange until the corresponding result arrives.
Duplicates can occur when delivery and knowledge of delivery become separated. Imagine that a receiver accepts a message but the connection fails before the sender learns the result. When the appropriate session resumes, resending an unacknowledged publication can deliver the same application information again. The application must be able to handle that possibility.
The crucial distinction is what the receipt means. A broker can acknowledge its responsibility before onward application delivery has finished. PUBACK is therefore not evidence that a device has moved, an alarm has been handled or a database has committed a record.
For business events or commands, include a stable application operation identifier where the protocol design permits it. The Idempotency guide explains how repeated requests can produce one intended effect. A temporary MQTT Packet Identifier should not be used as a permanent business-event identity, because it can be reused once its exchange is complete.
The DUP flag is not a universal duplicate detector
DUP describes retransmission of a PUBLISH packet within the relevant MQTT handling. It does not certify that a subscriber has or has not already acted on the same business event. The broker’s outgoing exchange is separate, and an application can publish equivalent content again as a new message.
Overlapping subscriptions also deserve attention. One publication can match several topic filters, and the specification permits certain additional deliveries for those matches. A consumer should not build its entire duplicate policy around a single packet flag or assume that every repeat proves a broken broker.
QoS 2: prevent duplicate delivery within a stateful exchange
The normal successful QoS 2 flow has four control packets. The sender transmits PUBLISH; the receiver returns PUBREC; the sender sends PUBREL; and the receiver returns PUBCOMP. Packet Identifiers and stored exchange state allow the endpoints to recognise the stages of that delivery.
If a receiver sees a repeated QoS 2 PUBLISH for the same still-active exchange, it responds according to the saved state rather than causing duplicate onward delivery. After the sender has advanced to PUBREL, recovery continues from that stage rather than sending the original PUBLISH again. The protocol must preserve the distinction between an incomplete exchange and a new publication.
Exactly once is consequently a statement about this defined delivery protocol. It is not a blanket guarantee that a real-world action happens exactly once across client restarts, broker failures, external databases and application retries. A subscriber can receive a message and then fail at a different point in processing its side effect.
For a command such as “record this event”, the receiving application may need to validate an operation identifier, perform the change and store a result consistently. The sender may need a separate application response that identifies that operation. QoS 2 does not automatically make those steps one atomic transaction.
The extra exchange also costs more state and feedback than QoS 0 or 1. That does not justify a universal performance multiplier: implementations can pipeline messages, network delay varies and payload sizes matter. Measure the actual workload if the difference is operationally important.
The broker handles the subscriber hop separately
The publication’s QoS and a subscription’s granted QoS constrain onward delivery. Requesting QoS 2 in a subscription does not upgrade a publication that arrived at QoS 0. Equally, publishing at QoS 2 does not force a subscriber that has a QoS 0 subscription to receive a QoS 2 exchange.
For a simple example, suppose a publisher sends at QoS 2 and three matching subscriptions are granted maximum levels 0, 1 and 2. Their outgoing delivery can use those respective levels. The publisher’s completed QoS 2 exchange with the broker does not turn all three subscriber relationships into QoS 2.
Check the subscription acknowledgement rather than assuming the requested level was granted. MQTT 5 also allows a broker to advertise a Maximum QoS capability. A client must respect that limit when publishing. A configuration that selects level 2 everywhere can still be incompatible with the connected service.

Sessions, reconnects and restarts change the result
QoS 1 and 2 depend on state associated with a Client Identifier. In MQTT 5, Clean Start and Session Expiry Interval control important parts of how that state begins and survives connection changes. Resuming a session requires more than simply opening another socket with roughly similar settings.
MQTT 5’s required resend behaviour applies when reconnecting with Clean Start set to 0 and an existing session present. Unacknowledged QoS 1 or 2 PUBLISH packets and PUBREL packets are resent using their original identifiers as applicable. Do not apply a generic “resend every few seconds until acknowledged” description to an otherwise live MQTT 5 connection.
The Reconnection Handling guide describes why a recovered network path and a recovered application session are different outcomes. If a new session replaces the old one, or the previous session has expired, the endpoints cannot assume that all previous exchange state remains available.
A process restart is another boundary. Eclipse Paho’s current Python documentation identifies limitations around client session state held in memory and certain republishing behaviour. These are implementation-specific warnings to inspect for the chosen library and mode. One boolean option should not be presented as a universal cure for message loss or duplicate effects.
Broker storage needs the same attention. The Mosquitto configuration reference documents persistence and queue-related controls. Whether a session survives a broker restart or a sudden failure depends on the implementation, storage settings and what has actually been saved. A QoS label does not make volatile memory durable.
Expiry, retained messages and errors are separate controls
Message Expiry Interval can remove a waiting MQTT 5 message copy when the broker has not started onward delivery before its lifetime expires. Session expiry concerns the lifetime of session state instead. Neither should be confused with the time by which a device must complete an action.
Retained messages solve another problem: providing a stored topic value to relevant future subscriptions. Retain is not a complete event history and does not replace offline-session handling. Decide whether a message represents current state or a historical event before combining these features.
An acknowledgement packet is not automatically a successful result. MQTT 5 PUBACK and PUBREC can contain reason codes indicating rejection or other outcomes. For example, a message can fail authorisation or a quota check. Applications should inspect the result exposed by their library rather than only observing that a callback ran.
Receive Maximum limits outstanding QoS 1 and 2 publications through MQTT flow-control rules. It is a count of messages under those rules, not a TCP byte window or an internet speed setting. Queue capacity, message sizes and a slow consumer can still constrain progress.
An original comparison of MQTT control bytes
Techie Broadband constructed a small MQTT 5 encoding example in Python 3.12.14 to make the overhead concrete. The topic is s/t, three UTF-8 bytes, and the payload is 21.5, four ASCII bytes. The publication has no properties or Topic Alias, and its Remaining Length fits in one byte. QoS 1 and 2 use Packet Identifier 1.
The QoS 0 PUBLISH contains two fixed-header bytes, a two-byte topic length, the three-byte topic, a one-byte zero property length and the four-byte payload: 12 bytes altogether. Adding a two-byte Packet Identifier makes the QoS 1 or 2 PUBLISH 14 bytes. Each compact successful acknowledgement packet in this example is four bytes.
Example flow | MQTT bytes across one exchange |
|---|---|
QoS 0 | 12-byte PUBLISH = 12 bytes. |
QoS 1 | 14-byte PUBLISH + 4-byte PUBACK = 18 bytes. |
QoS 2 | 14-byte PUBLISH + three 4-byte responses = 26 bytes. |
The script encoded the control packets and checked these lengths. This was an encoding calculation, not a broker interoperability test or a capture of broadband traffic. It excludes connection setup, subscriptions, TCP/IP, TLS, retransmissions and the broker’s outgoing subscriber exchange. Different topics, payloads and properties change the totals.
The practical insight is the proportion. For a tiny payload, control information can be a substantial share of the MQTT bytes. For a large payload, the same small acknowledgements form a smaller share. Packet counts alone do not establish latency, energy use or achieved throughput.
Choose QoS from the consequence of failure
Information or action | Questions that guide the choice |
|---|---|
Frequently replaced sensor state | Can the next fresh sample replace a missing one? Is stale backlog less useful than current state? |
An event that must be recorded | How will missing events be recovered, duplicates recognised and storage confirmed? |
A command with a side effect | Can the action be repeated safely? Is there a stable operation ID and a meaningful result response? |
An intermittently connected subscriber | Will its session and queued messages survive the expected outage and restart conditions? |
Start with those questions rather than treating level 2 as a general “best” setting. QoS 0 can suit replaceable observations. QoS 1 is useful when acknowledged delivery and duplicate-tolerant processing fit the job. QoS 2 can address duplicate delivery within the MQTT exchange when both endpoints support and preserve the necessary state.
Define acceptable loss, duplication and staleness separately for each message class.
Choose session and persistence policies alongside the QoS level, not after a failure.
Keep application operation identifiers and result semantics independent of MQTT Packet Identifiers.
Test interruption and restart cases in a controlled environment using the actual client and broker versions.
A practical MQTT QoS diagnostic sequence
A UK broadband interruption can expose weak session handling, but not every missing message starts with the access line. Distinguish failure to publish, rejection by the broker, expiry in a queue, subscription mismatch and failure inside the consuming application.
Record the MQTT version, client and broker versions, publish QoS and actual granted subscription QoS.
Check connection and publication results, including MQTT 5 reason codes and broker capability limits.
Verify Client Identifier, Clean Start or Clean Session settings, session expiry and whether the session was resumed.
Inspect persistence, queue limits and message expiry on both relevant endpoints. Separate reconnect tests from process and broker restart tests.
Trace a stable application message or operation identifier through publish, broker routing, subscriber receipt and final result. Check duplicates without relying only on DUP.
Retest the intended workload on a suitable wired path, then under controlled load and an authorised interruption. Confirm the application outcome, not just a protocol acknowledgement.
Latency under load can help explain why acknowledgements or application responses slow down while a connection is busy. It cannot, by itself, identify lost session state or a rejected message. Keep timestamps and relevant counters so the network observations can be compared with the MQTT and application evidence.
Frequently asked questions
Does QoS 2 guarantee that a command runs exactly once?
No. It prevents duplicate delivery within the defined MQTT exchange using protocol state. The application still needs suitable operation identity, processing and result handling for exactly-once effects across its own failure boundaries.
Can a QoS 2 subscription upgrade a QoS 0 publication?
No. A subscription’s QoS is a delivery constraint, not a way to add the missing publication-side exchange. Inspect both the incoming publication level and the granted subscription level.
Does QoS 0 mean TCP stops retransmitting?
No. MQTT QoS and TCP recovery operate at different layers. QoS 0 omits an MQTT-level acknowledgement and retry exchange; it does not disable TCP’s transport mechanisms.
Will QoS 1 or 2 preserve messages through every restart?
Not automatically. Session lifetime, client and broker persistence, library behaviour and application storage all matter. Verify the actual restart scenario rather than assuming that a delivery level makes all state durable.
What to remember
MQTT QoS is most useful when its boundary is clear. It controls a message exchange between adjacent endpoints; sessions and storage preserve the state around it, while the application decides whether the intended work happened. Choose the level that fits the cost of loss and duplication, then verify the complete route from publication to meaningful result.

