搜索

首页  >  问答  >  正文

nginx - php fastcgi进程数设为0好吗,该如何设?

服务器4核8G内存,cpu(30-50%),内存(40-50%)每天都会出现几次502
查了一下netstat -anpo | grep "php-cgi" | wc -l
是3

以下是我的/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 日志中有很多
fastcgi request record is too big错误是什么原因?

请朋友们帮忙看如何处理我的502问题,谢谢!

黄舟黄舟2749 天前1363

全部回复(1)我来回复

  • 怪我咯

    怪我咯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       

    调小,这些设置的太大了,频繁的IO切换,你现在似乎死的很惨。而且你少了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   

    回复
    0
  • 取消回复