Home  >  Article  >  Backend Development  >  页面是不是会出现502,怎么排查,是访问量过大吗

页面是不是会出现502,怎么排查,是访问量过大吗

WBOY
WBOYOriginal
2016-07-06 13:53:021500browse

PHP写的,页面是不是会出现502,怎么排查,是访问量过大吗

回复内容:

PHP写的,页面是不是会出现502,怎么排查,是访问量过大吗

大概先查这几个

  1. FastCGI 进程数

  2. Nginx等待php执行时间

<code>fastcgi_connect_timeout 0;
fastcgi_send_timeout 0;
fastcgi_read_timeout 0;</code>

3.php内存限制

<code>memory_limit</code>

如果前面有nginx做负载均衡的话,先查看一下nginx的日志

说白了就是后端挂了,当然不一定是PHP,如果你用CDN看到502的话可能是源站挂了。
排查方法楼上有说。

如果楼主是nginx+php-fpm的话,时不时502一般是php的问题。
原理是因为nginx反向代理去请求php-fpm后端的时候后端挂掉了。
我贴下我服务器的php-fpm.conf配置
本机内存1G(阿里云最小型的ECS)

<code>listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log</code>

具体参数要看楼主的主机配置。

nginx+php-fpm出现502 bad gateway错误解决方法

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn