I've got several low traffic vhost'ed applications that I'd like to run on the same box, using something like this configuration:

listen       = /tmp/example.com.socket
listen.owner = www-data
listen.group = www-data
listen.mode  = 0666

user  = www-data
group = www-data

pm                   = dynamic ; scale children according to this rule
pm.max_requests      = 1000    ; respawn child after so many requests
pm.max_children      = 12      ; cap the total number of children thus
pm.start_servers     = 6       ; children created at daemon boot
pm.max_spare_servers = 2       ; maximum number of idling children
pm.min_spare_servers = 1       ; minimum number of idling children

pm.status_path       = /php_pool_example.com_status

request_terminate_timeout = 30s
request_slowlog_timeout   = 20s
slowlog                   = /var/www/com/example/logs/php-slow.log

catch_workers_output = yes

env[TMP]      = /tmp
env[TMPDIR]   = /tmp
env[TEMP]     = /tmp

php_flag[display_errors]            = off
php_admin_value[error_log]          = /logs/php_err.log
php_admin_flag[log_errors]          = on

works okay, except that I'm not sure how to 'idle' a child so that php-fpm will kill it. The problem I'm seeing is that as I add more applications there exist ~6 idle php-fpm children per application, simply eating up RAM for no reason. Now, request_terminate_timeout will kill a child because of an over-long request, but not a child because of an overlong lack of requests. The manual defines how to say there are too many or too little idle children, but is quiet on designation. If I've measured that a php-fpm child which hasn't served a request for 30 minutes should be considered 'idle' and killed, how do I inform php-fpm of this?

  • Smart of you to post on the highload-en group! I selfishly hope you get some good info there as this is relevant to my config as well :) – iainlbc Oct 27 '11 at 1:47

The next stable version of php-fpm should support an ondemand scheduler that will scale children up and down. To date, there is no recourse.

| improve this answer | |

I just wanted to report that as of today ondemand works perfectly. With ondemand you can set pm.start_servers = 0 to stop idling processes:

pm = ondemand
pm.start_servers = 0
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.