Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the 502 error in CVM

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to solve 502 errors in cloud servers". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Analysis of the causes of 502 error

The request is submitted to the gateway, such as php-fpm execution, but for some reason the execution of the php-fpm process is terminated. Then the problem is related to the configuration of gateway services such as php-fpm. The maximum number of child processes in max_children. If the maximum number of php-fpm responses is reached under high concurrent requests, 502 errors will occur in subsequent requests. You can view the current number of connections through the netstat command.

Request_terminate_timeout sets the timeout termination time for a single request. You should also notice the max_execution_time parameter in php.ini. A 502 error also occurs when the request is terminated.

When a large number of php requests are accumulated, restart php-fpm to release resources at this time, but within a few minutes, the 502 error occurs again. Why? At this time, we should also consider whether it is related to the CVM database and check whether there are a large number of locked processes in the database process. The database deadlock causes a timeout, and the frontend terminates the request for continuation, but the SQL statement is still waiting for the lock to be released. At this time, the database service will be restarted or kill will lose the deadlock SQL process.

Solution with 502 error

When there is a 502 problem on the website, you can first solve it through the following two steps:

1. Check whether the current number of PHP FastCGI processes is sufficient for netstat-anpo | grep "php-cgi" | wc-l if the actual "number of FastCGI processes" is close to the preset "number of FastCGI processes", it means that the "number of FastCGI processes" is not enough and needs to be increased.

2. The execution time of some PHP programs exceeds the waiting time of Nginx, so the timeout time of FastCGI in nginx.conf configuration file can be increased appropriately.

If the memory_limit setting in php.ini is too low, modify the memory_limit of php.ini to 64m, and restart nginx, which means that PRH is out of memory.

3, max-children and max-requests a server running nginx php (fpm) xcache, daily visits of about 300W pv often occur: php pages open very slowly, cpu utilization suddenly dropped to a very low, system load suddenly rose to a very high, look at the network card traffic, you will find that suddenly dropped to a very low. Usually this situation can only last for a few seconds to recover.

There are many reasons for the 502 error on the website on the CVM, and the solutions are different for different reasons. When the 502 error occurs, our first task is to find out where the problem lies and where the problem occurs. It is much more convenient to solve the problem.

This is the end of the content of "how to solve 502 errors in CVM". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report