Trying to get an understanding of the cloud side compute power comparison (and cost) for say 10,000 devices sending data to the cloud using HTTPS Vs MQTT.

My co-worker says keeping 10k MQTT connections alive would eclipse the cost of having the same devices HTTPS POST. My intuition says it's probably the same (since you'll always need the power to support all connections even when using HTTPS), and the overhead of building those connections every time.

Does anyone have any experience comparing? Or would anyone have anecdotal experience?

Appreciate the help!

  • You are implying that MQTT has to keep the connection open, but presumably you could close the connection after each data transfer, similar to a POST. However, if you are concerned about the cost of connections, then think about UDP; a stateless server with a simple retry mechanism can easily handle one million transactions per second, and if you get broken connections (as often happens with cellular links) you aren't unnecessarily keeping dead connections open.
    – jayben
    Jan 21, 2023 at 11:10

2 Answers 2


An idle connection will use very, very little power. Just need to handle a few keep alive packets now and then, and possible slightly larger CPU overhead to correctly map incoming packets to the right connection (both at the OS network stack level and in your app), but that should be negligible.

Keeping tens of thousands or hundreds of thousands of connections active on a single server is not a problem if you use the right tools (I.e. you don’t have an Apache proxy on the path, for instance).

Establishing and HTTPS connection, on the other hand, is extremely expensive, both in terms of CPU and network traffic. You first need to establish a TCP connection, then TLS inside that, then HTTP inside that, probably also adding authentication and any application-level handshake on top of that.

That’s the whole reason there are so many mechanisms to avoid doing it again (connection keep alive, to serve several HTTP requests within a single TCP+TLS connection), or to speed up new negotiations (with caching, but that is limited in time).

Also, keeping the connection established has one huge advantage: you can send data from server to client at any time, while with individual connections you need to either perform polling (nooooooo) or long polling to do that, which gives the same result as keeping the connection alive, but with higher overhead.

Unless there’s something specific in your setup that would prevent it, go for the permanent connections.

  • Thanks! This makes complete sense. I wasn't even thinking about the extra overhead for the TLS, etc. Having bi-directional communications is also very important, making MQTT seem more attractive in my mind. The alternative suggested is putting commands in the POST response - which seems like a bad idea, if we need any real time data transfer - we'll need to POST more, which could be even more expense.
    – BAO
    Jan 21, 2023 at 15:12

IIRC An idle TCP/IP connection shouldn't consume any power at all (relative to just having the network hardware on)

So the closest analogue to power usage is going to be bandwidth and HTTPS connection dwarfs a MQTTS connection by the time you consider the repeat TLS handshake on each message and then add in the HTTP headers.

Why does your co-worker think it consumes more power to send a tiny MQTT ping packet every now and again Vs the whole HTTPS handshake?

  • Thanks! This makes sense. My co-worker thinks our compute costs will be higher if we're maintaining 10-20k MQTT connections VS using HTTPS POST . Assuming both are sending data every ~30 seconds. Their rational is just "it will use more" but I am a boring embedded engineer - so I really need more questions to ask.
    – BAO
    Jan 21, 2023 at 15:04
  • They is zero computer for a inactive open connection
    – hardillb
    Jan 21, 2023 at 15:30
  • @hardillb unless you happen to use SO_KEEPALIVE or similar (as you would do to prevent random firewalls from killing your idle connections) Jan 21, 2023 at 16:14
  • I assume we'll need keep alives. But a 60-120 second keep alive I would still guess is cheaper.
    – BAO
    Jan 21, 2023 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.