Php Performance Analysis-Usage Analysis of php-fpm slow execution log slow log, php-fpmslow
This article describes the usage of php-fpm slow execution log slow log in php performance analysis. We will share this with you for your reference. The details are as follows:
As we all know, mysql has slow query logs. Based on slow query logs, we can know that SQL statements have performance problems. As a good partner of mysql, php also has this function. If you use php-fpm to manage php, you can enable it using the following options.
Before PHP 5.3.3, the settings are as follows:
<value name="request_slowlog_timeout">5s</value><value name="slowlog">logs/php-fpm-slowlog.log</value>
After PHP 5.3.3, set the following settings:
request_slowlog_timeout = 5sslowlog = /usr/local/php/log/php-fpm-slowlog.log
Note:
Request_slowlog_timeout indicates how long the script can be recorded in the log file.
Slowlog is the path of the log file.
After the script is enabled, if the execution of a script exceeds the specified time, the following information will be written to the specified log file:
[16:54:49] [pool www] pid 18575
Script_filename =/home/admin/web/htdocs/sandbox_canglong/test/tt. php
[0x0000000003a00dc8] curl_exec ()/home/admin/web/htdocs/sandbox_canglong/test/tt. php: 2
[0x0000000003a00cd0] exfilter_curl_get ()/home/admin/web/htdocs/sandbox_canglong/test/tt. php: 6
Log description:
Script_filename is the entry file
Curl_exec (): it indicates that the execution time of this method exceeds the execution time.
Exfilter_curl_get (): indicates that the method for calling curl_exec () is exfilter_curl_get ().
The number after each colon is the row number.
After it is enabled, relevant records are also logged in the error log file. As follows:
[15:55:37] WARNING: [pool www] child 18575, script'/home/admin/web/htdocs/sandbox_canglong/test/tt. php '(request: "GET/test/tt. php ") executing too slow (1.006222 sec), logging
[15:55:37] NOTICE: child 18575 stopped for tracing
[15:55:37] NOTICE: about to trace 18575
[15:55:37] NOTICE: finished trace of 18575