What is Quality of Service?

The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message.

There are 3 QoS levels in MQTT:

  • At most once (0) [QoS0]
  • At least once (1) [QoS1]
  • Exactly once (2) [QoS2]

Why is Quality of Service important?

QoS is a key feature of the MQTT protocol. QoS gives the client the power to choose a level of service that matches its network reliability and application logic. Because MQTT manages the re-transmission of messages and guarantees delivery (even when the underlying transport is not reliable), QoS makes communication in unreliable networks a lot easier.

Quality of Service Level 0

QoS 0 is equivalent to the Best Effort Delivery Model, as discussed earlier. In this QoS, there is no guarantee of delivery as there is no Acknowledgment, nor retransmission by the sender. QoS 0 is used in the following two conditions.

  • Data is sent at very short intervals, thus loss of some messages are acceptable – Like weather monitoring, Pollution Monitoring, etc
  • You have a completely stable MQTT Connection and no chances of disconnected Client- Like connecting to an MQTT broker over Wired Connection.

 

Quality of Service Level 1

Quality Of Service Level 2