Log-php-fpm Slow log query

Source: Internet
Author: User
Tags fpm php error php error log system log
Project with PHP development, in the production process, it should be a period of time to monitor the running state of PHP script, which PHP process speed is too slow, what error log. Q: How do I check for slow-detection PHP scripts? A: Check the php-fpm slow log.
1. First find the configuration file to store the address
Find/-name php-fpm.conf


Vi/usr/servers/php/etc/php-fpm.conf


Open to see if your slow log is turned on, or where the slow log is stored. The corresponding address is replaced by your own.
2. If you do not open the slow log query, first open
The default request_slowlog_timeout is the 0,php slow script log is turned off, so it is set to n greater than 0, which means that scripts that execute more than n are logged into the slowlog. Then monitor the site when there are problems to see the next slowlog can find slow script, the script to check processing can be.
Request_slowlog_timeout and Slowlog need to be set at the same time, open the request_slowlog_timeout and need to open slowlog, slow log path needs to be manually created
Remove the request_slowlog_timeout, slowlog prefix semicolon '; '
Set Request_slowlog_timeout =1
: Wq    //Save exit Create slow Log directory
mkdir-p/var/logdata/php-fpm/php-fpm-slowlog.log
killall php-fpm/usr/servers/php/sbin/php-fpm//reboot PHP-FPM


3. Find the slow log store address




4. Observe slow log information
Tailf/var/logdata/php-fpm/php-fpm-slowlog.log



Once turned on, if a script executes for more than a specified time, a message similar to the following is written to the specified log file:
[19-dec-2016 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 (): The explanation is that the execution time is exceeded when the method is executed. Exfilter_curl_get (): Describes the method for calling Curl_exec () is Exfilter_curl_get (). The number following the colon of each line is the line number.

When turned on, there are also records in the error log file. As follows:
[19-dec-2016 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-2016 15:55:37] notice:child 18575 to stopped for tracing
[19-dec- 2016 15:55:37] Notice:about to trace 18575
[19-dec-2016 15:55:37] notice:finished trace of 18575


System log: Record system related information: http://blog.csdn.net/ty_hf/article/details/55511624 Apache access logs and error logs: http://blog.csdn.net/ty_hf/ article/details/55504719 nginx access log and error log: http://blog.csdn.net/ty_hf/article/details/55518070 php-fpm slow Log : Detect slow PHP script: http://blog.csdn.net/ty_hf/article/details/55504172 PHP error log: Detects PHP run or user logs error log: http:// blog.csdn.net/ty_hf/article/details/55505262 MySQL slow log: Record the performance sql:http://blog.csdn.net/ty_hf/article/in the MySQL server details/55504172
This article address: http://blog.csdn.net/ty_hf/article/details/55504172
Related Article

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.