博客園從今天上午就開始報502錯誤 , 他的原因還不知道 , 暫時先說下我們遇到502的排查情況
最大的可能性就是后端的服務不能支撐前端過來的tcp請求連接,包括連接資料庫服務時的連接數問題
1. php-fpm的行程是否啟動 ,沒啟動肯定報這個錯誤
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 is set to '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 is set to either 'static' or 'dynamic' ; Note: This value is mandatory. pm.max_children = 200 ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' ; 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 is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' pm.min_spare_servers = 10 ; The desired maximum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' 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;
代碼中有連接資料庫等的錯誤 , 導致執行時間過長了 , 檢查代碼等
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/232874.html
標籤:PHP
上一篇:PHP設計模式之簡單工廠模式
