search
Home类库下载PHP类库Make good use of php-fpm's slow execution log to analyze PHP performance issues

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

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


Statement
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

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool