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

Oct 14, 2016 am 10:51 AM

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
Copy after login

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
Copy after login


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)