-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add cgroups support to PHP-FPM pools #2440
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
Conversation
This patch allows to configure cgroup where to put php-fpm pool worker processes.
I'm not really sure if using libcg is a good idea considering that there are just 2 fixes in 2015 and all other development ends in 2014. So basically that library seems dead to me. What would be much better to have is our own pluggable interface that would support just the needed operations in drivers. Then we could have one driver for fs (preferably using v2 api) and one for systemd (yes something like what libcontainer does but on much smaller case to cover only the needed functionality). |
As for me, an example of dead library is libdbi (https://sourceforge.net/projects/libdbi/files/) which has huge memleaks without fixes for years. Libcgroup (libcg library + tools) just works and it does all it should to do. Yes, I'm agreed what systemd used widely for cgroups now. But I see no other way (without using this patch) how to separate pool processes into appropriate cgroup without starting many php-fpm instances (with dedicated fpm instance for each pool).
That will be more flexible, agreed.
What do you mean by 'fs'? Please point me.
How that can work / be configured for setting cgroup per pool? |
Well I think that's ok if you use it for your work but adding that to the upstream project is a different thing IMHO. We should really look if there is any work on the library before we add a dependency on it. By fs I mean doing operation on file system kernel API as documented in here https://www.kernel.org/doc/Documentation/cgroup-v2.txt . The libcg is just a wrapper around that (it's actually using v1 I think but in general it's just a wrapper around fs operations) I don't really know much about systemd and if it would be really useful for anything (even in the future). I just know that it has its own cgroup interface (which actually wraps fs api) and it is used libcontainer for some operations ( see https://github.com/docker/libcontainer/blob/master/cgroups/systemd/apply_systemd.go ) that also wraps fs api but has some systemd specific things in it. However that's not something that I'm suggesting to do. What I mean is that the API should be pluggable and the specific operation abstracted. But maybe that's something that could be added later. The main thing that I would prefer is having that done on the kernel API (preferably v2) rather then using libcg. |
Yes, I know about this difference, and after detailed analysis I agreed with you - adding support of (an become outdated) v1 cgroups is not an option. Our patch slightly outdated, I'm too late with publishing it :-) Thanks for your explanations. We will continue to use v1, but will try to start preparations for cgroups v2 as part of public work. Let's discuss future steps on this issue task.
New option should be added into 'global' section to point which library to load, right? Have you looked into sources to build your own draft plan how that can be implemented? Your support and mentoring is very welcome. |
Ah sorry I didn't actually mean pluggable in terms of having a dynamic loading of libs. I thought more about a generic API that can allow additional implementation. Basically in a similar way as it is done for fpm_event but just with the callbacks needed for cgroup operations (e.g. checking existence of cgroup, ataching current process into it and so on). In terms of global option it would certainly make sense to add an option (e.g. To sum it up the whole thing is mainly about abstracting the operation to the generic struct with callbacks for all needed operations and have one implementation that will be selected by default. |
So it looks like we are more interested in a kernel api version of this patch using the most recent API ... since the conversation kind of stopped there, I'm going to assume this work is abandoned and close the PR. |
I completely agree that 'kernel api is preferred', but for now I have no other patch proposals. When I will have, I will open new PR. Thanks. |
This patch allows to configure cgroup where to put php-fpm pool worker processes, configured per pool separately.
Moving workers into cgroup by external applications is too inaccurate and unuseable in heavily-loaded envirnonments. Applying cgroup to worker at its start is correct solution for this, and can be widely used to pool resource control and limiting.
We use this solution since 5.6, with 7.0 too. But these branches are already closed for new features, so I made PR against 7.1.
Many Thanks to PHP Team.