502 Bad Gateway dig deep

Source: Internet
Author: User
Tags php error log connection reset

The morning received 502 alarm, set the alarm rule is 502 error two minutes more than 500 on the alarm.

Troubleshooting process:

Log Analysis System report--View Log system log-->nginx error log-->php error log-->php-fpm.log log

In the log analysis system to see the production of 502 alarm machine Only one xxx.xxx.xxx.170, the client IP is only one, the description is not a large-scale failure.

Connect to 170 server to view Nginx error log, see connection reset by peer, connection is reset by the other side, instructions PHP shut down this connection

 ./ A/ in  ,: -:Geneva[ERROR]1328#0: *766316197Recv () failed (104: Connection reset by Peer) whileReading response Header fromUpstream, client:123.206.95.156, Server:jifen.Wuyi. com, Request:"Get/center/index http/1.0", Upstream:"fastcgi://127.0.0.1:9000", Host:"jifen.51.com", referrer:"http://jifen.51.com/" ./ A/ in  ,: -:Geneva[ERROR]1328#0: *766316178Recv () failed (104: Connection reset by Peer) whileReading response Header fromUpstream, client:123.206.95.156, Server:jifen.Wuyi. com, Request:"Get/center/index http/1.0", Upstream:"fastcgi://127.0.0.1:9000", Host:"jifen.51.com", referrer:"http://jifen.51.com/" ./ A/ in  ,: -:Geneva[ERROR]1328#0: *766316153Recv () failed (104: Connection reset by Peer) whileReading response Header fromUpstream, client:123.206.95.156, Server:jifen.Wuyi. com, Request:"Get/center/index http/1.0", Upstream:"fastcgi://127.0.0.1:9000", Host:"jifen.51.com", referrer:"http://jifen.51.com/" ./ A/ in  ,: -:Geneva[ERROR]1328#0: *766316055Recv () failed (104: Connection reset by Peer) whileReading response Header fromUpstream, client:123.206.95.156, Server:jifen.Wuyi. com, Request:"Get/center/index http/1.0", Upstream:"fastcgi://127.0.0.1:9000", Host:"jifen.51.com", referrer:"http://jifen.51.com/"

Continue to view the log, see PHP error log, there is nothing.

Then look at the Php-fpm.log log file and see that the index.php script execution timed out for more than 30 seconds.

[ in-dec- .  ,: -: the] WARNING: [Pool www] Child22751Exited on signal the(SIGTERM) after10765.182746Seconds fromstart[ in-dec- .  ,: -: the] NOTICE: [Pool www] Child10703started[ in-dec- .  ,: -: the] WARNING: [Pool www] Child10257Exited on signal the(SIGTERM) after10287.255584Seconds fromstart[ in-dec- .  ,: -: the] NOTICE: [Pool www] Child10705started[ in-dec- .  ,: -: One] WARNING: [Pool www] Child11311, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(31.152266sec), terminating[ in-dec- .  ,: -: One] WARNING: [Pool www] Child1432, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(31.370696sec), terminating[ in-dec- .  ,: -: One] WARNING: [Pool www] Child15998, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(30.236601sec), terminating[ in-dec- .  ,: -: One] WARNING: [Pool www] Child17886, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(31.273963sec), terminating[ in-dec- .  ,: -: One] WARNING: [Pool www] Child11019, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(30.752849sec), terminating[ in-dec- .  ,: -: One] WARNING: [Pool www] Child19115, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(31.055392sec), terminating[ in-dec- .  ,: -: One] WARNING: [Pool www] Child9978, script'/opt/wwwroot/jifen.51.com/www/index.php'(Request:"Get/center/index") Execution timed out(30.037908SEC), terminating

Open the php-fpm.conf configuration file, set the Request_terminate_timeout = 30 set of a single script execution more than 30s will be terminated.

And in the php.ini config file Max_execution_time = 60, set a single script to execute up to 60s.

The cause of the error was found, and the reason for the 502 bad Gateway was that the script execution timed out. Given the single case, only one user has 502 errors, not all user connections appear 502, and in order to relieve the server pressure, the Request_terminate_timeout value is not adjusted.

502 Bad Gateway dig deep

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.