博客园从今天上午就开始报502错误,他的原因还不知道,暂时先说下我们遇到502的排查情况
最大的可能性就是后端的服务不能支撑前端过来的tcp请求连接,包括连接数据库服务时的连接数问题
2. tcp连接数超过了fpm的进程数
netstat -altupn|grep EST|grep PHP|wc -l
查看当前tcp连接,比较自己fpm的进程数
/etc/PHP-fpm.d/www.conf
; Note: This value is mandatory. pm = dynamic ; The number of child processes to be created when pm is set to 'static' and the ; maximum number of child processes to be created when pm dynamic. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP ; CGI. ; Note: Used when pm set to either ' or ; Note: This value mandatory. pm.max_children = 200 ; The number of child processes created on startup. ; Note: Used only when pm ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 pm.start_servers = 30 ; The desired minimum number of idle server processes. ; Note: Used only when pm ; Note: Mandatory when pm pm.min_spare_servers = 10 ; The desired maximum number of idle server processes. ; Note: Used only when pm pm.max_spare_servers = 50
3.FastCGI执行时间过长
根据实际情况调高以下参数值
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
4.FastCGI Buffer不够
Nginx和apache一样,有前端缓冲限制,可以调整缓冲参数
fastcgi_buffer_size 32k;
fastcgi_buffers 8 32k;
5.Proxy Buffer不够
如果你用了Proxying,调整
proxy_buffer_size 16k;
proxy_buffers 4 16k;