php-fpm7.0 慢查询设置及说明
php  /  管理员 发布于 7年前   179
环境说明
root@ubuntu:/home/tb# cat /etc/issueUbuntu 16.04.2 LTS \n \lroot@ubuntu:/home/tb# php -vPHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )Copyright (c) 1997-2017 The PHP GroupZend 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 fpmroot 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 wwwwww-data 3686 1642 0 17:14 ? 00:00:03 php-fpm: pool wwwwww-data 3808 1642 0 17:43 ? 00:00:03 php-fpm: pool wwwroot 3930 2208 0 18:10 pts/0 00:00:00 grep --color=auto fpmroot@ubuntu:/home/tb#
php-fpm.conf的最后一行为
include=/etc/php/7.0/fpm/pool.d/*.conf
那我们去那里改www.conf,查看关于慢查询的介绍
314 ; The log file for slow requests315 ; Default Value: not set316 ; Note: slowlog is mandatory if request_slowlog_timeout is set317 ;slowlog = log/$pool.log.slow318319 ; The timeout for serving a single request after which a PHP backtrace will be320 ; 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: 0323 ;request_slowlog_timeout = 0
添加两行配置
slowlog=/var/log/php7.0/fpm/slow.logrequest_slowlog_timeout=1s
重启fpm,同时注意目录权限等一般问题
service php7.0-fpm reload
查看log回显结果
[03-Jan-2018 18:48:53] [pool www] pid 4934script_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 4931script_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
关于log的说明
[03-Jan-2018 18:48:53] [pool www] pid 4931
这个没啥解释,时间进程id
script_filename = /usr/share/nginx/ testapp/index.php
执行脚本名称,php web应用都为单入口
[0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11
这个第三行比较重要:是堆栈顶部信息(is the top of the stack trace),他说明指出了超出了阈值的当前执行的方法的函数调用是哪个,以及具体的文件及代码行数
剩下的其他部分就是 调用的顺序(从下往上,最终导致变慢超时的结果)
其他说明
如果发现第三行是以类似curl_exec(),比如:这一般是网络io占用了时间,如果是必须请求第三方,那么。。忍吧。
[0x00007fb6262136f0] curl_exec() /usr/share/nginx/
同样,如果有mysql_query之类的,也是由于sql 慢查询导致的
相关推荐:《PHP教程》
以上就是php-fpm7.0 慢查询设置及说明的详细内容,更多请关注其它相关文章!
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号