MQTT vs REST: Understanding the Key Differences
Advertisement
This page compares MQTT vs REST and mentions the difference between MQTT and REST protocols.
Figure 1: MQTT Architecture
MQTT stands for Message Queue Telemetry Transport. As shown in Figure 1, it consists of a centralized broker through which all communications between end devices pass. The broker can be installed on any public server.
MQTT is based on a publish/subscribe architecture, where each end device can publish to topics and subscribe to any topic. It is built on the TCP protocol, meaning a connection is established before communication.
In the MQTT protocol, a username and password are required to establish a connection.
Figure 2: REST Protocol Stack
REST stands for Representational State Transfer. As shown in Figure 2, it is built on HTTP/TCP layers.
The REST protocol uses a bus-based architecture, where no broker component is needed, and end devices can communicate directly. Request and response messages are used between end devices to exchange information.
The following table highlights the comparison between MQTT and REST protocols:
Features | MQTT | REST |
---|---|---|
Full Form | Message Queue Telemetry Transport | Representational State Transfer |
Messages used | Connect, connect ack, publish, publish ack, subscribe, subscribe ack, disconnect etc. | GET, PUT, POST and DELETE |
Architecture | Publish/Subscribe | Request/Response |
Need of centralized broker | Required, end devices communicate via broker | Not required, end devices communicate directly |
Transport protocol | TCP/IP | TCP/IP |
Security protocol | TLS | HTTPS |
Fault tolerance | Broker in SPoF | Server in SPoF |
Interoperability | foundational semantic scope device to cloud cloud to cloud | device to cloud cloud to cloud |