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
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.
# 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With