Search topics...
Networking ProtocolsMQTT & Application Protocolsintermediate

Compare MQTT vs HTTP/REST vs CoAP for embedded IoT.

0 upvotes
Practice with AISoon

MQTT is a publish-subscribe protocol over TCP. Its strengths are bidirectional push (the server can send data to the device without polling), low per-message overhead (2-byte minimum header), built-in reliability (QoS levels), and excellent support for one-to-many distribution (one publish reaches all subscribers). Its weaknesses: it requires a persistent TCP connection (which consumes RAM and keeps the radio active on battery devices), needs a broker infrastructure, and is not request-response by nature — implementing RPC patterns (send a command, get a result) requires pairing topics and correlation IDs.

HTTP/REST is the most ubiquitous protocol on the internet. Every developer knows it, every cloud platform supports it, and it works through proxies and firewalls without special configuration. For embedded systems, the downsides are significant: HTTP headers add 200-800 bytes of overhead per request, the request-response model requires the device to poll for commands (wasting bandwidth and battery), TLS handshake is expensive (HTTP without TLS is insecure for IoT), and each request is stateless — there is no persistent session. HTTP is appropriate when the device communicates infrequently (once per hour or less), only needs to push data to the cloud (not receive commands in real-time), or must integrate with existing REST APIs.

CoAP (Constrained Application Protocol) is specifically designed for constrained devices. It runs over UDP (not TCP), uses a compact binary header (4 bytes), supports request-response like HTTP but with much lower overhead, and includes built-in discovery and observe (subscribe to resource changes). CoAP shines on severely constrained devices (8-bit MCUs, 6LoWPAN networks, NB-IoT with tiny MTU) where even a TCP connection is too expensive. DTLS provides security without TCP overhead. The downside is a smaller ecosystem compared to MQTT and HTTP — fewer cloud platforms natively support CoAP, and proxy translation (CoAP-to-HTTP) adds complexity. For most IoT products with Wi-Fi or cellular connectivity and reasonable RAM (64 KB or more), MQTT is the pragmatic default. CoAP is the better choice for truly constrained devices on constrained networks.

Source: Networking Protocols Q&A