-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use single curl session for Volkszaehler #117
Conversation
Not entirely sure what this does: execute requests sequentially? What happens if things start queuing up? How much latency does it add (thinking about realtime logging here)? The real load of |
The problem I tried to fix (and I think did fix ;-) with this PR is the following: in my setup I have two meter (d0 and ocr) and 6 channels (4 from d0 each sec., 2 from ocr each minute) pointing to the middleware running on the same raspberry pi. The current threading model does the following:
The 6 logging threads each use a separate curl connection to connect to the middleware. This causes 6 parallel connections for the local apache2 server performing 6 parallel connections to the mysql server,… with a good impact on cpu load and especially RAM usage (on a 256MB raspi quite important). My PR changes this in the following way:
So instead of each logging thread having it’s own curl session they share one (as they all want to talk to the same middleware instance). So instead of firing 6 parallel requests to the apache/middleware/mysql they basically get send sequentially, using the same curl session so talking to the same apache instance (as curl seems to keep the session open for some time and reuses it).
Gruß |
Agreed. It's the same I have done in the frontend by batching the requests into a single one that is sequentially evaluated.
Let me know when and if so I can prepare the data context for what you need. |
use single curl session for middleware requests
Thanks! Will do.
Gruß Matthias |
To reduce load if multiple channels towards the same middleware are in use I added some handling to use a synchronized curl session between the logging threads. In other words: the logging threads share a single curl session if they are communicating with the same middleware. Thus the http requests gets synchronized instead of being started in parallel. Currently only activated for Volkszaehler api but could easily be added for MySmartGrid as well.
E.g. on my system I have 4 channels from one meter towards the same middleware. I constantly have a load of >4 as there are 4 apache2 services active. Using this change the load gets <2.