摘要:同樣,如果有之類的,也是由于慢查詢導(dǎo)致的參考鏈接配置
環(huán)境說明
root@ubuntu:/home/tb# cat /etc/issue Ubuntu 16.04.2 LTS l root@ubuntu:/home/tb# php -v PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies查看php-fpm配置路徑
root@ubuntu:/home/tb# ps -ef |grep fpm root 1642 1 0 10:17 ? 00:00:01 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf) www-data 3685 1642 0 17:14 ? 00:00:04 php-fpm: pool www www-data 3686 1642 0 17:14 ? 00:00:03 php-fpm: pool www www-data 3808 1642 0 17:43 ? 00:00:03 php-fpm: pool www root 3930 2208 0 18:10 pts/0 00:00:00 grep --color=auto fpm root@ubuntu:/home/tb#
php-fpm.conf的最后一行為
include=/etc/php/7.0/fpm/pool.d/*.conf
那我們?nèi)ツ抢锔?b>www.conf,查看關(guān)于慢查詢的介紹
314 ; The log file for slow requests 315 ; Default Value: not set 316 ; Note: slowlog is mandatory if request_slowlog_timeout is set 317 ;slowlog = log/$pool.log.slow 318 319 ; The timeout for serving a single request after which a PHP backtrace will be 320 ; dumped to the "slowlog" file. A value of "0s" means "off". 321 ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 322 ; Default Value: 0 323 ;request_slowlog_timeout = 0添加兩行配置
slowlog=/var/log/php7.0/fpm/slow.log request_slowlog_timeout=1s
重啟fpm,同時(shí)注意目錄權(quán)限等一般問題
service php7.0-fpm reload查看log回顯結(jié)果
[03-Jan-2018 18:48:53] [pool www] pid 4934 script_filename = /usr/share/nginx/ testapp/index.php [0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11 [0x00007fb6262134a0] __construct() /usr/share/nginx/ci_2.2.0/core/Loader.php:303 [0x00007fb626213390] model() /usr/share/nginx/ testapp/app/core/my_Controller.php:39 [0x00007fb6262132e0] __construct() /usr/share/nginx/ testapp/app/controllers/home.php:8 [0x00007fb626213270] __construct() /usr/share/nginx/ci_2.2.0/core/CodeIgniter.php:308 [0x00007fb6262130e0] [INCLUDE_OR_EVAL]() /usr/share/nginx/ testapp/index.php:325 [03-Jan-2018 18:48:53] [pool www] pid 4931 script_filename = /usr/share/nginx/ testapp/index.php [0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11 [0x00007fb6262134a0] __construct() /usr/share/nginx/ci_2.2.0/core/Loader.php:303 [0x00007fb626213390] model() /usr/share/nginx/ testapp/app/core/my_Controller.php:39 [0x00007fb6262132e0] __construct() /usr/share/nginx/ testapp/app/controllers/home.php:8 [0x00007fb626213270] __construct() /usr/share/nginx/ci_2.2.0/core/CodeIgniter.php:308 [0x00007fb6262130e0] [INCLUDE_OR_EVAL]() /usr/share/nginx/ testapp/index.php:325關(guān)于log的說明
[03-Jan-2018 18:48:53] [pool www] pid 4931
這個(gè)沒啥解釋,時(shí)間進(jìn)程id
script_filename = /usr/share/nginx/ testapp/index.php
執(zhí)行腳本名稱,php web應(yīng)用都為單入口
[0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11
這個(gè)第三行比較重要:是堆棧頂部信息(is the top of the stack trace),他說明指出了超出了閾值的當(dāng)前執(zhí)行的方法的函數(shù)調(diào)用是哪個(gè),以及具體的文件及代碼行數(shù)
剩下的其他部分就是 調(diào)用的順序(從下往上,最終導(dǎo)致變慢超時(shí)的結(jié)果)
其他說明
如果發(fā)現(xiàn)第三行是以類似curl_exec(),比如:這一般是網(wǎng)絡(luò)io占用了時(shí)間,如果是必須請(qǐng)求第三方,那么。。忍吧。
[0x00007fb6262136f0] curl_exec() /usr/share/nginx/
同樣,如果有mysql_query之類的,也是由于sql 慢查詢導(dǎo)致的
參考鏈接php-fpm配置
how-to-read-the-php-slow-request-log
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/26284.html
摘要:前言作為一名程序員,比碼代碼還重要那么一點(diǎn)點(diǎn)的東西就是日志的分析和查詢。下面列出常見日志及設(shè)置方法。設(shè)置慢查詢?nèi)罩镜纳赡夸浽O(shè)置慢查詢的標(biāo)準(zhǔn)時(shí)間打開此配置就相當(dāng)于開啟了慢查詢?nèi)罩?,配置以秒為單位,一般設(shè)置。 showImg(https://blog.fastrun.cn/wp-content/uploads/2018/07/74072834b3e92ffc915ddd9e2cd3a93...
視頻地址 學(xué)徒卡夫 - 卡夫的Mac 03 - Mac下使用Docker配置PHP環(huán)境 https://www.bilibili.com/vide... 安裝 Docker https://www.docker.com/docker... 下載鏡像 # 安裝基礎(chǔ)鏡像 - ubuntu:14.04 # 拉取鏡像(拉取鏡像經(jīng)常會(huì)失敗,嘗試幾次就好了) docker pull ubuntu:14.0...
視頻地址 學(xué)徒卡夫 - 卡夫的Mac 03 - Mac下使用Docker配置PHP環(huán)境 https://www.bilibili.com/vide... 安裝 Docker https://www.docker.com/docker... 下載鏡像 # 安裝基礎(chǔ)鏡像 - ubuntu:14.04 # 拉取鏡像(拉取鏡像經(jīng)常會(huì)失敗,嘗試幾次就好了) docker pull ubuntu:14.0...
閱讀 1624·2021-11-11 10:59
閱讀 2628·2021-09-04 16:40
閱讀 3663·2021-09-04 16:40
閱讀 2982·2021-07-30 15:30
閱讀 1621·2021-07-26 22:03
閱讀 3169·2019-08-30 13:20
閱讀 2230·2019-08-29 18:31
閱讀 442·2019-08-29 12:21