After buying an ECS, the system automatically installs nginx 1.6 + php 5.3.28 + mysql 5.5
After the PHP program is put into the ECS, the first test program access is normal and the speed is normal.
However, after you put the program online for access, you will gradually find that the PHP page is getting slower and slower, and the 502 bad gateway problem occurs directly.
(In the php-fpm.conf, the pm = static mode was originally set and pm. max_children = 128)
Analysis:
When the nginx access log is opened, the traffic volume is not high, and the average number of requests per second is less than 10 IP addresses. Therefore, the traffic volume cannot cause too many PHP requests, resulting in 502 of requests.
Turning on the php-fpm.conf log has a lot of PHP warning problems,
Then adjust the pm mode of php-fpm to pm = dynamic,
The code is as follows: |
Copy code |
Pm. start_servers = 20 Pm. min_spare_servers = 5 Pm. max_spare_servers = 35 Pm. max_requests = 10000 After restarting php-fpm, use ps to view the php process: Ps-ef | grep-c php-fpm 22 At the beginning, access to PHP was fast and then getting slower. Check the process again. Ps-ef | grep-c php-fpm 28 |
From the log and process changes, we can conclude that it is a problem with the PHP program, which is caused by too many PHP requests. This is probably because too many PHP requests are called on the PHP page. After the problem is reported to the developer, after the developer solves the problem, no 502 error occurs on the server.
From the above configuration, we have configured the number of requests. Of course, this configuration is not the best. If you still encounter such problems, you can adjust the parameters.