fg71
Do you know why webserver.py is so slow?
 
Something say to me this is because of flask and not slow hardware. Sometimes its not enough to click once to start plc or its takes almost 1 second to click between the menu. And sometimes there also need to be execution twice to make something working.
 
And I have also seen a demo from you @thiagoralves, clicking twice to start plc. (So I guess you already know this) 😉
 
What could we do about it, any idea ??
 
Some idea,
 
2500 line of code should run faster I think 😉, do you not agree.
Reply 0 0
davenardella
The web server is just a service interface, its operations are sporadic over time, the important thing is that the openplc binary is fast.
 
If it can console you, loading a program and sending a €3000 CPU to run/stop, with TIA Portal it is even slower. 😁
Reply 0 0
fg71
Would it not be possible to use async with flask I believe 2.x does support it.
Maybe it will be a quick change if you seek a challenge 😉
 
Ps. Are you the Dave from RetroMagazine ?? 🙂
Reply 0 0
fg71
I was doing some logging why Start PLC did not always work.
And in the log I could see there was some error so I decide to edit in webserver.py
I do not have any dnp3 or enip devices so the responds from flask was much faster
and only 1 click is working to Start PLC.
 
I believe it could be that OpenPLC_v3 have little difficulty with openplc_runtime.stop_enip()
By disable the protocol checks I find the responds to be faster or less error.
 
[203128%2F9258137%2Fmceclip0]
Reply 0 0
thiagoralves
Do you know why webserver.py is so slow?
 
Yes, the web frontend is slow. And the reason why is because its architecture sucks. For the past 10 years OpenPLC was built on my spare time as a hobby project. I never expected it to scale as it did. The result is that it didn't get as much love as it deserved. Features were being pushed out without too much thought on the architecture behind it. All I wanted was to publish something that worked so users can benefit from it. And that's particularly how the webserver was built. There are several shortcomings to it, mainly in the way it communicates with the C runtime. That's why it is so slow and unresponsive sometimes. And that's also why it only works on Chrome! 😂
 
But this all started to change about 18 months ago when I started Autonomy. Thanks to the funding from our sponsors, I was able to assemble a team to redo this project the right way. We started with the OpenPLC Editor as that was needing more love than the runtime. The result is OpenPLC Editor v4 that is out already. Eventually our rework process will reach the runtime as well, and then you will see big improvements there too. Stay tuned 🙂
Reply 0 0
fg71
I have to admit I try to use async and await in the Webserver.py to see if I could make it better, that try fail in the main function.
Or that is what the error come. Next I think I remove whose error and got it to run. But I didn't have UI so I guess it fail again.
Maybe I will give it a try once more when I know more about async and await approach in flask version 2.x
At least that is what OpenPLC_v3 is using.
 
I thought it would be a simple change, but its was not a success 🙂
Reply 0 0
thiagoralves
Async and await won't change absolutely anything speed-wise. The webserver is not heavy in terms of requests. As I said, the problem is actually in the architecture. The HTML page wasn't built correctly to be real-time/responsive.
Reply 0 0
Reply