MQTT vs HTTP for IoT Applications
Use MQTT when many small messages must flow between devices and services, especially over unreliable or constrained networks; use HTTP when a device makes occasional requests to a web API or when you need simple integration with existing web services. Many systems use both.
Comparison
| MQTT | HTTP | |
|---|---|---|
| Model | Publish/subscribe via a broker | Request/response between client and server |
| Connection | Long-lived, persistent | Typically short-lived per request (keep-alive possible) |
| Server push | Native: subscribers receive messages instantly | Needs polling, WebSockets or SSE |
| Overhead | Very small headers | Larger text headers |
| Delivery guarantees | QoS 0, 1 and 2 | Application-level retries |
| Offline awareness | Last Will, retained messages | None built in |
| Tooling | Brokers, MQTT clients | Universal: browsers, REST tools, CDNs |
Choose MQTT for
- Telemetry from many devices at frequent intervals.
- Commands that must reach a device quickly (relays, setpoints).
- Battery-powered nodes that cannot afford heavy request overhead.
Choose HTTP for
- Occasional uploads of a batch of readings.
- Calling third-party APIs (weather, SMS, webhooks).
- Firmware downloads and configuration endpoints.
Design tip: use both
A common pattern is MQTT between devices and a gateway or back end, and HTTP between the back end and web applications. A gateway such as a Raspberry Pi can translate between them. See MQTT explained for the protocol details and the MQTT and Node-RED course for hands-on practice.
References
- OASIS, MQTT Version 5.0: docs.oasis-open.org
- IETF RFC 9110, HTTP Semantics: rfc-editor.org
Related reading
IoT Fundamentals
IoT Architecture: Devices, Gateways, Networks and Cloud
A practical walkthrough of the layers of an IoT system and how data and commands move between devices, gateways, networks and the cloud.
IoT Communication and Cloud
MQTT Explained with Examples
MQTT is the lightweight publish/subscribe protocol behind much of IoT messaging. Learn brokers, topics, QoS, retained messages and last will with examples.
IoT Fundamentals
IoT Learning Roadmap for Engineering Students: What to Learn and When
A semester-by-semester IoT roadmap for engineering and diploma students, from electronics basics to a documented project.
IoT Fundamentals
IoT Sensors and Actuators Explained with Examples
Sensors turn physical conditions into signals; actuators turn commands into action. Learn the common types, how they connect and how to choose one.
Learning from your city?
City guides show how online IoT training works from where you are, with project themes for your area.