As we all know, mysql has slowquerylog. 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:
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:
5S
Logs/php-fpm-slowlog.log
After PHP 5.3.3, set the following settings:
Request_slowlog_timeout = 5S
Slowlog =/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/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 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/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
Link to the original article: Use the php-fpm slow execution log slow log to analyze php performance