2

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!

BAO
  • 23
  • 2

2 Answers2

2

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?

hardillb
  • 12,813
  • 1
  • 21
  • 34
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.

jcaron
  • 2,408
  • 5
  • 10