Slow log configuration is enabled in PHP-FPM (to detect slow PHP script execution)

Source: Internet
Author: User

Although through Nginx Accesslog can record user access to an interface or the time spent on a webpage, but can not be clearly traced to the specific location or the function is slow, so through the php-fpm slow log, Slowlog setting allows us to see which PHP processes are too slow to cause problems with the site

Php-fpm.conf has a parameter in the configuration file request_slowlog_timeout is described in this way

 for which  'slowlog'file'0s'off  '0= 0

When Request_slowlog_timeout is set to a specific second, Request_slowlog_timeout = 1, indicating which script execution time is greater than 1 seconds, the script is logged to the slow log file

Request_slowlog_timeout =0 indicates that slow log output is turned off.

The slow log file location defaults to the log folder in the PHP installation directory and can be specified by modifying the Slowlog = log/$pool. Log.slow parameter.

file  for  if= log/$pool. Log.slow

PHP-FPM Slow Log example, the slow log will record the process number, the script name, which file which line of code which function execution time is too long.

[ --may- .  -: -:Panax Notoginseng] Notice:child16683Stopped fortracing[ --may- .  -: -:Panax Notoginseng] Notice:about to trace16683[ --may- .  -: -:Panax Notoginseng] Notice:finished Trace of16683[ --may- .  -: -:Panax Notoginseng] WARNING: [Pool www] Child16720, script'/data/webapps/test/public/index.php'(Request:"post/index.php/test/test/") Executing too slow (1.204894SEC), logging

Request_slowlog_timeout and Slowlog need to be set at the same time, the request_slowlog_timeout need to turn on Slowlog, slow log path needs to be created manually

To turn on the php-fpm slow log step specifically:

cd/apps/phpvi /apps/php/etc/php-fpm.conf Remove request_slowlog_timeout, slowlog prefix semicolon ' ; ', set request_slowlog_timeout =1;: Wq save exit Create slow Log directory mkdir -p/apps/php/etc/  Log restart PHP-fpmkillall php-fpm/apps/php/sbin/php-fpm

Slow log configuration is enabled in PHP-FPM (to detect slow PHP script execution)

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.