Logic Machine Forum
Parallel processing in index.lp - 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: Parallel processing in index.lp (/showthread.php?tid=4017)



Parallel processing in index.lp - achang - 26.04.2022

Hello, 

I have a separate controller application hosted on GCP, and would like to send requests to the LogicMachine from my application and therefore need an endpoint. 
I have created a custom application within the LogicMachine using index.lp, and was able to send requests to it. The LogicMachine will then send requests to the KNX server using grp.write().

Now my question is, is there a way to use Lua script and Javascript within index.lp (or maybe widget.lp?) in order to send requests to the KNX server in parallel using something like JavaScript's promise.all()?

Any other ideas are also appreciated.

Thanks, and kind regards.


RE: Parallel processing in index.lp - admin - 26.04.2022

It's not possible to do in it parallel but even if it would there would not be any performance gains. Using plain HTTP for requests is very inefficient. Does your application support any other transports like MQTT?


RE: Parallel processing in index.lp - achang - 27.04.2022

Thanks for the reply!

Though I understand that HTTP requests are inefficient, I'd like to stick with it for now.
If doing it in parallel within one application is not possible, is it possible to run multiple separate custom LogicMachine applications in parallel?
For example, if index1.lp, index2.lp, and index3.lp exists and I send requests to all of them, would they be processed in parallel?


RE: Parallel processing in index.lp - admin - 27.04.2022

The web server can handle multiple connections at once but it does not matter whether you use a single or multiple endpoints.


RE: Parallel processing in index.lp - achang - 28.04.2022

So do you mean for multiple custom LM apps, when a request is sent to each application at the same time, it is processed in a single OS process?


RE: Parallel processing in index.lp - admin - 28.04.2022

Web server is a single OS process but it can handle multiple concurrent requests.

Since LM has a single core CPU nothing can truly happen in parallel. OS constantly switches between tasks but only a single task can actually be doing something at any time. grp calls are also processes one-by-one by any process that is listening to the object value changes.

As I've already mentioned if you have a lot of object updates your first bottleneck is the overhead that comes with using HTTP requests. From my tests LM can handle around 20..30 object writes per second via remote services. But that consumes quite a lot of CPU resources.