Insights Why HTTP is not suitable for IOT applications.

Why HTTP is not suitable for IOT applications.

When developing modern web-applications, the most commonly used application layer protocol is HTTP. It is suitable for serving hypermedia resources in a request-response fashion over the internet. However, when it comes to the Internet of things (IOT), it tends to perform poorly mainly because it was designed to be a reliable but heavy-weight protocol for the world-wide-web. In this blog, I want to highlight the issues with HTTP with respect to IOT applications.

1. What is Internet of Things?

The Internet of things (IoT) is the extension of Internet connectivity into everyday dumb-objects (Microwave, toothbrush, Car etc.) that serve us a purpose. Embedded with electronics, Internet connectivity, and other forms of hardware (sensors), these devices can communicate and interact with others over the Internet, and they can be remotely monitored and controlled. By connecting these devices with internet, it is possible to gather data, analyze it and then take a responsible actions to help someone with a particular task or see the hidden-trends from this collected data. IoT offers us opportunity to be more efficient in how we do things, saving us time, money and effort.

IOT network traffic falls broadly into 2 categories: telemetry and telecommand. Telemetry is the aggregation of data generated by sensors and devices. Usually, telemetry involves sending data from a pool of sensors to a server of some sort. Telecommand on the other hand is just the sending of commands across a network to control these devices or sensors.

2. What is HTTP and how does it work?

The Hypertext Transfer Protocol is an application protocol for distributed, collaborative, hypermedia information systems that allows users to communicate data on the World Wide Web. HTTP was invented alongside HTML to create the first interactive, text-based web browser: the original World Wide Web. Today, the protocol remains one of the primary means of using the Internet.

HTTP data rides above the TCP protocol, which guarantees reliability of delivery, and breaks down large data requests and responses into network-manageable chunks. TCP is a “connection” oriented protocol, which means when a client starts a dialogue with a server the TCP protocol will open a connection, over which the HTTP data will be reliably transferred, and when the dialogue is complete that connection should be closed. All of the data in the HTTP protocol is expressed in human-readable ASCII text.

The steps can be summarized as below:

  1. Client sends a SYN packet to the server.
  2. Web server responds with SYN-ACK packet.
  3. Client again sends a ACK packet, concluding a connection establishment. This is also commonly referred to as a 3-way handshake.
  4. Client sends a HTTP request to the server asking for a resource.
  5. Client waits for the server to respond to the request.
  6. Webserver processes the request, finds the resource and sends the response to client.
  7. If no more resources are required by the client, it sends a FIN packet to close the TCP connection.

3. Why HTTP is not suitable for IOT?

  • One-to-one communication: HTTP is designed for communication between 2 systems only at a time. While this works fine for requesting resources from the web as a user, it doesn’t fulfill the needs of IOT setup. In most of the IOT applications at large industries and manufacturing units, there are a large number of sensors which are generating data at the same time and want to push this ahead to the server at the same time as well. Hence, HTTP does not fulfill the need for one to many communication between sensors and the server.
  • Uni-Directional: HTTP is unidirectional in the sense that only one system(client or server) can send a message to the other at any point in time. This is because it is based on the request-response model where client has to explicitly request for resources and then server responds with them. However, in the case of IOT applications, we may need to send data in both directions simultaneously – telemetry and telecommand can be executed at the same time!
  • Synchronous request-response: After requesting a resource to the server, the client has to wait for the server to respond. This blocks some system resources like threads, CPU cycles etc. on both client as well as server side. Additionally, this leads to slow transfer of data. IOT sensors are small devices with very limited computing resources and hence cannot work efficiently in a synchronous manner. All the widely used IOT protocols are based on asynchronous model.
  • Not designed for event-based communication: Most of the IOT applications are event based. The sensor devices measure for some variable like temperature, air quality and contents etc. and might need to take event driven decisions like turning off a switch etc. HTTP was designed for a request-response based communication rather than a event-driven communication. Also, programming this event based systems using HTTP protocol becomes a big challenge especially because of the limited computing resources on the sensor devices.
  • Scalability: HTTP connections utilize high system resources especially I/O threads. For every HTTP connection, the client/server has to open an underlying persistent TCP connection as well. As more sensor devices are added in the network, the load on the server increases. If the sensor devices themselves are connected to multiple other devices, this puts heavy load on the tiny system resources of the sensors. Hence, HTTP does not scale well for IOT applications.
  • High Power Consumption:  Since HTTP utilizes heavy system resources as explained above, this also leads to heavy power consumption. Advanced Wireless Sensor Networks of today have battery operated sensor devices utilizing wireless network connections. Because of heavy power consumption, HTTP is not suitable for advanced Wireless Sensor Networks.

As clear from above, HTTP has severe limitations for IOT applications. Many advanced application-layer protocols(MQTT, AMQP, CoAP) have been developed to overcome these limitations. 

Main aim of this blog is to make technology users understand the limitations of HTTP as a communication protocol for IOT applications, so that informed decision can be made when designing modern IOT applications.