MQTT vs REST: Understanding the Key Differences

This page compares MQTT vs REST and mentions the difference between MQTT and REST protocols.

Broker based MQTT protocol

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.

REST protocol

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:

FeaturesMQTTREST
Full FormMessage Queue Telemetry TransportRepresentational State Transfer
Messages usedConnect, connect ack, publish, publish ack, subscribe, subscribe ack, disconnect etc.GET, PUT, POST and DELETE
ArchitecturePublish/SubscribeRequest/Response
Need of centralized brokerRequired, end devices communicate via brokerNot required, end devices communicate directly
Transport protocolTCP/IPTCP/IP
Security protocolTLSHTTPS
Fault toleranceBroker in SPoFServer in SPoF
Interoperabilityfoundational semantic scope device to cloud cloud to clouddevice to cloud cloud to cloud