Home >Backend Development >PHP Tutorial >Will there be a 502 on the page? How to check? Is the number of visits too high?

Will there be a 502 on the page? How to check? Is the number of visits too high?

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

Written in PHP, will a 502 appear on the page? How to check? Is it because the number of visits is too large?

Reply content:

Written in PHP, will a 502 appear on the page? How to check? Is it because the number of visits is too large?

Probably check these first

  1. Number of FastCGI processes

  2. Nginx waits for php execution time

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

3.php memory limit

<code>memory_limit</code>

If nginx is used for load balancing before, check the nginx log first

To put it bluntly, it means that the backend is down. Of course, it is not necessarily PHP. If you see 502 using CDN, it may be that the origin site is down.
The troubleshooting method is mentioned above.

If the poster is nginx php-fpm, 502 from time to time is usually a PHP problem.
The principle is that the backend hangs when the nginx reverse proxy requests the php-fpm backend.
I posted the php-fpm.conf configuration of my server
1G local memory (Alibaba Cloud’s smallest 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>

The specific parameters depend on the host configuration of the host.

Solution to 502 bad gateway error in nginx php-fpm

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