Site 502 and 504 error analysis

A. Joking whether you do or do development operation and maintenance, even if you are a tourist, from time to time encounter or 502 Bad Gateway 504 Gateway Time-out. This page appears, under the service restart, then it is not under restart the server, the problem is solved, but the problem still haunt you, especially to do the operation and maintenance personnel. Dark and stormy night sleep timing, a phone rings, let you restart the service or IISRESET, it is certainly a great unhappy, flew to greet his mother. Oh, this paper summarizes the 502 and 504 failure analysis and solutions. Second Status code interpreter 502 Bad Gateway: as a gateway or proxy server try to perform a work request received from the upstream to the server invalid response. 504 Gateway Time-out: a gateway or proxy server as job execution request attempts, failed from the upstream server (URI identified server, e.g. HTTP, FTP, LDAP) or a secondary server (e.g., DNS) response is received. Three. 502 Bad Gateway Analysis Submit a request to the gateway as php-fpm execution, but for some reason has not been completed resulting in php-fpm process terminated. Having said this, this issue is very clear, and gateway services such as php-fpm related to the configuration. php-fpm.conf configuration file has two parameters you will need to take into account, namely max_children and request_terminate_timeout. max_children maximum number of child processes, at high concurrent requests, the maximum number of responses php-fpm, subsequent requests 502 error occurs. You can view the current number of connections by the netstat command. request_terminate_timeout set the timeout period terminates a single request. It should also be noted that the max_execution_time parameter in php.ini. When a request for termination, an error also occurs 502. When I accumulated a lot of php request that you restart php-fpm release resources, but less than a minute or two, and 502 appear again, which is what causes it? At this point you should also take into account the database to see if the database under process a large number of locked process, resulting in a database deadlock timeout, front-end termination request to continue, but the SQL statement is still waiting for the release of the lock, then we should restart the database service or kill SQL deadlock out the process. For a long time, consider using asynchronous requests, you can see " Research on PHP asynchronous operation ." Four. 504 Gateway Time-out Analysis 504 error is usually related to the configuration and nginx.conf. Mainly related to the following parameters: fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout, fastcgi_buffer_size , fastcgi_buffers, fastcgi_busy_buffers_size, fastcgi_temp_file_write_size, fastcgi_intercept_errors. Especially in the first three timeout. If the buffer is too small will lead to fastcgi fastcgi process to be suspended so that the evolution of 504 error. V. Summary In summary, error 502 mainly from four directions: 1. max_children 2. request_terminate_timeout, max_execution_time 3. 4. database gateway service is started as an error php-fpm 504 on the main view nginx.conf fastcgi as the gateway configuration. For reprint please indicate the source: http: //www.ttlsa.com/html/3112.html

Reproduced in: https: //my.oschina.net/766/blog/210976

Guess you like

Origin blog.csdn.net/weixin_34198881/article/details/91547929