MQTT connection consumes less power

纵饮孤独 提交于 2019-12-08 11:27:27

问题


MQTT is claimed to consume less power for keeping the connection open between broker and client. I believe application layer need not do anything special to persist a TCP connection and MQTT is an application layer protocol. So, how does MQTT improvises in this area?


回答1:


HTTP(S) doesn't keep a connection open - so to get the "effect" of a continuous connection, the HTTPS client has to keep making poll requests, each of which involves creating the TCP connection and negotiating SSL/TLS encryption etc. each time a poll is needed.

By contrast, MQTT makes a connection at the start, so the TCP and SSL/TLS overhead cost is only paid once. MQTT has a keep alive message flowing between applications on top of the TCP connection, so that the applications can detect when the connection is broken, this allows the MQTT broker to reliably publish the (optional) client last will/testament when the connection is broken.

The article you read says that MQTT saves 50% mobile battery power compared to HTTPS, I think.




回答2:


I think that MQTT is considered lower power than HTTP, mainly because of reducing the amount of data transferred, particularly over a wireless link.

  1. MQTT is a binary protocol and so there is less overhead
  2. By maintaining a persistent TCP connection, it avoids the overhead of establishing a connection for each published item of data

The biggest saving is when a client needs to subscribe to messages - waiting for a remote system to send it data. With plain HTTP, it would require some kind of polling - using up a lot of power, even where there are no messages. With MQTT a message can be pushed to the client over the open TCP connection.

While there are lots of other protocols that allow this too. MQTT was designed for this purpose.



来源:https://stackoverflow.com/questions/37362582/mqtt-connection-consumes-less-power

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!