Is there a way to limit PHP-FPM memory usage in general or by site?

Just wondering how this works with InterWorx. I had one site that was using 2GB of RAM until I did a restart on PHP-FPM service from NodeWorx. There were some processes that had been started 3 days earlier.

Hi Justin

I hope your well

You can adjust the php-fpm each siteworx uses by editing the siteworx account from siteworx locate domain and click edit icon

It’s listed as package php-fpm settings

Many thanks

John

Yes, I am playing with those settings last night, but there is no max memory usage by site in these settings or some general setting for max memory usage in total of all PHP-FPM.

Closest I found was this:

Hello–

You control per-domain php memory usage by creating a .user.ini file for the domain and adding a memoriy_limit setting: How to: Set Individual/Per-Domain ini Configurations for Custom PHP Options — InterWorx documentation

There is not any kind of global file controlling all of php-fpm since there are multiple php versions that use php-fpm–each version is defined and controlled by its own php.ini file.

For instance, on this test server, I have the system level php version (8.0) using php-fpm, and I also have three php versions that were installed via the multiple php tool, which uses php-fpm by default.

There is a memory_limit setting in each corresponding php.ini file:

System PHP:

[root@testgajun9 ~]# grep memory_limit /etc/php.ini
memory_limit = 128M
[root@testgajun9 ~]#

PHP 5.4:

[root@testgajun9 php71]# grep memory_limit /opt/remi/php54/root/etc/php.ini
memory_limit = 128M
[root@testgajun9 php71]#

PHP 7.1:

[root@testgajun9 php71]# grep memory_limit /etc/opt/remi/php71/php.ini
memory_limit = 128M
[root@testgajun9 php71]#

PHP 7.2:

[root@testgajun9 php71]# grep memory_limit /etc/opt/remi/php72/php.ini
memory_limit = 128M
[root@testgajun9 php71]#

Thanks,
-Jenna

I’ve used .user.ini before for various things, but I thought that was just like a similar php.ini override, in this case how much memory a script could use while running.

I was thinking more of the PHP-FPM OPCache. I found one site was holding 2GB of RAM until I did a restart on the PHP-FPM service in NodeWorx.

Hello–

I checked in with the devs for you, and they said they did not think there really was an real good way to limit max memory usage per unixuser, nor globally for all of php-fpm. The closest they could think of that might work was c-groups but that may unforeseen consequences, and is not recommended.

Thanks,
-Jenna

1 Like