DEV Community

Jannatul Nisa Jeem
Jannatul Nisa Jeem

Posted on

MQTT vs HTTP: Don't Choose Just Because Everyone Else Does

If you're new to IoT, you'll probably come across MQTT pretty quickly.

And then the obvious question is:

Why not just use HTTP?

You absolutely can use HTTP.

For example, a device could simply send:

POST /api/readings

with:

{
"device_id": "sensor-12",
"temperature": 31.4
}

Pretty straightforward.

MQTT takes a different approach.

A device publishes a message to a topic:

factory/machine12/temperature

and other systems subscribe to that topic.

That can make a lot of sense when you have many devices constantly sending small messages.

The thing I wouldn't do is choose MQTT just because it's "the IoT protocol."

Ask what your application actually needs.

How many devices?

How often are they sending data?

Do they need to receive commands?

How reliable is the network?

Does latency matter?

Those questions are much more useful than asking which technology is more popular.

Top comments (0)