Score:0

Php-fpm is generating too many proccesses

in flag

I am using a VPS with 2 GB of RAM on a 1 core CPU. (Ubuntu 20.04 + nginx1.21.6 + php7.4 + Mariadb10.5)

And run 3 WordPress websites, and the average number of concurrent users is around 10.

But I recently saw the following error in the log of PHP-FPM.

[pool www] server reached pm.max_children setting (20), consider raising it

And I thought there was something wrong with the server, so I checked several parts.

Because I don't think there's any reason to get a max_children error with this number of visitors.

But no matter how much I check, I don't know why Php-fpm creates so many processors.

Here's the memory usage I checked with ps_mem:

  1.1 MiB + 145.5 KiB =   1.2 MiB       dbus-daemon
812.0 KiB + 488.5 KiB =   1.3 MiB       udisksd
  1.2 MiB + 110.5 KiB =   1.3 MiB       htop
  1.2 MiB + 138.0 KiB =   1.3 MiB       sftp-server (2)
  2.4 MiB +  82.5 KiB =   2.5 MiB       bash
  3.5 MiB + 786.5 KiB =   4.2 MiB       systemd (3)
  4.9 MiB +   1.4 MiB =   6.3 MiB       sshd (4)
 13.3 MiB + 369.5 KiB =  13.6 MiB       multipathd
 14.7 MiB +   3.0 MiB =  17.7 MiB       systemd-journald
 31.1 MiB +   5.8 MiB =  36.9 MiB       nginx (3)
 40.3 MiB +  39.5 KiB =  40.3 MiB       redis-server
 65.0 MiB +   1.2 MiB =  66.2 MiB       fwupd
189.6 MiB + 181.5 KiB = 189.7 MiB       mariadbd
639.8 MiB + 276.8 MiB = 916.5 MiB       php-fpm7.4 (21)

I also checked the access logs, but only a handful of visitors and bots were logged.

the main settings of my web server are as follows.

Timeout config

Nginx
    client_body_timeout 14;
    client_header_timeout 14;
    keepalive_timeout 25;
    send_timeout 13;
Server block
    fastcgi_read_timeout 30;
php 
    max_execution_time = 30

In www.conf

pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 15

In php.ini


[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
zend.enable_gc = On
zend.exception_ignore_args = On
expose_php = Off
max_execution_time = 30
max_input_time = 60
max_input_vars = 2000
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 65M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 64M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Pdo_mysql]
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
opcache.enable=1
opcache.memory_consumption=384
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=130986
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.error_log=/var/log/opcache_error.log

extension=imagick.so

Can someone advise on how to solve this problem or where else I should look again?

cn flag
Is that message `[pool www] server reached pm.max_children setting (20), consider raising it` appears in your log files constantly? If it is not - you don't need to worry, you've might be reached some accidental peak and it's not permanent.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.