Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WARNING: [pool inter] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children,

Tags:

php

nginx

I have a problem with nginx and php-fpm, i searched already in this form but i found no solution for it.

Server: 16 cores 10gb memory

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

[i]
listen = /var/run/fastcgi/i.sock    
listen.allowed_clients = 127.0.0.1    
listen.group = i

user = i

group = inter
pm = dynamic

pm.max_children = 20    
pm.max_requests = 1000

pm.start_servers = 15    
pm.min_spare_servers = 15

pm.max_spare_servers = 15    
;request_terminate_timeout = 300

php_admin_value[error_log] = /var/log/php-fpm/i-error.log    
php_admin_flag[log_errors] = on

php_value[session.save_handler] = files    
php_value[session.save_path] = /var/lib/php/ = /

php_admin_value[open_basedir] = /www/public_html/:/tmp:/usr/share/php:/var/lib/php

strong textphp_admin_value[disable_functions] = dl,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

i tried a lot of differnt settings, but i don't know what is the reason, i hope sombody can help.

Best regards

like image 935
zaur osmanov Avatar asked Dec 19 '25 00:12

zaur osmanov


1 Answers

The root cause of your problem can't be determined because we don't know what kind of code your server runs.

What happens is that PHP can't process requests fast enough to keep up with nginx.

Raising number of child processes won't help, you have 16 cores and 20 processes. This means that your OS will be forced to schedule processes and raising the number won't make anything faster - you don't even know if you are CPU or I/O bound.

To correctly solve this problem, you need to determine why PHP can't keep up.

You can enable PHP-FPM slow_log feature by adding this to your pool:

slowlog = /var/log/php-fpm/slow.log
request_slowlog_timeout = 1s

This will log every request that took 1 second or longer to file /var/log/php-fpm/slow.log

Inspect the log file and trace back which part of your code causes PHP to respond slowly and fix the real problem


To keep your site responsive until you fix the real problem is that you get another server for PHP processing. Since you are using nginx and php-fpm is your backend, then it's quite trivial to set up more servers to handle dynamic request processing. As your site grows and demands grow with it, you can easily add more backend processing power by adding php-fpm serves to processing pool.

Disclaimer: I am not saying that you should but it's good to know what your options are.

Example configuration file for nginx for multiple PHP backends

    # Define servers in the cluster
    upstream phpcluster {
        server 10.0.0.1:9000;
        server 10.0.0.2:9000;
    }

    location ~ \.php$ {
        try_files                   $uri /index.php =404;
        fastcgi_split_path_info     ^(.+\.php)(/.+)$;
        fastcgi_pass                phpcluster; # Pass to phpcluster upstream. Additional load balancing rules can be defined in upstream block
        fastcgi_index               index.php;
        fastcgi_param               SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }  
like image 122
Mjh Avatar answered Dec 21 '25 12:12

Mjh