Bug #77060 [NEW]: PHP-FPM pm.process_idle_timeout behaviour
| From: | contact at sshilko dot com | Date: | Thu, 25 Oct 2018 14:30:10 +0000 |
| Subject: | Bug #77060 [NEW]: PHP-FPM pm.process_idle_timeout behaviour | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217679@lists.php.net to get a copy of this message | ||
From: contact at sshilko dot com
Operating system: Amazon Linux 2
PHP version: 7.2.11
Package: FPM related
Bug Type: Bug
Bug description:PHP-FPM pm.process_idle_timeout behaviour
Description:
------------
Hello, i manage multiple AWS EC2 servers, with docker running on them.
I compile and deploy php, and have deep knowledge of configuration
options - to the level where i look up how things work in PHP source
code.
My question/bug is that php-fpm fastcgi server configuration option
pm_process_idle_timeout
as seen
http://php.net/manual/en/install.fpm.configuration.php
https://github.com/php/php-src/blob/1ad08256f349fa513157437abc4feb245cce03fc/sapi/fpm/fpm/fpm_process_ctl.c#L368
When set to low values doesnt make any difference: whether its 10
seconds or 1 second.
Typical scenario is i have 50 php-fpm child workers running, then with
traffic spike the go up to >150 workers. But when traffic spike is over
(after 10..50 seconds) the amount of workers remain between 150...140
for another 5-10 minutes, and basicly never goes down to previous level
of 50.
process_idle_timeout states
"The number of seconds after which an idle process will be killed. Used
only when pm is set to ondemand"
Which is not true.
Even if server is able to serve requests with <50 workers, it keeps >100
running after spike is over.
Does that happen because it round-robin requests thru all those 150
workers and each of 150 workers get a request in less than 1 second ?
Because my setting is process_idle_timeout=1
Test script:
---------------
Linux ip-172-30-0-201.ec2.internal 4.14.47-64.38.amzn2.x86_64 #1
PHP-FPM 7.2.11
[global]
process_control_timeout=10s
process.max=210
process.priority=0
log_level=warning
[www]
user = www-data
group = www-data
listen = /var/run/php7-fpm.sock
listen.owner = www-data
listen.group = www-data
pm.process_idle_timeout = 1;
security.limit_extensions=.php
;when pm=ondemand, backlog cant be lower than 511
listen.backlog = 511
request_terminate_timeout=902s
listen.allowed_clients=127.0.0.1
pm = ondemand
pm.max_children = 150
pm.start_servers = 80
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests=400
Nginx
fastcgi_index rawrpc.php;
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_buffer_size 4k;
fastcgi_buffering on;
fastcgi_buffers 8 4k;
fastcgi_cache nginxcache;
fastcgi_cache_bypass $skip_cache;
fastcgi_cache_valid 200 5m;
fastcgi_connect_timeout 15;
fastcgi_keep_conn on;
fastcgi_no_cache $skip_cache;
fastcgi_read_timeout 90;
fastcgi_request_buffering on;
fastcgi_send_timeout 5;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
Expected result:
----------------
Setting process_idle_timeout=1 will terminate workers to previous level
(before spike)
Actual result:
--------------
Setting process_idle_timeout=1 does not affect workers spawned amount at
all, all the child processes spawned keep on going for few more hours.
--
Edit bug report at https://bugs.php.net/bug.php?id=77060&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77060&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77060&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77060&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77060&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77060&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77060&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77060&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77060&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77060&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77060&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77060&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77060&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77060&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77060&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77060&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77060&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77060&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77060&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77060&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77060&r=mysqlcfg