- iot
- mqtt
- architecture
- embedded
- backend
MQTT vs HTTP for IoT: Which Should Your Devices Use?

Most IoT projects start with someone asking a version of the same question: the device reads a sensor every few seconds — do we post it to a REST endpoint, or do we set up this MQTT thing everyone mentions? The answer changes the architecture of everything downstream: how devices authenticate, how much battery they burn, whether your dashboard updates in a second or a minute, and what happens when a device loses the network.
This guide compares the two on the decisions that actually matter. It draws on how we structure real-time dashboards — the part of our work where this choice shows up first.
The core difference in one paragraph
HTTP is a conversation: the device asks, the server answers, the conversation ends. Every reading is a request the device initiates, waits for, and closes. MQTT is a postal system: devices publish messages to topics (like plant3/line2/temperature) on a broker, and any backend service that subscribed to that topic receives them — including, going the other way, commands published to a topic the device listens to. With MQTT the device and the server never talk to each other directly; they both talk to the broker.
That one structural difference produces most of the practical trade-offs below.
The seven comparisons that decide it
| Question | HTTP | MQTT |
|---|---|---|
| Who initiates? | Always the device | Either side, via the broker |
| Can the server reach a device instantly? | No — the device must poll | Yes — publish to a topic the device subscribes to |
| Overhead per message | Headers on every request, typically hundreds of bytes to kilobytes | 2-byte fixed header on the smallest messages |
| Battery / bandwidth on cellular or LoRa-backed links | Heavy — TLS handshake per request unless you keep connections alive | Light — one TLS handshake, then a persistent connection |
| What happens when the device is offline | Your request fails; data is lost unless the device queues it | Broker queues messages (QoS 1+) and delivers on reconnect |
| Backend integration | Your API endpoint | Broker + a bridge into your services |
| Tooling and familiarity | Every language, every firewall, every engineer | Needs a broker (Mosquitto, EMQX, HiveMQ…) and new ops knowledge |
QoS levels: what they actually buy you
MQTT's quality-of-service setting is the part people get wrong, so here is the honest version:
- QoS 0 — at most once. Fire and forget. The message may vanish. Fine for a temperature reading that is repeated every few seconds; the next one supersedes it.
- QoS 1 — at least once. The broker acknowledges. The message always arrives — possibly twice. This is the right default for readings that feed dashboards or alerts, if your consumer is idempotent (deduplicates by device + timestamp). If your consumer is not idempotent, a dashboard showing 21.4°C becomes 21.4°C received twice and, in a worse case, a stock counter incremented twice.
- QoS 2 — exactly once. A four-step handshake. Costs latency for a guarantee you usually don't need, because deduplication at the consumer is cheaper than the handshake on every message.
And the companion feature that matters more than any of the three: retained messages. The broker keeps the last message on a topic and hands it to any new subscriber immediately — so a dashboard that opens in the afternoon still shows the latest reading, instead of an empty screen until the next interval.
Security: both need work, in different places
- HTTP security is web security: TLS, API keys or tokens, rate limiting, input validation. Your endpoint is internet-facing, so it carries the whole OWASP surface. Our API security checklist applies directly.
- MQTT moves the perimeter to the broker. The non-negotiables: TLS on port 8883 (plain 1883 is for local development only), per-device credentials — a unique username/password or client-certificate per device, never one shared secret in firmware — and topic ACLs, so a compromised device cannot publish to another product's topics or subscribe to the whole fleet. Most brokers support all of this; "we didn't enable it" is the most common failure we see.
One more MQTT-specific trap: client IDs must be unique. Two devices with the same client ID will keep disconnecting each other, and the symptom in your logs is a mystery flapping connection, not an error message pointing at the cause.
Payloads: what actually goes on the wire
A sensor reading as JSON over HTTP might look like {"deviceId":"p3-l2-t7","timestamp":"2026-11-03T10:14:00Z","sensor":"temperature","value":21.4} — roughly 110 bytes of data plus a few hundred bytes of TLS-protected HTTP overhead.
The same reading on MQTT can shrink in two steps. First, encode the structure in the topic instead of the payload — publish 21.4 to plant3/line2/p3-l2-t7/temperature and let a timestamp be added at receipt. Second, if bandwidth is genuinely expensive (NB-IoT, satellite), swap JSON for a binary format like CBOR or Protobuf — a single-digit-grams message. JSON on MQTT is perfectly fine until the SIM card bill says otherwise.
So which should your devices use?
The decision rule we use:
- Stateless, low-frequency, client-initiated, existing REST API → HTTP. A device that checks in every 15 minutes with a status payload is a client, and a plain endpoint is the simplest correct architecture.
- Telemetry at seconds-level frequency, remote commands, or a dashboard that must be live → MQTT. The persistent connection, queued delivery and server-initiated push are exactly what HTTP cannot give you.
- Both is a common and legitimate answer: MQTT for the live telemetry stream, HTTPS for firmware downloads, bulk sync and anything that fits a request/response shape better than a topic.
One thing not to do: do not put raw MQTT on the public internet without the broker hardening above, and do not confuse "MQTT is lightweight" with "MQTT is secure by default". It is neither encrypted nor authenticated until you make it so.
Where this fits in the rest of the platform
The transport is one layer. What happens to messages after the broker — ingestion, storage, alerting, and how a dashboard gets built on top — is the next decision, and it is covered in IoT architecture: from device to dashboard. If you are weighing a bespoke real-time dashboard against a BI tool afterwards, that comparison is here: real-time dashboard vs BI tool.
If you are scoping a connected product and want an architecture review before committing to a transport, that is part of our IoT development work — bring the device list and the data source, and we will map the layers with you.
FAQ
Is MQTT better than HTTP for IoT? Not universally. MQTT wins for frequent telemetry, offline tolerance and server-initiated commands. HTTP wins for low-frequency check-ins, simplicity and existing REST infrastructure. The frequency and direction of your data decides it.
Does MQTT require internet access? The device needs IP connectivity to reach the broker — that can be LAN, private APN or the public internet. MQTT over a local broker works without internet; that is common in factory settings.
Can I use both MQTT and HTTP in one product? Yes, and it is a common pattern: MQTT for live telemetry and commands, HTTPS for firmware updates, configuration and bulk uploads. One product does not have to pick a single protocol.
Have a project idea?
Get a rough estimate in 5 minutes with our Project Scoper.
Scope Your ProjectReady to discuss?
30 minutes. No pitch deck. Just an honest conversation about your project.
Book a Free Call





