Scenario: A hospital patient monitoring system sends three types of messages via MQTT: vital signs (heart rate, BP), equipment status, and diagnostic logs. The network team must assign QoS levels.
Given Data:
- Vital signs: 240 messages/hour per patient (every 15 seconds), 50 patients = 12,000 msg/hr
- Equipment status: 12 messages/hour per device, 200 devices = 2,400 msg/hr
- Diagnostic logs: 5 messages/hour per system, 20 systems = 100 msg/hr
- Network: Hospital WiFi with occasional 5-10 second glitches
- Message sizes: Vitals 80 bytes, Status 120 bytes, Logs 500 bytes
Step 1: Analyze criticality and loss tolerance
Vital signs: - Loss tolerance: ZERO for critical alerts (heart rate <40 or >120 bpm) - Routine readings: Missing 1-2 readings acceptable (next arrives in 15 seconds) - Duplicate tolerance: LOW (processing duplicate heart rate could trigger false alert)
Equipment status: - Loss tolerance: LOW (must know if ventilator fails) - Duplicate tolerance: MEDIUM (idempotent state updates)
Diagnostic logs: - Loss tolerance: MEDIUM (helpful for debugging, not critical) - Duplicate tolerance: HIGH (logs are informational)
Step 2: Calculate bandwidth for each QoS level
QoS 0 overhead: 1× message size (no ACK) QoS 1 overhead: ~1.5× (PUBLISH + PUBACK) QoS 2 overhead: ~2.5× (PUBLISH + PUBREC + PUBREL + PUBCOMP)
Vitals with QoS 2: 12,000 × 80 bytes × 2.5 = 2,400 KB/hr Status with QoS 1: 2,400 × 120 bytes × 1.5 = 432 KB/hr Logs with QoS 0: 100 × 500 bytes × 1.0 = 50 KB/hr Total bandwidth: 2,882 KB/hr = 0.8 KB/sec
WiFi capacity: 54 Mbps = 6,750 KB/sec MQTT overhead: 0.8 ÷ 6,750 = 0.01% (negligible)
Step 3: Assign QoS levels with rationale
| Critical vitals (HR <40 or >120) |
QoS 2 |
Zero tolerance for loss or duplicate critical alerts |
| Routine vitals |
QoS 1 |
At-least-once acceptable, dedupe at receiver |
| Equipment status |
QoS 1 |
Exactly-once preferred, but duplicate “ON” is safe |
| Diagnostic logs |
QoS 0 |
Fire-and-forget, logs are for troubleshooting only |
Step 4: Measure impact during 10-second WiFi glitch
Without QoS: - Vitals lost: 240 msg/hr ÷ 3600 × 10s × 50 patients = 33 critical readings lost - Potential missed emergency: HIGH RISK
With QoS (2 for critical, 1 for status, 0 for logs): - Critical vitals: 100% delivered (QoS 2 guarantees) - Status updates: 100% delivered (QoS 1 retries) - Diagnostic logs: ~10 lost (QoS 0), acceptable trade-off
Result: QoS strategy prevented 33 potential missed emergencies during one glitch
Key insight: Mix QoS levels by message criticality. QoS 2 for life-safety, QoS 1 for operations, QoS 0 for diagnostics.