Advantage IoT – REST vs. MQTT

A common dilemma development teams are facing today; should they leverage existing REST APIs, or invest time and energy in moving to MQTT? As always, project timelines are severely crunched, and teams must take the shortest path, repurposing the REST APIs.

It is, however, important for business teams to understand the benefits of moving to MQTT, the light weight protocol designed exclusively for IoT. This blog aims to assess the relative strengths and weaknesses, to help you select what’s most appropriate for you.

 

Response

REST offers a uni-directional connectivity. The client will reach out to the server when it needs data, or needs to push some data. This places the onus solely on the client application, and more often than not, poorly designed application lead to frustrated end users. Oftentimes, servers will limit the frequency at which a client can connect. Imaging having to wait 30 seconds for an acknowledgement, when you’ve just used your home automation app to power on an air conditioner. It’s just not conceivable.

On the other hand, MQTT allows the client and the server to be ‘always connected’, eliminating all delays when the server needs to send a message to the client. This allows the end user to have instantaneous updates, creating a smooth user friendly interaction.

 

Energy

In studies (https://ieeexplore.ieee.org/document/7899537/), it has been concluded that MQTT offers upto 20% improvement in power consumption, when compared to REST. The fundamental reason appears to be the frequent connection-disconnection requirements that REST mandates. In an energy sensitive mobile device, which battery powered, this is a significant differentiator.

 

Performance

The payload of MQTT’s ‘keep-alive’ ping is much smaller, when compared to the connection-reconnection requests that REST requires. Not only this, it eliminates the time delays associated with re-establishing a connection between the server and the client. An MQTT based application, catering to 1000s of requests per second, across 10000s connections has demonstrated to have throughput of over 20x, when compare to similar REST application. And this is on commodity hardware.

If you’re just getting started with MQTT, see this list (https://github.com/mqtt/mqtt.github.io/wiki/public_brokers) for some publicly accessible brokers, useful for testing.

Loading Likes...
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.