Logic Machine Forum
system load Http request vs Mqtt - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: system load Http request vs Mqtt (/showthread.php?tid=4492)



system load Http request vs Mqtt - tigi - 12.01.2023

Hi,

I was wondering if there is a big difference in system load when using Mqtt vs http requests.

I currently fetch the values of the energymeter using http request and data:match every 3 seconds and see a system load of .79% to .99%

I assume using Mqtt the system load will be less because the elimination of data:match code.
I also assume that fetching a webpage is more intensive then subscribing to a mqtt broker.

However I don't know if there will be a huge difference and if the juice is worth the squeeze.


RE: system load Http request vs Mqtt - Daniel - 12.01.2023

How many values and do you write every single one or on change?


RE: system load Http request vs Mqtt - tigi - 12.01.2023

(12.01.2023, 11:45)Daniel Wrote: How many values and do you write every single one or on change?

There are around 10 to 15 values I fetch and the page I fetch them from has only this data:

Code:
/FLU5\xxxxx_A
0-0:96.1.4(xxxx)
0-0:96.1.1(xxxxxxxxxxxx)
0-0:1.0.0(230112124557W)
1-0:1.8.1(000227.384*kWh)
1-0:1.8.2(000266.084*kWh)
1-0:2.8.1(000000.009*kWh)
1-0:2.8.2(000000.151*kWh)
0-0:96.14.0(0001)
1-0:1.7.0(02.269*kW)
1-0:2.7.0(00.000*kW)
1-0:21.7.0(02.184*kW)
1-0:41.7.0(00.035*kW)
1-0:61.7.0(00.049*kW)
1-0:22.7.0(00.000*kW)
1-0:42.7.0(00.000*kW)
1-0:62.7.0(00.000*kW)
1-0:32.7.0(230.6*V)
1-0:52.7.0(234.3*V)
1-0:72.7.0(233.8*V)
1-0:31.7.0(009.49*A)
1-0:51.7.0(000.25*A)
1-0:71.7.0(000.42*A)
0-0:96.3.10(1)
0-0:17.0.0(999.9*kW)
1-0:31.4.0(999*A)
0-0:96.13.0()
0-1:24.1.0(003)
0-1:96.1.1(374D495432323030303239363434)
0-1:24.4.0(1)
0-1:24.2.3(230112124555W)(00055.855*m3)
!xxxx



RE: system load Http request vs Mqtt - Daniel - 12.01.2023

... and do you write every single one or on change?


RE: system load Http request vs Mqtt - tigi - 12.01.2023

(12.01.2023, 11:53)Daniel Wrote: ... and do you write every single one or on change?


Sorry, I currently write every single one since only 3 or 4 values don't change that often, all other values are changed every second though I only capture it every 3 seconds.

Values are written to group objects using grp.update and also to storage using a storage.set at the end of the script.


RE: system load Http request vs Mqtt - Daniel - 12.01.2023

Then the high load is mostly generated by frequent writing. I strongly recommend to use grp.checkwrite, you can specify a delta to limit amount of writes.


RE: system load Http request vs Mqtt - tigi - 12.01.2023

(12.01.2023, 12:26)Daniel Wrote: Then the high load is mostly generated by frequent writing. I strongly recommend to use grp.checkwrite, you can specify a delta to limit amount of writes.


Thank you for the clarification!

I'll update the script accordingly and will also add some extra code so certain values only get written every 60 seconds or more since only 3 to 4 values are of importance.


RE: system load Http request vs Mqtt - Dré - 13.01.2023

(12.01.2023, 12:00)tigi Wrote:
(12.01.2023, 11:53)Daniel Wrote: ... and do you write every single one or on change?


Sorry, I currently write every single one since only 3 or 4 values don't change that often

Maybe this will help to update more often? i had that problem too.
grp.checkwrite / grp.checkupdate


RE: system load Http request vs Mqtt - tigi - 15.01.2023

(13.01.2023, 18:40)Dré Wrote:
(12.01.2023, 12:00)tigi Wrote:
(12.01.2023, 11:53)Daniel Wrote: ... and do you write every single one or on change?


Sorry, I currently write every single one since only 3 or 4 values don't change that often

Maybe this will help to update more often? i had that problem too.
grp.checkwrite / grp.checkupdate

I replaced all with grp.checkupdate and indeed the cpu load has dropped drastically. Thx for the tip!