When my server receives many requests php-fpm records (php5-fpm.log) the following:
WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 6 total children
My php-fpm.conf is:
...
pm = dynamic
pm.max_children = 50
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 200
...
It seems that you need to change your php-fpm.conf.
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
As php-fpm.log shows,[pool www] seems busy.There are 6 total children and php-fpm will spawn 8 more.It means that there are not enough php-fpm processes. I suggest you increase pm.start_servers,pm.min_spare_servers and pm.min_spare_servers based on your server performance.
Related
Having set the pool to static with max_children to 5 I would expect the metric "active processes" to be 5 or below. Sending 10 concurrent requests will have "active processes" report more than 5 (e.g. 10, 12, 25, ...).
Is this valid behaviour?
Pool configuration:
# grep -v ";" /usr/local/etc/php-fpm.d/www.conf | grep -Ev "^$"
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
pm = static
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 10s
pm.max_requests = 500
pm.status_path = /status
ping.response = pong
slowlog = log/$pool.log.slow
request_slowlog_timeout = 0
request_terminate_timeout = 0
Expected result:
Metric "active processes" from /status should be below 5.
Actual result:
Metric "active processes" from /status is above 5.
According to the PHP FPM documentation when pm is set to static the only setting that determines the number of child processes is pm.max_children. As you expect, that should determine the start and max number.
A couple things to consider:
After changing the configuration did you restart both PHP-FPM and NGINX ? Something like:
sudo service php-fpm5 restart
sudo service nginx restart
Is it possible you are altering the wrong config file (perhaps one that is in the wrong path?). You might try changing some other value and confirm that it is affecting the web server as intended.
Is it possible that you have multiple pools configured and that the /status page is giving you a report for multiple pools.
I have a setup of nginx + php-fpm on my server.
FPM's pool configuration looks like this:
[www]
user = root
group = root
listen = /run/php-fpm.sock
listen.owner = root
listen.group = root
pm = ondemand
pm.max_children = 50
pm.process_idle_timeout = 10s
pm.max_requests = 500
pm.status_path = /server-status
catch_workers_output = yes
My first expectation is, that no child php-fpm processes are started unless there's an incoming request. Unfortunately, when I start php-fpm I promptly see 2 processes:
10 ? S 0:00 php-fpm: master process (/etc/php/7.1/fpm/php-fpm.conf)
37 ? S 0:00 php-fpm: pool www
So, one process is pre-forked for some reason.
My second expectation is that all processes idling for more than 10s will be killed. I run a test which results in the creation of 13 processes. After 1 minute or so (no more requests performed) around 5 processes are idling. Why is it so?
php-fpm crash every morning at 7pm (I don't have specific cron at this time), log say :
WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 39 idle, and 180 total children
Server hardware :
nproc : 40
RAM: 256Go
here is www.conf of php-fpm :
[www]
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 350
pm.start_servers = 40
pm.min_spare_servers = 40
pm.max_spare_servers = 70
pm.process_idle_timeout = 60s;
pm.max_requests = 500
request_terminate_timeout = 0
chdir = /
php_flag[display_errors] = off
php_admin_value[error_reporting] = 0
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 1024M
php_admin_value[session.save_path] = /tmp/
I already try to increase max_children value but it change nothing
Please check the following image:
Output of: htop -u www-data
My current configuration of pool.d/www.conf is:
pm = ondemand
pm.max_children = 4
pm.process_idle_timeout = 10s;
pm.max_requests = 50
It's a 4 core cpu with 8gb ram. Ram usage is considerably less. If I have set max_children = 4, does that mean it there can be only 4 processes? (In screenshot, there are more than 8 php-fpm processes)
And sometimes, it just stays at 100% in all 4 cores and website gives a 502 error till I restart php5-fpm.
I had VPS with CentOS 6.4 64bit. There is running Nginx 1.4.4 and PHP-FPM 5.5.6. I'm trying to make long-polling requests. However, if server is already processing one request, he doesn't respond to other. This mean, that if I have script with:
sleep(60);
PHP doesn't process other request. I must wait for 60 seconds. PHP status page is:
pool: www
process manager: dynamic
start time: 26/Nov/2013:22:02:00 +0100
start since: 148
accepted conn: 170
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 1
active processes: 49
total processes: 50
max active processes: 49
max children reached: 1
slow requests: 0
And je conf.d/www.conf:
[www]
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
pm.status_path = /status
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache