cowen71 / mqtt-LabVIEW

AN MQTT Driver implementation for LabVIEW
28 stars 33 forks source link

MQTT vs HTTP ? #8

Open martin9115 opened 2 years ago

martin9115 commented 2 years ago

Hi, is there a performance test between MQTT vs HTTP ?

francois-normandin commented 2 years ago

It is undeniably faster to transfer payloads using MQTT, but both protocols serve different purposes. MQTT is for data payloads and a pub-sub architecture, whereas HTTP is suited for synchronous query and response.

MQTT's effective transfer rate will slow down when you introduce quality of service > 0, but fundamentally the difference lies in the size of the header required for a successful transfer. MQTT's header is always the same size (publish packet format) whereas HTTP's is significant larger and can vary based on signatures, authorization types and encoding.

If you want a benchmark, I'm afraid it will be hard to decouple your type of payload from the expected result. In theory, compare the size of headers and that's your difference in throughput.

Here's a light read on the topic:

https://medium.com/mqtt-buddy/mqtt-vs-http-which-one-is-the-best-for-iot-c868169b3105

martin9115 commented 2 years ago

Can i just testing time to transfer certain amount of data ?

francois-normandin commented 2 years ago

Of course.

What I'm saying is that such a benchmark will represent how fast is your transfer based on the type of payload you have to ferry around, not a universal benchmark for MQTT vs HTTP.

martin9115 commented 2 years ago

Is there any example, that can i use ? Is Labview support MQTT-SN ?

francois-normandin commented 2 years ago

Example: not that I know of. Be sure to factor in the latency to the server you are using when you write your code. Better make sure the servers (MQTT and HTTP) are both on the same machine, so that network latency is somewhat the same.

I don't know of any library that supports MQTT-SN in LabVIEW. MQTT-SN is limited subset of MQTT (ID instead of topic name) to create even smaller payloads, at the price of interoperability. Unless you are planning to develop your own MQTT-SN server, you can probably get by encoding directly into byte arrays for the simplest of nodes. At that point, it is little more than a direct TCP/UDP connection...