为什么 PHP-FPM 仅使用一个进程?

为什么 PHP-FPM 仅使用一个进程?

查看我的 PHP-FPM 统计页面,看起来现在只有一个进程正在处理所有连接。

我的猜测是,到目前为止,请求的执行速度非常快,因此还不需要使用其他流程。会是这样吗?

以下是我在 PHP-FPM 统计页面中看到的内容:

pool                    www
process manager         static
start since             432796
accepted conn           90399
listen queue            0
max listen queue        1
listen queue len        128
idle processes          63
active processes        1
total processes         64
max active processes    6
max children reached    0

我的 PHP-FPM 配置如下:

[General]
 pid = /var/run/php5-fpm.pid
 error_log = /var/log/php5-fpm.log
 syslog.ident = php-fpm
 syslog.facility = 24
 log_level = unknown value
 emergency_restart_interval = 0s
 emergency_restart_threshold = 0
 process_control_timeout = 0s
 process.max = 0
 process.priority = undefined
 daemonize = yes
 rlimit_files = 30000
 rlimit_core = 0
 events.mechanism = epoll

[www]
 prefix = undefined
 user = www-data
 group = www-data
 listen = 127.0.0.1:9000
 listen.backlog = 128
 listen.owner = undefined
 listen.group = undefined
 listen.mode = undefined
 listen.allowed_clients = 127.0.0.1
 process.priority = undefined
 pm = static
 pm.max_children = 64
 pm.start_servers = 8
 pm.min_spare_servers = 4
 pm.max_spare_servers = 10
 pm.process_idle_timeout = 10
 pm.max_requests = 12800
 pm.status_path = /fpm
 ping.path = undefined
 ping.response = undefined
 access.log = undefined
 access.format = undefined
 slowlog = /var/log/www.log.slow
 request_slowlog_timeout = 5s
 request_terminate_timeout = 120s
 rlimit_files = 30000
 rlimit_core = 0
 chroot = undefined
 chdir = /
 catch_workers_output = yes
 security.limit_extensions = .php .phar

答案1

为什么 PHP-FPM 仅使用一个进程?

因为... 1 就足够了。但这并不意味着活动进程数始终为 1。

将终端分成两个区域:在第一个区域输入:

$ watch 'lynx -dump http://domain.com/fpm'

在第二个中,尝试如下操作:

$ ab -c 1000 -n 10000 http://domain.com/fpm

然后看看第一个区域发生的情况:

pool:                 www
process manager:      dynamic
start time:           04/Sep/2012:23:19:24 +0700
start since:          3441
accepted conn:        42296
listen queue:         0
max listen queue:     8
listen queue len:     128
idle processes:       18
active processes:     3
total processes:      21
max active processes: 21
max children reached: 0

相关内容