MQTT Quality of Service (QoS) is a delivery agreement between a message sender and the broker. It has three levels: QoS 0 at most once, QoS 1 at least once and QoS 2 exactly once. Each level adds reliability and also adds network overhead, latency and power use.
Key takeaways
- Definition: MQTT QoS sets the delivery guarantee between a publisher and the broker across 3 levels.
- Trade-off: Higher levels add reliability and also add packets, latency and power use.
- Most used: QoS 1 balances guaranteed delivery with acceptable overhead in most production systems.
- Rule: Match QoS to data criticality: QoS 0 for telemetry, QoS 1 for commands, QoS 2 for critical transactions.
- Dev Station: Dev Station designs MQTT messaging layers and IoT platforms for teams in the US and UK.
What is MQTT QoS?
MQTT Quality of Service (QoS) is a delivery agreement between a message sender and the broker that defines how much effort both sides invest in ensuring a message arrives. It is the primary mechanism for controlling reliability versus performance in any MQTT-based IoT system.
Devices in IoT networks operate under unpredictable conditions, intermittent cellular coverage, congested Wi-Fi, and constrained battery life. MQTT was designed for these environments, and QoS is its core reliability control. The protocol offers exactly three levels, and every message is tagged with one of them. The level you choose directly impacts whether messages can be lost, duplicated, or delivered with absolute certainty.
QoS is negotiated independently for each publish operation. A publisher sets the QoS level on outbound messages, and a subscriber requests a QoS level when subscribing. The broker enforces the lower of the two, so a subscriber asking for QoS 1 receiving a QoS 2 publish will get QoS 1 delivery guarantees. This per-message granularity lets you mix reliability levels within a single application, sending sensor readings at QoS 0 while commanding actuators at QoS 1, for example.
What are the 3 MQTT QoS levels?
The three levels are QoS 0 (at most once), QoS 1 (at least once), and QoS 2 (exactly once), each with a different message handshake.
Each QoS level defines a specific message handshake between client and broker. Higher levels add more round-trip packets to eliminate delivery failures, but at a direct cost to throughput, latency, and device battery life.
QoS 0, At Most Once
Fire-and-forget delivery. The sender transmits a single PUBLISH packet and moves on immediately. No acknowledgment is expected or retransmission attempted. If the packet is lost, the message is simply gone.
Packet flow: PUBLISH → (1 packet, 1x baseline overhead)
Best for: High-frequency telemetry where individual readings are disposable, ambient temperature, humidity, air quality indexes reported every few seconds.
QoS 1, At Least Once
Acknowledged delivery. The sender transmits PUBLISH with a Packet Identifier and stores the message until it receives a PUBACK from the broker. If the acknowledgment never arrives, the sender retransmits. This guarantees delivery but allows duplicates.
Packet flow: PUBLISH → ← PUBACK (2 packets, ~2x overhead)
Best for: Commands and alerts where delivery matters but duplicates are harmless, turning on a light, triggering a notification, updating a display state.
QoS 2, Exactly Once
The highest assurance level. A four-part handshake eliminates both message loss and duplication. The sender publishes, the receiver acknowledges receipt (PUBREC), the sender releases (PUBREL), and the receiver confirms completion (PUBCOMP). Both sides maintain state throughout, so a lost packet at any stage triggers retransmission without risking a duplicate.
Packet flow: PUBLISH → ← PUBREC → PUBREL → ← PUBCOMP (4 packets, ~4x overhead)
Best for: Mission-critical transactions where duplicates cause real harm, financial operations, medication dispensing, robotic arm control, door-lock commands in security systems.
How do the MQTT QoS levels compare?
The levels differ in delivery guarantee, packet count, latency, power consumption, and implementation complexity.
The following table maps each QoS level against the five dimensions that matter most when architecting an IoT messaging system: delivery guarantee, network overhead, latency, power consumption, and implementation complexity.
| Dimension | QoS 0: At Most Once | QoS 1: At Least Once | QoS 2: Exactly Once |
|---|---|---|---|
| Delivery Guarantee | No guarantee, message may be lost | Guaranteed at least once, duplicates possible | Guaranteed exactly once, no loss, no duplicates |
| Packet Count | 1 (PUBLISH only) | 2 (PUBLISH + PUBACK) | 4 (PUBLISH + PUBREC + PUBREL + PUBCOMP) |
| Relative Overhead | 1x (baseline) | ~2x | ~4x |
| Latency | Lowest, single one-way trip | Medium, one round-trip for acknowledgment | Highest, two full round-trips |
| Power Consumption | Lowest | Medium | Highest, significant for battery-powered devices |
| Implementation Complexity | Simplest, send and forget | Requires duplicate handling (idempotent design) | Most complex, both sides must track transaction state |
| Recovery on Failure | None. Message is gone | Automatic retransmission until PUBACK received | Automatic retransmission at any handshake stage |
Key insight: Moving from QoS 0 to QoS 2 results in a 300% increase in network packets per message. For a battery-powered sensor sending 500 messages per day, this directly translates into measurably shorter field life, choose the lowest level that satisfies your reliability requirement.
When should you use each MQTT QoS level?
Use QoS 0 for non-critical frequent telemetry, QoS 1 for commands where duplicates are harmless, and QoS 2 only where loss and duplication are both unacceptable.
There is no single best QoS level, only the right level for your specific data type, device constraints, and network conditions. The three factors below determine the optimal choice.
Choose QoS 0 When
Data is non-critical and frequently updated. Losing a single reading has no business impact because the next reading arrives within seconds. Devices are severely constrained (small battery, low bandwidth). Examples: ambient temperature telemetry, humidity reports, GPS pings on a moving vehicle, occupancy counts.
Choose QoS 1 When
Delivery must be confirmed, but a duplicate message causes no harm (the operation is idempotent). This covers the majority of IoT commands: set a relay to ON, update a thermostat setpoint, trigger an alert notification, log an event. QoS 1 is the most widely deployed level in production IoT systems.
Choose QoS 2 When
Both message loss and duplication are unacceptable. A duplicate financial transaction, a repeated medication dose, or a second open up command on a security door could cause real damage. Reserve QoS 2 strictly for these mission-critical operations. Its overhead makes it impractical for routine telemetry.
Network Conditions Matter
On stable wired or strong Wi-Fi networks, QoS 0 risks are lower. On cellular or LPWAN links with frequent dropouts, QoS 1+ retransmission becomes essential. Match the guarantee level to the packet loss rate, not just the business criticality of the data.
Decision rule: If losing a message has no impact, use QoS 0. If losing a message is unacceptable but duplicates are harmless, use QoS 1. If duplicates would cause a system failure, use QoS 2.
How do you implement MQTT QoS and what are the best practices?
Set the qos parameter in the publish call of your MQTT client, and follow production practices such as idempotent subscribers and persistent sessions.
Implementing QoS in code is straightforward, set the qos parameter in your MQTT client publish call. The handshake logic is handled entirely by the library. Below is a practical reference using the Paho MQTT client for Python, followed by key practices for production systems.
Code Reference
import paho.mqtt.client as mqtt
client = mqtt.Client("publisher_id")
client.connect("broker.example.com", 1883)
client.loop_start()
# QoS 0: high-frequency, non-critical telemetry
client.publish("iot/sensor/temperature", payload="23.5", qos=0)
# QoS 1: command that must arrive (idempotent)
client.publish("iot/device/command", payload="TURN_ON", qos=1)
# QoS 2: mission-critical transaction (exactly once)
client.publish("iot/system/payment", payload="TXN_12345", qos=2)
client.loop_stop()
client.disconnect()
Production Best Practices
- Design for idempotency at QoS 1. Since duplicates are possible, every subscriber receiving QoS 1 messages must handle them safely. Use unique message IDs or timestamps to deduplicate, or ensure the operation is naturally idempotent (setting a state to ON twice has the same result as setting it once).
- Set QoS per topic, not globally. Different data types within the same application have different reliability needs. Publish telemetry at QoS 0 and commands at QoS 1 on separate topics rather than applying one level to everything.
- Reserve QoS 2 sparingly. The four-packet handshake quadruples network traffic and CPU load. Use it only where the cost of a duplicate genuinely exceeds the overhead. Most production IoT systems run almost entirely on QoS 0 and 1.
- Use persistent sessions for QoS 1/2. Enable
clean_session=Falseso the broker stores undelivered messages and pending acknowledgments across client reconnects. Without this, messages queued during an offline period are lost. - Monitor duplicate rates as a network health signal. A rising duplicate rate at QoS 1 indicates PUBACK packets are being lost, a sign of network degradation. Use this metric to trigger alerts before message delivery is affected.
Warning: On battery-powered devices, QoS 2 can shorten operational life noticeably compared to QoS 0 for the same message volume. Always profile power consumption with your actual hardware and message frequency before committing to QoS 2 in production.
What are the next steps for applying MQTT QoS?
Audit message types, implement idempotent subscribers, enable persistent sessions, and profile packet loss, duplicates, and battery impact.
Applying the right QoS level is one of the highest-use architectural decisions in an IoT system, it affects reliability, latency, device battery life, and infrastructure costs simultaneously. The steps below give you a practical path from assessment to production.
- Audit your current message types. List every topic in your system and classify each as non-critical telemetry, important command, or mission-critical transaction. Assign QoS 0, 1, or 2 accordingly.
- Implement idempotent subscribers. For every topic at QoS 1, verify that duplicate messages cannot cause incorrect state. Add deduplication logic using message IDs or timestamps if the operation is not naturally idempotent.
- Enable persistent sessions. Set
clean_session=Falseon devices that receive QoS 1 or 2 messages so the broker buffers messages during offline periods and resumes delivery on reconnect. - Profile and optimize. Measure actual packet loss, duplicate rates, and battery impact on representative hardware. Adjust QoS levels down where the measured network reliability is higher than assumed.
Need help architecting your MQTT messaging layer? Dev Station Technology designs and builds production-grade IoT platforms, from protocol selection and QoS strategy to broker infrastructure and device firmware. Contact our team at sale@dev-station.tech for a technical consultation.
Frequently asked questions
Five questions come up most often on this topic.
Who sets the QoS level?
The publisher sets it on outbound messages, a subscriber requests one when subscribing, and the broker enforces the lower of the two.
Why design subscribers to be idempotent at QoS 1?
Duplicates are possible at QoS 1, so a repeated message must not corrupt state.
What is a persistent session?
Setting clean_session to false makes the broker store undelivered messages and pending acknowledgments across client reconnects.
Why set QoS per topic?
Different data has different reliability needs, so publish telemetry at QoS 0 and commands at QoS 1 on separate topics.
What does a rising duplicate rate mean?
At QoS 1 it suggests PUBACK packets are being lost, which signals network degradation.
Dev Station Technology designs production-grade MQTT messaging layers and IoT platforms for teams in the United States and the United Kingdom, from protocol selection and QoS strategy to broker infrastructure and device management. Contact dev-station.tech or sale@dev-station.tech. Device and telemetry data stays in your own cloud tenant, in the region your policy requires. Where a client needs SOC 2, HIPAA or UK GDPR evidence, we build the technical controls those frameworks ask for and work alongside the assessor who issues the certificate. Our engineers work from Vietnam with overlap into US Eastern, US Pacific and UK GMT hours, and we invoice in USD or GBP.
Want an AI assistant to summarize or cite this guide?
Click any link below to open the AI with a pre-filled prompt referencing this article:
Talk To Us
Tell us what you are building and what it has to connect to. An engineer answers, and you get a straight view of what the work would take.
Get In Touch →