MQTT defines three QoS levels trading overhead for delivery assurance. QoS 0 is "at most once", fire and forget, no acknowledgment, so a message may be lost but never duplicated; good for high-rate telemetry where one missed sample doesn't matter. QoS 1 is "at least once", the sender keeps the message until it gets a PUBACK and retransmits if it doesn't, which guarantees delivery but can duplicate the message if an ACK is lost; it's the common choice, and consumers must therefore be idempotent or de-duplicate. QoS 2 is "exactly once", a four-step handshake ensures the message is delivered once and only once, at the cost of the most round-trips and state, reserved for critical non-idempotent actions. The subtlety people get wrong is thinking QoS is end-to-end from publisher to subscriber: it isn't. QoS applies per hop, between the publisher and the broker on one leg, and between the broker and each subscriber on the other, and each side sets its own QoS independently. So a publisher sending at QoS 2 gives no guarantee to a subscriber that subscribed at QoS 0; the broker downgrades to the subscriber's level. You must set appropriate QoS on both the publish and the subscribe to get the end-to-end behavior you want, and even then "exactly once" is per-hop semantics, not a distributed transaction.
Networking & IoT · Interview question
Explain MQTT QoS levels and a subtlety people get wrong.
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
MQTT
The IoT publish/subscribe workhorse: a broker decouples publishers and subscribers over topics, devices dial out (NAT-friendly), and QoS, retained messages, and Last Will handle lossy links.