Use the slow execution log slowlog of php-fpm to analyze php performance problems

Source: Internet
Author: User
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

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.