Nginx – Ever increasing mem usage by php-fpm

memory usagenginxPHPphp-fpm

It seems php-fpm is allocating more and more memory, although peaks and dips in amount of requests.
Couldn't post more than one image, so I put them here.

As you can see in the uri of the pictures, one pictures nginx requests, showing clear dips and peaks.
The others, which are php-fpm memory and average memory per child doesn't seem to follow the same pattern at all. Only a restart of php-fpm will have an effect, and even then I can't say I notice any change in performance.

The system is fine, response time is good and all is well, just curious if this is expected behaviour, and if it either has performance benefits or should be avoided (by lowering max_requests or something?).

System is running Debian GNU/Linux 6.0 Squeeze, AMD64. PHP version 5.3.6.
PHP 5.3.6

pool.d/www.conf:

pm.max_children = 50
pm.start_servers = 30
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1024

I have gotten these in php-fpm.log since it was freshly installed:

[28-Jun-2011 14:45:39] WARNING: [pool www] child 1893 exited on signal 9 (SIGKILL) after 22296.217811 seconds from start
[28-Jun-2011 14:45:39] NOTICE: [pool www] child 18391 started
[28-Jun-2011 14:45:39] WARNING: [pool www] child 1903 exited on signal 9 (SIGKILL) after 22296.213677 seconds from start
[28-Jun-2011 14:45:39] NOTICE: [pool www] child 18392 started
[28-Jun-2011 14:45:39] WARNING: [pool www] child 1904 exited on signal 9 (SIGKILL) after 22296.213757 seconds from start
[28-Jun-2011 14:45:39] NOTICE: [pool www] child 18393 started
[28-Jun-2011 14:45:39] WARNING: [pool www] child 1905 exited on signal 9 (SIGKILL) after 22296.214307 seconds from start
[28-Jun-2011 14:46:20] NOTICE: fpm is running, pid 18410
[28-Jun-2011 14:46:20] NOTICE: ready to handle connections
[28-Jun-2011 15:10:04] NOTICE: Terminating ...
[28-Jun-2011 15:10:04] NOTICE: exiting, bye-bye!
[28-Jun-2011 15:10:04] NOTICE: fpm is running, pid 1742
[28-Jun-2011 15:10:04] NOTICE: ready to handle connections
[28-Jun-2011 15:10:22] NOTICE: Terminating ...
[28-Jun-2011 15:10:22] NOTICE: exiting, bye-bye!
[28-Jun-2011 15:10:22] NOTICE: fpm is running, pid 2016
[28-Jun-2011 15:10:22] NOTICE: ready to handle connections
[28-Jun-2011 15:28:04] NOTICE: Terminating ...

Best Answer

Some ideas:

  1. Lower your fpm settings then increase as needed:

    pm.max_children = 10 # concurrent children's
    pm.start_servers = 2
    pm.min_spare_servers = 2
    pm.max_spare_servers = 4
    pm.max_requests = 300 # till restart

  2. Lower the nginx settigns.

  3. Install pecl-apc(Debian package is php5-apc).

  4. Update your php/nginx version to latest stable

What is your server spec?

Related Topic