Slow log analysis of php-fpm slow execution logs

Source: Internet
Author: User

Background: Watch PHP Slow log Generally speaking is mainly to look at the problem of network interface, there is a time when a server invokes the API interface, and the interface is on another machine, and someone maliciously calls through the interface, high bandwidth, resulting in a heap of Time_wait,nginx appear white page, at this time, This is the phenomenon, how to see the nature of the phenomenon, then open php-fpm slow log, how to open, and then look down.


As we all know, MySQL has slow query log, and we can tell that those SQL statements have performance problems based on the slow search logs. As a good partner for MySQL, PHP has the same functionality. If you use PHP-FPM to manage PHP, you can open it with the following options.
The PHP 5.3.3 was previously set as follows:

<value name= "Request_slowlog_timeout" >5s</value>
<value name= "Slowlog" >logs/php-fpm-slowlog.log</value>

Description

Request_slowlog_timeout is how long a script can be logged to a log file
Slowlog is the path to the log file

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:
Request_slowlog_timeout = 0s^m
Slowlog =/data/logs/php/slow.log^m


[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 (): Indicates 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:

Script_filename =/data/www/justwinit/index.php 
[0x00007ff0f9c9cdc8] curl_exec ()/data/www/justwinit/ application/class/weibo.class.php:2081 
[0X00007FF0F9C9CC40] oauthrequesthttp ()/data/www/justwinit/ application/modules/xweibo/xwb.com.php:767 
[0x00007fffeb65c010] getfsfollowers () unknown:0 
[ 0X00007FF0F9C9C990] Call_user_func_array ()/data/www/justwinit/application/core.php:3157 
[ 0X00007FFFEB65C350] Call () unknown:0 
[0x00007ff0f9c9c818] Call_user_func_array ()/data/www/justwinit/ application/core.php:3269 
[0x00007ff0f9c9c4c0] DR ()/data/www/justwinit/application/controllers/ ta.mod.php:375 
[0x00007ff0f9c9c330] default_action ()/data/www/justwinit/application/core.php:1819  
[0x00007ff0f9c9c1e8] M ()/data/www/justwinit/application/core.php:270 
[0x00007ff0f9c9c0f0] Request ()/data/www/justwinit/index.php:157 

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.