PHP-FPM 7.0 + NGINX:空闲进程

PHP-FPM 7.0 + NGINX:空闲进程

我知道在 stackoverflow 或 serverfault 上有很多类似这样的问题的好答案,但我找不到我的问题的答案。

/status我的 php-fpm 7.0 进程有以下输出。

pool:                 www
process manager:      dynamic
start time:           04/Jul/2017:15:09:20 +0200
start since:          609
accepted conn:        6113
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       89
active processes:     11
total processes:      100
max active processes: 27
max children reached: 0
slow requests:        0

如您所见,我有很多空闲进程在等待执行某项任务。空闲进程是好做法还是坏做法?

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 550

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 100

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 50

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 150

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0

我尝试为我们的服务器找到完美的配置,因为有些东西正在泄漏我们的内存。日复一日,php 占用的内存越来越多,直到服务器停止工作。

如果我查看/status输出,我认为我定义的值www.conf太高了。我说得对吗?只有 27 个进程处于活动状态(最大),而有超过 80 个进程正在等待。这不是很糟糕吗?

感谢您的帮助!

相关内容