PHP Performance Tuning---PHP-FPM Enable slow log configuration (used to detect slow PHP scripts)

Source: Internet
Author: User
Tags fpm php performance tuning

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

; The timeout for serving a single request after which a PHP backtrace would be; Dumped to the ' slowlog ' file. A value of ' 0s ' means ' off '.; Available units:s (econds) (default), M (inutes), H (ours), or D (ays); Default value:0; Request_slowlog_timeout = 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.

; The log file for slow requests; Default Value:not set; Note:slowlog is mandatory if request_slowlog_timeout is set; Slowlog = 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.

[27-may-2016 13:20:37] Notice:child 16683 stopped for tracing[27-may-2016 13:20:37] notice:about to trace 16683[27-may-2016 13:20:37] Notice:f inished trace of 16683[27-may-2016 13:20:37] WARNING: [Pool www] child 16720, script '/data/webapps/test/public/index.php ' (Request: "post/index.php/test/test/") executing too Slow (1.204894 sec), 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 quit Create slow log directory mkdir-p/apps/php/etc/log restart Php-fpmkillall php-fpm/apps/php/sbin/php-fpm

PHP Performance Tuning---PHP-FPM Enable slow log configuration (used to detect slow PHP scripts)

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.