0

i know there are a lot of good answers for questions like this on stackoverflow or serverfault but i cant find answers for my questions.

I have following /status output for my php-fpm 7.0 processes.

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

As you can see i have a lot of idle processes waiting to get something to do. Are idle processes good or bad practice?

; 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

I try to find the perfect configuration for our server because something is leaking our memory. Day after day php is using more and more memory until the server stops working.

If i look at the /status ouput i think that my values defined in www.conf are too high. Am i right? There are only 27 processes active (max) i and have over 80 processes waiting. Isn´t that bad?

Thank you for helping!

  • It depends, and you haven't given enough information to help work it out. Idle php processes don't typically cause problems, but they use RAM that might be better used elsewhere, say by a database or RAM cache. A busy site or site with variable traffic might like to have many idle processes. There is even an "ondemand" mode that has on idle PHP processes, but that's not suitable for sites that get regular traffic. If you really want advice we'd need to know site traffic, server load, and what the server does. – Tim Jul 04 '17 at 19:23
  • Ok, we have 24 cores (Intel Xeon), 126 GB of ram on Ubuntu 16.04. We have round about 2,5 million users a month. We run php, nginx, elasticsearch and redis all on the same machine. The server load ist currently `load average: 4,94, 5,19, 5,74`. – Stillmatic1985 Jul 05 '17 at 06:16
  • Sounds like a busy server. I don't think anyone can answer your question, but maybe we can help you work it out. I think a little more monitoring or spot checking of the PHP stats on the server will answer this question for you. My guess is that that RAM can probably be better used for caching (redis or database if it's on the machine) than PHP, but you'd have to look at your cache statistics. If there's nothing else that could really benefit from the RAM there's not really any harm letting PHP use it. – Tim Jul 05 '17 at 09:11

0 Answers0