经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » PHP » 查看文章
[Nginx] 博客园出现了502错误该怎么追查原因
来源:cnblogs  作者:陶士涵  时间:2020/12/14 17:27:58  对本文有异议

博客园从今天上午就开始报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 

  1. ; Note: This value is mandatory.
  2. pm = dynamic
  3. ; The number of child processes to be created when pm is set to 'static' and the
  4. ; maximum number of child processes to be created when pm is set to 'dynamic'.
  5. ; This value sets the limit on the number of simultaneous requests that will be
  6. ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
  7. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
  8. ; CGI.
  9. ; Note: Used when pm is set to either 'static' or 'dynamic'
  10. ; Note: This value is mandatory.
  11. pm.max_children = 200
  12. ; The number of child processes created on startup.
  13. ; Note: Used only when pm is set to 'dynamic'
  14. ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
  15. pm.start_servers = 30
  16. ; The desired minimum number of idle server processes.
  17. ; Note: Used only when pm is set to 'dynamic'
  18. ; Note: Mandatory when pm is set to 'dynamic'
  19. pm.min_spare_servers = 10
  20. ; The desired maximum number of idle server processes.
  21. ; Note: Used only when pm is set to 'dynamic'
  22. ; Note: Mandatory when pm is set to 'dynamic'
  23. 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;

 

代码中有连接数据库等的错误 , 导致执行时间过长了 , 检查代码等

 

原文链接:http://www.cnblogs.com/taoshihan/p/14113897.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号