search

Home  >  Q&A  >  body text

nginx - Is it good to set the number of php fastcgi processes to 0? How to set it?

The server has 4 cores and 8G memory, cpu (30-50%), memory (40-50%). 502 appears several times every day.
Checked netstat -anpo | grep "php-cgi" | wc -l
is 3

The following is the content of my /usr/local/php/etc/php-fpm.conf

[global]                                                                                                                                                            
pid = /usr/local/php/var/run/php-fpm.pid                                                                                                                            
error_log = /data/logs/php-fpm-error.log                                                                                                                            
log_level = notice                                                                                                                                                  
                                                                                                                                                                    
[www]                                                                                                                                                               
listen = /tmp/php-cgi.sock                                                                                                                                          
listen.backlog = -1                                                                                                                                                 
listen.allowed_clients = 127.0.0.1                                                                                                                                  
listen.owner = www                                                                                                                                                  
listen.group = www                                                                                                                                                  
listen.mode = 0777                                                                                                                                                  
user = www                                                                                                                                                          
group = www                                                                                                                                                         
pm = dynamic                                                                                                                                                        
pm.max_children = 400                                                                                                                                               
pm.start_servers = 80                                                                                                                                               
pm.min_spare_servers = 40                                                                                                                                           
pm.max_spare_servers = 240                                                                                                                                          
request_terminate_timeout = 100                                                                                                                                     
request_slowlog_timeout = 3                                                                                                                                         
slowlog = /data/logs/php_slow.log  

nginx error There are many
fastcgi request record is too big errors in the log. What is the reason?

Please help my friends on how to deal with my 502 problem, thank you!

黄舟黄舟2753 days ago1369

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-16 17:17:48

    pm = dynamic                                                                                                                                                        
    pm.max_children = 400                                                                                                                                               
    pm.start_servers = 80                                                                                                                                               
    pm.min_spare_servers = 40                                                                                                                                           
    pm.max_spare_servers = 240       

    Turn down, these settings are too big, frequent IO switching, you seem to be dying miserably now. And you don’t need to use the following configuration. pm.max_requests

    pm = dynamic                                                                                                                                                        
    pm.max_children = 64                                                                                                                                              
    pm.start_servers = 32                                                                                                                                             
    pm.min_spare_servers = 16                                                                                                                                           
    pm.max_spare_servers = 32
    pm.max_requests = 5000   

    reply
    0
  • Cancelreply