HTTP vs. MQTT: A tale of two protocols by Google Cloud

Forums IoTStack Discussions (IoTStack) HTTP vs. MQTT: A tale of two protocols by Google Cloud

  • This topic has 1 voice and 0 replies.
Viewing 0 reply threads
  • Author
    Posts
    • #27572
      TelegramGroup IoTForIndia
      Moderator
      • Topic 2519
      • Replies 0
      • posts 2519
        @iotforindiatggroup

        #Discussion(IoTStack) [ via IoTForIndiaGroup ]


        Looking at the result that compares response time over one connection cycle for MQTT, we can clearly see that the initial connection setup increases the response time for sending single messages to the level that equals the response time of sending a single message over HTTP, which in our case rounds up to 120 ms per message. The contribution in terms of data amount sent over wire is even more significant for the MQTT case in which around 6300 bytes is sent for a single message, which is larger than for HTTP, which sums up to 5600 bytes. By looking at the packet traffic log, we can see that the dominant part—more than 90% of the data transmitted—is for setting up and tearing down the connection.

        The real advantage of MQTT over HTTP occurs when we reuse the single connection for sending multiple messages in which the average response per message converges to around 40 ms and the data amount per message converges to around 400 bytes. Note that in the case of HTTP, these reductions simply aren’t possible.

        From the result of the test for variation in payload size, we could observe that response times were kept constant as the payload size went up. The explanation here is that since the payloads being sent are small, the full network capacity isn’t utilized and as the payload size increases, more of the capacity is being used. Another observation we can make looking at the network packet log is that even as the amount of information packed into the payload increased by 10x and 100x, the amount of data actually transferred only increased by 1.8x respective 9.8x for MQTT and 1.2x and 3.4x for HTTP, which shows the effect of the protocol overhead when publishing messages.

        The conclusion we can draw is that when choosing MQTT over HTTP, it’s really important to reuse the same connection as much as possible. If connections are set up and torn down frequently just to send individual messages, the efficiency gains are not significant compared to HTTP.

         


        Read More..

    Viewing 0 reply threads
    • You must be logged in to reply to this topic.