Skip to content

Plain-language guides to iot development

Date

Monday, November 16, 2026

Posted by

Date

MQTT vs HTTP for IoT: Which Fits Your Device?

mqtt vs http

Unsure which protocol your device needs? MQTT vs HTTP comes down to how often it talks and whether it must listen. Frequent senders usually fit MQTT; occasional, low-volume uploads suit HTTP.

This guide is part of our wider look at iot development, where protocol choice shapes battery life, cost and reliability.

Item Value
MQTT standard message header Two bytes
MQTT quality-of-service levels Three levels
MQTT protocol stack footprint About 10 kB of RAM/flash
Energy use versus HTTP on 3G networks (vendor claim) MQTT uses 170 times less energy
Energy use versus HTTP on Wi-Fi networks (vendor claim) MQTT uses 47 times less energy

These figures come from RoboticLab’s IoT-Open course material and Nabto’s protocol comparison. Figures can change, so check the sources before you rely on them.

How MQTT and HTTP differ at the core

According to HiveMQ, a vendor of MQTT software, MQTT was designed for the Internet of Things, while HTTP was created to make documents available across the internet. That difference in purpose explains most of the trade-offs below.

Both protocols run over TCP and follow a client-server pattern. The key difference is direction: MQTT lets messages pass both ways between clients and servers, whereas an HTTP server only answers requests from clients, as HiveMQ’s comparison explains.

In day-to-day terms, that gives you three practical differences:

  • Connection life: once an MQTT connection is open, any number of messages can flow through it in both directions, with sensor data going up and commands coming down.
  • Per-request cost: HTTP deals with requests one at a time, with overhead such as authentication repeated each time.
  • Payload format: MQTT payloads are binary, while HTTP is textual, so binary data has to be encoded before it travels over HTTP.

HTTP can pool TCP connections, which helps, but the overhead for each message remains, per HiveMQ. MQTT, in turn, needs a broker: RoboticLab describes a central server located outside firewalls and NATs, where all clients connect and exchange messages by publish/subscribe.

Overhead, battery and speed

Size matters on a constrained device, so start with the header. RoboticLab’s course material puts the standard MQTT message header at two bytes and the protocol stack at about 10 kB of RAM/flash, while Cedalo’s guide gives a minimum fixed header of 2 bytes. The RoboticLab page also notes that even the simplest HTTP header takes up bytes before any payload is added, which it calls problematic for constrained devices.

Battery life is the next concern. Nabto, which promotes its own remote-access product, claims in its comparison that MQTT consumes 170 times less energy on 3G networks and 47 times less energy on Wi-Fi networks than HTTP. Treat those multiples as a vendor claim and test on your own hardware.

HiveMQ’s benchmark shows why the gap grows with traffic. HTTP pays overhead on every request, while MQTT pays a connection setup cost once and then sends many messages cheaply. The catch, HiveMQ admits, is that a device sending only one message per TCP session can see that setup cost exceed HTTP’s.

You can also trade safety for speed. HiveMQ notes that sending messages before the previous acknowledgment arrives adds coding complexity, and that QoS 0 skips the acknowledgment at the cost of some reliability.

mqtt vs http Server hardware
A row of server components glows under blue lighting.

What MQTT adds that HTTP lacks

HiveMQ lists queuing, QoS, retained messages and message push as features HTTP lacks for IoT. Here is what that means in practice:

  • Retained messages: a client that subscribes later receives the last retained message at once, even if the publisher is silent, as RoboticLab describes.
  • Will messages: the broker can notify other clients when a device disconnects unexpectedly, so you can monitor device state, according to HiveMQ.
  • Queuing: the broker’s built-in queuing copes with connection interruptions and buffers data for constrained devices that cannot do it themselves.
  • Quality of service: RoboticLab counts three levels, chosen at the message level.
  • Remote updates: firmware and configuration updates can be broadcast to devices.

These are the reasons HiveMQ concludes that MQTT fits many more IoT scenarios than HTTP. Because the company sells MQTT infrastructure, weigh that verdict against the HTTP cases in the next section.

When is HTTP still the right choice?

The principal advantage of HTTP is familiarity. HiveMQ points out that many developers have already built web solutions, so client libraries and servers are easy to find.

HiveMQ itself allows one valid case: devices that already include an HTTP client, connecting to a provider that offers an HTTP option. Even then it limits the idea to low-volume data, with no way to send control commands to the device.

Everyday examples point the same way. IoT For All imagines a smart home setup that uses HTTP for periodic uploads from smart devices, while warning that HTTP is not limited to periodic transfers, nor MQTT to real-time asset tracking.

Security needs planning too. Nabto says HTTP has no native encryption, so you would add HTTPS, which solves the integrity problem but makes the protocol more energy intensive.

Where MQTT can be the harder choice

Nabto lists several drawbacks worth weighing before you commit:

  • User interface code: asynchronous publish-subscribe can be very cumbersome when a phone app must tell a user what happened to a slow command.
  • Latency: reliability is one of MQTT’s main strengths, but speed and latency are not, which matters if a machine must shut off the instant someone comes too close.
  • Streaming: MQTT does not support streaming of any kind, either audio or video.

Nabto also markets Nabto Edge, which it says gives secure remote access to an existing HTTP service. Read its list as one vendor’s view rather than a verdict.

How do you choose for your device?

Work through these questions in order, and stop at the first one that settles it:

  1. Must the device receive commands from the server? If so, MQTT’s two-way connection is the natural fit.
  2. Will it send many messages per connection? Frequent traffic favours MQTT, while a single message per session can favour HTTP.
  3. Is the battery tight? Test energy use on your own network, since the published multiples come from vendors.
  4. Do you need streaming, or quick request-and-response behaviour behind a user interface? HTTP may be easier.
  5. Does the device already ship with an HTTP client and send little data? Then HTTP can be enough.

If neither protocol fits, the wider iot protocols overview in our guide to iot protocols covers the alternatives. Cedalo describes CoAP and MQTT as complementary, with CoAP serving the most constrained device tier and MQTT taking over at the gateway.

Your cloud service matters as well, so check which protocols it accepts before you build. Our iot platform comparison is a sensible place to start that check.

Frequently asked questions

Is MQTT always the better choice for IoT?

Show answer

No. It suits devices that report often and need instructions back, but a gadget that uploads a reading now and then and already ships with an HTTP client can stay on HTTP. Traffic pattern should drive the decision, not fashion.

Does MQTT need a broker?

Show answer

Yes. Clients connect to a central hub, the broker, which takes in published messages and forwards them to subscribers, as IoT For All explains. HTTP clients talk to a server directly.

Can an HTTP server push a command to a device by itself?

Show answer

Not in a plain exchange: servers reply to requests rather than start them, so the device has to ask first. An open MQTT connection lets the broker deliver commands the moment they exist.

Is MQTT secure enough?

Show answer

Out of the box it is weak. RoboticLab says the broker can check usernames and passwords sent in plain text, but the whole client-broker conversation can be wrapped in an SSL-encrypted stream. Use that wrapper on any real deployment.

How old is MQTT?

Show answer

It dates to 1999, when Arlen Nipper of Eurotech and Andy Stanford-Clark of IBM developed it, per IoT For All. The goal was to save battery and bandwidth on oil pipelines connected by satellite.