-
Notifications
You must be signed in to change notification settings - Fork 108
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
Reduce microservices memory footprint #12200
Comments
@mapellidario , yesterday I posted on MM chat to Alan and Andrea my observations which aligned with the ticket. Here is my posting (for completeness on the issue): Here is a proof of memory spike in I took test/python/WMCore_t/MicroService_t/MSRuleCleaner_t/MSRuleCleanerWflow_t.py code and added memory profile to one of the unit test as following:
Basically, I run over 10K requests which I modified slightly and call MSRuleCleanerWflow for each of them in a similar manner as MSRuleCleaner code is doing. Here is the outcome:
and, when I enable my for loop I see the following:
As you can see the first reported set of numbers which correspond to the test I modified spiked from 11KB to 1232KB. Therefore if we take MSRuleCleaner for loop at line https://github.com/dmwm/WMCore/blob/master/src/python/WMCore/MicroService/MSRuleCleaner/MSRuleCleaner.py#L262 and pass 10K requests you will see a spike of 1000x times in memory due to the memory allocation in Here is modified version I used MSRuleCleanerWflow_t.py To fix the problem few steps should be performed:
|
Thanks @mapellidario @vkuznet . |
@anpicci , I doubt that there is generic abstract implementation since it depends on data-structure of HTTP requests between services. But what probably should be done is the following:
Is it feasible? I think so, but it certainly will require lots of code re-factoring, therefore a proper management decision should be made if we'll spend time on such activity. |
Another approach would be to put a proxy server in front of CouchDB which will provide JSON and NDJSON streams such that clients to start migration from JSON request to NDJSON ones. Then, we'll need to modify each service to talk to proxy server instead of CouchDB and start using NDJSON. The proxy server is easier to write and maintain as it can be written separately, using different language and be fully transparent to MS services. Such proxy will provide an intermediate layer between a database (CouchDB) and the clients (MS services). But downside of this approach would be extra layer in networking stack, and coverage of different APIs. But such proxy server is similar to APS in its functionality as it provide a proxy between client and a database layer. |
Impact of the new feature
MicroServices
Is your feature request related to a problem? Please describe.
We realized that the microservices memory footprint depends on their backlog, for example for ms-rulecleaner at every polling cycle runs the function
_execute()
only once [1] on every workflow with a certain status [2]Describe the solution you'd like
Taking ms-rulecleaner as an example, we could change
getRequestRecords
into a generator that yields only a few workflows every time it is called. We would need to add a for loop inexecute()
around the call to_execute()
. Not a huge effort, achievable without consistent refactoring.Describe alternatives you've considered
The alternative would be to process once workflow at a time, possibly moving our model to a pub/sub, but this would require some major refactoring
Additional context
Follow-up to #12042 .
[1]
WMCore/src/python/WMCore/MicroService/MSRuleCleaner/MSRuleCleaner.py
Line 222 in beefc74
[2]
WMCore/src/python/WMCore/MicroService/MSRuleCleaner/MSRuleCleaner.py
Line 775 in beefc74
The text was updated successfully, but these errors were encountered: