LNMP Optimization and problem summary

Source: Internet
Author: User
Tags bz2 error handling php script sqlite cpu usage high cpu usage
Nginx error log: PHP fastcgi connection Timeout, view nginx and PHP-FPM timeout value no problem error message (nginx error log): 2012/06/03 11:24:02 [ERROR] 920#0: * 6197285 upstream timed out (110:connection timed out) while reading the header from response, upstream. 1.90, Server:localhost, Request: "Post/api/api.php http/1.1", Upstream: "fastcgi://127.0.0.1:9000", Host: "50.XX." Xx. XX ", referrer:" app:/xxx.swf "solution: Improve PHP processing capability by increasing the PHP-FPM process, Pm.max_children value from 50 to 100, increase in the same way Pm.start_servers,pm.min_ Value of Spare_servers,pm.max_spare_servers
Production server recommended error handling level

Recommended Use error_reporting = E_all & ~e_deprecated, log records notice, easy to check the wrong, such as memcached connection problems, such as many key errors notice level online game, To get rid of all the notice problems, and monitor the Nginx log purpose: To ensure that the game does not have any error messages appear, the error message to deal with the solution: First, the game online, must do a step is to monitor the error log, processing any error messages; Timed script, found the error log has content, Send mail, monitor error log nginx error log: PHP fastcgi connection Timeout, view nginx and PHP-FPM timeout value is not a problem, by adding Max_children still does not solve the problem cause analysis: View server Load_ Average, the result found that the load was too large. Continue to analyze the program, found in the program by PHP read the file and passed to the front end of the picture. Solution: PHP does not have to do not take the flow of the way to transfer pictures to the client, by the Nginx directly to the client, see Nginx whether keep_alive long connection, if it is to stop the keep_alive function, you can reduce the load, Too much concurrency also needs to be turned off keep_alive features resolved after a new problem: The server load down, but still have connection timeout caused php-fpm blocking solution: Open php-fpm slow log, request_slowlog_timeout = 30s (PHP-FPM mode max_execution_time invalid), Slowlog =/usr/local/webserver/php/var/log/php-fpm.log.slow                     limit php-fpm maximum execution time, request_terminate_timeout = 30s       &NBSP ;             record load average log, reads server load average every minute and logs to log files to detect problems through log monitoring: PHP-FPM slow log, Slow script execution is not recorded, and only the execution steps that PHP-FPM thinks are causing the entire script to slow down are recorded;     &nbsp              php script execution time of more than 10 seconds (different servers may not be the same) can lead to high CPU usage, so PHP is not suitable for long request processing, only for short request processing solution: Avoid long processing, if there is long processing, using other solutions nginx, PHP-FPM status monitoring problem: PHP-FPM often down, temporarily found no problem temporary solution: Find nginx status and PHP-FPM Status/ping/pong , by manually monitoring the peak state, writing scripts, monitoring problems through the status and restart PHP-FPM new problem: When php-fpm jams, php-fpm Ping can still return the value, so the script will not restart PHP-FPM solution: Write a test php file, By monitoring whether this file can be a normal rhetorical question to restart PHP-FPM yum error:  centos5.5 execution yum Command error, primary.sqlite.bz2:Metadata file does not match checksum solve : cd/var/cache/yum/addons            sudo yum clean all            sudo Yum Makecache            sha1sum primary.sqlite.bz2         & nbsp   Change primary_db value to sha1sum result <checksum type= "Sha" >0e039f885793bddf6c3bf9821a51ff0983fffb76</checksum >

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.