Home > Backend Development > PHP Tutorial > Analysis of php performance analysis of php-fpm slow execution log slow log usage

Analysis of php performance analysis of php-fpm slow execution log slow log usage

coldplay.xixi
Release: 2023-04-09 10:26:01
forward
4311 people have browsed it

Analysis of php performance analysis of php-fpm slow execution log slow log usage

The example in this article describes the usage of slow log of php-fpm slow execution log for php performance analysis. Share it with everyone for your reference, the details are as follows:

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:

<value name="request_slowlog_timeout">5s</value>
<value name="slowlog">logs/php-fpm-slowlog.log</value>
Copy after login

The settings after PHP 5.3.3 are as follows:

request_slowlog_timeout = 5s
slowlog = /usr/local/php/log/php-fpm-slowlog.log
Copy after login

Instructions:

request_slowlog_timeout is how long it takes for the script to be recorded to the log file
slowlog is the path of the log file

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

[19-Dec-2013 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(): Description is when this method is executed exceeds the execution time.
exfilter_curl_get(): Description The method of calling 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/admin/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

related Learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of Analysis of php performance analysis of php-fpm slow execution log slow log usage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template