I recently read a Quora question about whether CoAP or MQTT is more lightweight, but the answers don't seem particularly satisfying and all contradict each other: the top answer says MQTT takes fewer resources, and another below that says CoAP is less demanding.

From what I've found, it would make sense that CoAP would be less demanding than MQTT, since CoAP only requires UDP, and its messages are mainly fire-and-forget, unlike MQTT which functions over TCP (and hence would be much more involved).

Which protocol requires the least resources to function?

By resources, I'm primarily thinking of required processor power, RAM and data to be transmitted. For example, in the Quora question I linked, the top answer points out that a simple ESP8266 chip could run MQTT, which only has a 80MHz processor and less than 1MB of RAM. I'm curious as to whether CoAP could run on something like this, or an even more constrained environment.

The sort of use case I'm envisaging is where the device would mostly be receiving data from another device (e.g. commands to switch on/off), but may need to infrequently (perhaps a few times an hour) send updates with the device's status. I'd like to use as little processing power as possible to reduce device costs, and transmit relatively infrequency to reduce power usage as much as possible.

  • 1
    To avoid apples and oranges comparisons it would be useful if you could lay out a very, very specific use case. What task would you like to use as a basis for comparison? – goobering Jan 16 '17 at 18:04
  • @goobering I've edited with some more info about a more concrete use case; let me know if you need anything more. – Aurora0001 Jan 16 '17 at 18:11
  • At the server/hub, or the endpoint? Your example device seems way over-spec for a constrained endpoint. – Sean Houlihane Jan 16 '17 at 18:13
  • @SeanHoulihane At the endpoint. The resources needed at the hub aren't so much of a factor in my question; just aiming to minimise the endpoint resources. – Aurora0001 Jan 16 '17 at 18:15

CoAP and MQTT have both equal RAM usage, measured in 10kbits [1].

Difference is in cpu and network usage: [2]

Every client supports TCP and holds a connection open to the broker.

So, CoAP has fewer foot print and according to the whole use case (small data once in a while) it seems to be your best choice.

As you referred, CoAP uses UDP. It does not guarantee data delivery. Still it performs 'excellent' in lossy conditions, while MQTT is only 'good'. So, I would not worry much on that.


[1] http://embedded-computing.com/articles/internet-things-requirements-protocols/

[2] http://www.altencalsoftlabs.com/blogs/2016/08/08/analyzing-mqtt-vs-coap/

| improve this answer | |
  • Your reference doesn't appear to support your conclusion: “an additional 20 KB of flash and 8 KB of RAM to upgrade to TCP”. If you round to 10kbits, or even to 10kB, it does mean that the difference in RAM usage between CoAP and MQTT is non-negligible. – Gilles 'SO- stop being evil' May 27 '17 at 20:14
  • Depends if TCP is a selection criteria. It opposes the normal case for the protocol, which is UDP. Taking CoAP almost means accepting UDP. – mico May 27 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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