>  기사  >  백엔드 개발  >  php-fpm7.0 느린 쿼리 설정 및 지침

php-fpm7.0 느린 쿼리 설정 및 지침

藏色散人
藏色散人앞으로
2019-11-12 14:20:162033검색

환경 설명

root@ubuntu:/home/tb# cat /etc/issue
Ubuntu 16.04.2 LTS \n \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

그럼 거기 가서 www.conf를 변경하고 느린 쿼리에 대한 소개를 확인해 보겠습니다

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을 다시 시작하고 디렉터리 권한과 같은 일반적인 문제에 주의하세요

service php7.0-fpm reload

로그 에코 결과 보기

[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
#🎜 🎜#로그에 대한 설명

[03-Jan-2018 18:48:53]  [pool www] pid 4931
이에 대한 설명은 없습니다. 시간 프로세스 ID
script_filename = /usr/share/nginx/ testapp/index.php

실행 스크립트 이름, php 웹 애플리케이션은 단일 항목입니다# 🎜🎜#
[0x00007fb626213520] session_start() /usr/share/nginx/ testapp/app/models/user_model.php:11

이 세 번째 줄은 더 중요합니다. 스택 추적의 맨 위입니다. 이는 현재 실행된 메서드의 어떤 함수 호출이 임계값을 초과하는지와 특정 파일 및 코드 줄 번호 #🎜를 나타냅니다. 🎜 #

남은 부분은 호출 순서입니다(아래에서 위로, 결국 속도 저하 및 타임아웃이 발생함)

기타 지침

#🎜 🎜#

세 번째 줄이 컬_exec()와 유사하다고 판단되면 이는 일반적으로 네트워크 IO가 시간을 소모하기 때문입니다. . 참아보세요.

[0x00007fb6262136f0] curl_exec() /usr/share/nginx/

마찬가지로 mysql_query 등이 있으면 SQL 쿼리가 느려서 발생하는 경우도 있습니다관련 권장사항: "

PHP tutorial

" #🎜 🎜#

위 내용은 php-fpm7.0 느린 쿼리 설정 및 지침의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 segmentfault.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제