Enable slow log slowlog for nginx php-fpm

Source: Internet
Author: User
Tags fpm stop script

The php-fpm slow log slowlog setting allows us to see which php processes are too slow to cause website problems.

We can easily find the problem.

The code is as follows: Copy code

Vi/data1/server/php-cgi/etc/php-fpm.conf

 
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
Slowlog =/data1/log/$ pool. log. slow
 
; The timeout for serving a single request after which a PHP backtrace will be
; Dumped to the 'slowlog' file. A value of '0s' means 'off '.
; Available units: s (econds) (default), m (inutes), h (ours), or d (ays)
; Default Value: 0
Request_slowlog_timeout = 1 s

Both request_slowlog_timeout 0s must be set to disable, that is, slowlog is useless.

1 s indicates that processing in more than 1 s will be recorded.

How many seconds is the execution slow?

The code is as follows: Copy code

/Data1/server/php-cgi/var/log/php-fpm.log

[19-Apr-2013 12:40:35] WARNING: [pool www] child 29514, script'/xx/www/adx/tx/tm. php '(request: "GET/tx/tm. php ") executing too slow (1.034708 sec), logging


Add the slow log tutorial for different php versions.

PHP versions earlier than 5.3.3 are set as follows:

The code is as follows: Copy code

The timeout (in seconds) for serving a single request after which the worker process will be terminated
Shocould be used when 'max _ execution_time 'ini option does not stop script execution for some reason
'0s' means 'off'
<Value name = "request_terminate_timeout"> 10 s </value>
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow. log file
'0s' means 'off'
<Value name = "request_slowlog_timeout"> 1 s </value>
The log file for slow requests
<Value name = "slowlog"> logs/slow. log </value>


PHP 5.3.3 and later versions are set as follows:

The code is as follows: Copy code

; The timeout for serving a single request after which a PHP backtrace will be
; Dumped to the 'slowlog' file. A value of '0s' means 'off '.
; Available units: s (econds) (default), m (inutes), h (ours), or d (ays)
; Default Value: 0
Request_slowlog_timeout = 1 s

; The log file for slow requests
; Default Value:/usr/local/php/log/php-fpm.log.slow
Slowlog =/usr/local/php/log/php-fpm.log.slow

; The timeout for serving a single request after which the worker process will
; Be killed. This option shocould be used when the 'max _ execution_time 'ini option
; Does not stop script execution for some reason. A value of '0' means 'off '.
; Available units: s (econds) (default), m (inutes), h (ours), or d (ays)
; Default Value: 0
Request_terminate_timeout = 10 s

Note: request_terminate_timeout terminates a process that has been executed for too long.

Request_slowlog_timeout writes slow files to logs.

Later, you can optimize the program file based on the slow execution log/usr/local/php/logs/slow. log!

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.