[Nginx] 博客园出现了502错误该怎么追查原因
2023-02-18 15:36:39 时间
博客园从今天上午就开始报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;
代码中有连接数据库等的错误 , 导致执行时间过长了 , 检查代码等
相关文章
- 一次 Redis 事务使用不当引发的生产事故
- 前端基础(6) - 入门jQuery编程
- 前端基础(4) - CSS定位
- 前端基础(3) - CSS浮动
- 前端基础(2) - CSS入门
- 前端基础(1) - HTML入门
- 爬虫(15) - Scrapy-Redis分布式爬虫(2) | 实例:分布式爬虫项目
- 爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
- 爬虫(13) - 反爬虫(2) | 项目示例-爬取瓜子二手车网站数据
- 爬虫(12) - 反爬虫(1) | 详解
- 爬虫(11) - Scrapy框架(3) | 示例项目抓取并下载网站图片
- 爬虫(10) - Scrapy框架(2) | 伪装爬虫
- 爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
- 爬虫(8) - 可视化爬虫框架Selenium
- 爬虫(7) - 网页数据解析(3) | lxml解析数据
- 爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
- 爬虫(5) - 网页数据解析(1) | XPath在爬虫中的应用
- 解决方案:可以ping别人,但是别人不能ping我
- 爬虫(4) - Requests(3) | Requests常用场景方法
- 爬虫(3) - Requests(2) | Requests模块的方法、关键字和响应对象属性总结