Home >Backend Development >PHP Tutorial >DZ forum often gets 502, please help

DZ forum often gets 502, please help

WBOY
WBOYOriginal
2016-08-04 09:22:231311browse

A small local portal with only a few thousand PVs suddenly started to close frequently.
log Tips:

<code>WARNING: [pool www] child 13760, script '/home/wwwroot/luntan/forum.php' (request: "GET /forum.php") execution timed out (77.310180 sec), terminating</code>

A certain cloud’s 4-core 4G 120G SSD cloud disk.

Centos 7 + Nginx + PHP5.4 + RDS (Mysql 5.6). Memcached is turned on

The main problem is that php is down. The PHP-FPM parameters are as follows:

<code>pm = dynamic
pm.max_children = 180
pm.start_servers = 100
pm.min_spare_servers = 60
pm.max_spare_servers = 180
pm.max_requests = 3096
pm.process_idle_timeout = 10s
request_terminate_timeout = 60
request_slowlog_timeout = 0</code>

From the performance monitoring point of view, when the website opening time becomes longer, the database reading also becomes longer. Do I need to adjust the database parameters? However, I looked at the database monitoring and found that all parameters, iops, connection usage, memory usage, etc., only reached a maximum of about 80%.

I really can’t figure it out, please help

Reply content:

A small local portal with only a few thousand PVs is suddenly closed now.
log Tips:

<code>WARNING: [pool www] child 13760, script '/home/wwwroot/luntan/forum.php' (request: "GET /forum.php") execution timed out (77.310180 sec), terminating</code>

A certain cloud’s 4-core 4G 120G SSD cloud disk.

Centos 7 + Nginx + PHP5.4 + RDS (Mysql 5.6). Turn on memcached

The main problem is that php is down. The PHP-FPM parameters are as follows:

<code>pm = dynamic
pm.max_children = 180
pm.start_servers = 100
pm.min_spare_servers = 60
pm.max_spare_servers = 180
pm.max_requests = 3096
pm.process_idle_timeout = 10s
request_terminate_timeout = 60
request_slowlog_timeout = 0</code>

From the performance monitoring, when the website opening time becomes longer, the database reading also becomes longer. Do I need to adjust the database parameters? However, I looked at the database monitoring and found that all parameters, iops, connection usage, memory usage, etc., only reached a maximum of about 80%.

I really can’t figure it out, please help

This situation looks like PHP has exhausted its resources and cannot handle new situations, and then it hangs.
However, it is impossible for thousands of PVs to cause such a result, and it is possible for thousands of UVs. Otherwise, it may be CC.
You can:

  1. Carry out load balancing to completely solve the problem

  2. Increase the number of sub-processes and the maximum number of requests for php-fpm to temporarily solve the problem.

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