This article is a mirror article of machine translation, please click here to jump to the original article.

View: 5057|Reply: 0

php-fpm slowlog slowlog analyzes website bottlenecks

[Copy link]
Posted on 12/19/2021 11:43:12 AM | | | |
When developing a website using PHP, if some PHP dynamic pages are very slow to access after launch, we can analyze the bottleneck of the website through php-fpm slow logs.

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

First, check all processes via the top -c command to see the configuration file address loaded by php-fpm, as shown in the figure below:



FPM configuration

parameter: -p, dynamically modify --prefix in the command line

include=etc/php-fpm.d/*.conf to contain one or more files if glob(3) exists (glob() function returns a filename or directory that matches the specified pattern)

php-fpm loads a sub-configuration file, $pool variable can be used in any directive, and it will replace the corresponding process pool name. For example: here[www]

Turn on slow logs

enter/usr/local/etc/php-fpm.dSub-configuration file, find www.conf (according to your actual situation), PHP 5.3.3 and later versions are set as follows:

; 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 = 1s
; 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 should 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 = 10s
Note: request_terminate_timeout Terminate a process that has been running for too long directly

request_slowlog_timeout Write files that are too slow to execute to the log

From now on, you can optimize the program files according to the slow execution log /usr/local/php/log/php-fpm.log.slow!





Previous:Baidu Library cannot replicate the solution
Next:Practical Operation: Java uses hutool to send emails
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com