Device command delivery
QoS and retained messages solve different problems. QoS 1 repeats a message until the device acknowledges it. A retained message gives the 5 percent of devices that reconnect late the latest command.
See it on the board
The same traffic runs on two boards. The simulator measured both when this page was built.
| Measure | Goal | QoS 0, nothing retained | QoS 1 and a retained command |
|---|---|---|---|
| Lost writes | none | 146,667 Fail | 0 Pass |
| Durability | at least 100% | 0% Fail | 100% Pass |
| Monthly cost | 64 USD/mo | 64 USD/mo | |
| p99 latency | 14 ms | 26 ms | |
| Error rate | 0% | 0% |
Key numbers
| Number | Value |
|---|---|
| Header bytes for each MQTT message | 2 bytes |
| Acknowledgment round trips for MQTT | 1 RTT |
| Device round trip, slow end | 150 ms |
13 deliveries · 10 payments applied · 0 charged twice
How it works
A broker sends commands to devices over MQTT. A device can be offline: it sleeps to save power, or it has lost its link. Two features help, and they are not the same.
Quality of service level 1 tracks each message until the device sends an acknowledgment. If no acknowledgment arrives, the broker repeats the message. This covers messages that are lost on the way to a connected device. The device must handle a repeat, because the same command can arrive twice.
A retained message is stored by the broker for a topic. When a device subscribes later, the broker sends it the last retained message. This covers a device that was offline when the command was sent.
In the mini board one new state command goes to 200,000 devices. Five percent are offline until 0:10. With neither feature, those 10,000 devices never get the command, and the run has lost writes. With both, every device has the command after it reconnects.
A retained message keeps only the latest value. If the controller sends several commands, a late device sees only the last one. So retained messages suit state, such as on or off, and not a series of actions.
In the levels you turn on the features that each case needs and check that no device misses the final command.