Home >类库下载 >PHP类库 >Make good use of php-fpm's slow execution log to analyze PHP performance issues

Make good use of php-fpm's slow execution log to analyze PHP performance issues

高洛峰
高洛峰Original
2016-10-14 10:51:131216browse

As we all know, MySQL has slow query log. According to the slow query log, we can know which SQL statements have performance problems. As a good partner of mysql, php also has such a function. If you use php-fpm to manage php, you can enable it through the following options.
The settings before PHP 5.3.3 are as follows:
5s
logs/php-fpm-slowlog.log

PHP 5.3.3 The settings after PHP 5.3.3 are as follows:
request_slowlog_timeout = 5s
slowlog = /usr/local/php/ log/php-fpm-slowlog.log

Explanation:
request_slowlog_timeout is how long it takes for the script to record to the log file
slowlog is the path to the log file

After it is turned on, if a script is executed for more than the specified time, it will Write information similar to the following in the specified log file:

[19-Dec-2013 16:54:49] [pool www] pid 18575
script_filename = /home/web/htdocs/sandbox_canglong/test/tt.php
[0x0000000003a00dc8] curl_exec() /home/web/htdocs/sandbox_canglong/test/tt.php:2
[0x0000000003a00cd0] exfilter_curl_get() /home/web/htdocs/sandbox_canglong/test/tt.php:6

Log description:
script_filename is the entry file
curl_exec(): It means that the execution time exceeds when executing this method.
exfilter_curl_get(): The method to call curl_exec() is exfilter_curl_get().
The number after the colon on each line is the line number.

After it is turned on, there are also relevant records in the error log file. As follows:

[19-Dec-2013 15:55:37] WARNING: [pool www] child 18575, script '/home/web/htdocs/sandbox_canglong/test/tt.php' (request: "GET /test/tt.php") executing too slow (1.006222 sec), logging
[19-Dec-2013 15:55:37] NOTICE: child 18575 stopped for tracing
[19-Dec-2013 15:55:37] NOTICE: about to trace 18575
[19-Dec-2013 15:55:37] NOTICE: finished trace of 18575


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more