It was 4:17 in the morning when my phone buzzed with a message from the operations manager at our energy monitoring client: "The same meter sent the same consumption reading 340 times overnight, and the billing team is losing their minds." We had 10,400 devices in the field and were processing an average of 4.2 million MQTT messages a day. Our duplicate rate normally hovered around 7 per thousand; that night it shot up to 11 percent. Same payload, same device, same timestamp — but 340 copies. My first reflex was the same as everyone's: "Something must have blown up in the broker."
Nothing had blown up. The broker was doing exactly what it had been asked to do. The problem was a decision made in a meeting room two years earlier that nobody had ever questioned: "Let's not lose any data — make everything QoS 1."
The Fine Print in QoS 1's Contract
On paper, MQTT's QoS levels look simple. QoS 0 is "fire and forget," QoS 1 is "at least once," QoS 2 is "exactly once." Most engineers read this trio like a quality scale: 0 is bad, 1 is okay, 2 is perfect. But that "at least" in QoS 1 isn't a guarantee — it's a threat. The protocol is telling you plainly: when the network gets bad, I will deliver this message twice, five times, 340 times if need be, and none of that will count as my fault.
Here's what happened that night: a GSM base station in the rural Aegean region had been taken down for maintenance, and our 600-odd devices in the area had fallen back to 2G. The device sends a PUBLISH, the message reaches the broker, the broker processes the data and returns a PUBACK — but the PUBACK was getting lost on the weak connection. When the device firmware didn't see a PUBACK, it counted the message as "not delivered" and resent it. Our retry interval was a fixed 8 seconds, with no cap on attempts. With the connection half-alive for 45 minutes, the math wrote itself: the data arrived every time, the acknowledgment never came back, and the counter climbed to 340.

Two Days Lost to the Wrong Hypothesis
I'll admit it: we spent the first two days blaming the broker. We combed through the EMQX logs, played with the inflight window settings, and even talked about upgrading the broker version. A teammate floated the hypothesis that "maybe the load balancer is silently dropping the TCP connection and the broker is writing the PUBACK to a dead socket"; it sounded so plausible that we spent another day chasing it. The LB idle timeout was 300 seconds and our keepalive was 60 — no problem there.
What showed us the truth was lining up a single device's modem logs, hour by hour, against the MQTT packet dump. We couldn't run tcpdump on the device side, but we added a temporary "send counter" to the firmware's telemetry. The result was clear: the device had sent 340 times, the broker had received 340 times, and the device had seen 0 PUBACKs. Asymmetric link quality — the uplink works, the downlink is garbage. On 2G, this happens far more often than you'd think. The device wasn't lying; there was simply a truth nobody had told it.
The Other Edge of the Persistent Session
The duplicate story didn't end there. Our devices used persistent sessions (Clean Session = false), because we didn't want configuration messages sent on the command channel while a device was offline to get lost. Reasonable. But when the base station maintenance ended, 600 devices reconnected within a 4-minute window, and the broker started replaying the inflight messages waiting in each of their sessions with the DUP flag set. The reconnect storm and the redelivery storm piled on top of each other; the broker's outbound queue hit 9,000 messages per second, and our backend consumers fell 11 minutes behind.
At this point we seriously discussed QoS 2. On paper it was the solution: a four-way handshake, guaranteed uniqueness. In the field it was a disaster. In testing, QoS 2 on a 2G connection added an average of 2.8 seconds of extra latency per message and 60 percent more radio wake time — eating 8-9 percent of battery life a year. On top of that, when a PUBREL got lost, the message hung in a gray zone of uncertainty for both sides. In a fleet of 10,000 devices, QoS 2 created a bigger problem than the one it solved.

The Right Question: What Breaks If This Message Arrives Twice?
In the end, we put the right question on the table. Not "which QoS is better?" but "what breaks if this message is processed twice, and what breaks if it never arrives?" We split our topics into three classes based on those two questions and wrote a separate contract for each class.
Real-time status data — temperature, signal strength, battery — dropped to QoS 0. This data is refreshed every 30 seconds anyway; losing one reading changes nothing, and neither does getting one twice. That single change took 55 percent of total traffic out of the retry mechanism and took 30 percent of the load off the broker's CPU.
Meter readings and alarms stayed on QoS 1, but on one condition: end-to-end idempotency. We added a monotonic sequence number generated on the device to every message, combined with the device ID into a deduplication key. In the backend, the ingestion layer keeps that key in Redis for a 24-hour window; duplicates increment a counter and are silently dropped. The duplicate rate is still 7 per thousand — but it no longer shows up on anyone's bill; it just lives on as a network-health indicator on a Grafana panel. We didn't try to eliminate duplicates; we made them measurable and harmless.
The command channel stayed on QoS 1 + persistent sessions, but we used MQTT 5's Session Expiry Interval feature to cut session lifetime from infinite to 4 hours, and we gave commands an application-level expiry time. A device that has been offline for three days receiving a stale "turn off the relay" command the moment it powers back on is no joke in an energy system.

Retry Policy Is an Architectural Decision Too
We also overhauled the retry strategy on the firmware side: instead of a fixed 8 seconds, exponential backoff at 8-16-32-64 seconds, with plus or minus 25 percent jitter on top, and a maximum of 6 attempts in total. If the attempts run out, the message goes into the device's local queue and is sent in a batch sync once the connection has seen a healthy PINGRESP. To smooth out reconnect storms, we added a deterministic jitter derived from the device ID to the reconnect delay; 600 devices now come back spread over 20 minutes instead of 4. The reconnect peak on the broker dropped from 41 connections per second to 9.
Three months after all of these changes went live, the same region had another base station maintenance. This time my phone didn't ring; when I checked the dashboard in the morning, all I saw was that the duplicate indicator had turned yellow for a few hours and gone back to green on its own. The incident had stopped being an incident.
If I could give just one piece of advice to someone building an MQTT architecture today, it would be this: don't think of QoS as a quality setting; think of it as a contract signed separately for each topic, and put that contract's costs — battery, bandwidth, duplicates, latency — on the table in plain sight. If you're wrestling with a similar problem across thousands of devices in the field and the sentence "we made everything QoS 1 and weird things are happening" sounds familiar, write to me; I can probably tell you within minutes what you're experiencing looks like in the log files, because I once sat staring at those very same lines.
Devices don't lie. They just remind those of us who don't read the protocol's fine print of the contract we signed — usually just before dawn, and in 340 copies.