반응형
NGING에서 PHP-FPM 상태를 활성화하고 모니터링하는 방법
nginx 설정
vim /etc/nginx/conf.d/default.conf
$ vim /etc/nginx/conf.d/default.conf
...
# nginx, php-fpm status
location ~ ^/(status|ping)$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
allow 127.0.0.1;
allow 10.11.0.0/16;
allow 10.21.0.0/16;
allow 10.31.0.0/16;
deny all;
access_log off;
}
php-fpm 설정
vim /etc/php-fpm.d/www.conf
$ vim /etc/php-fpm.d/www.conf
...
;ping.path = /ping
pm.status_path = /status
php-fpm status 호출
PHP-FPM 기본 상태
curl -s localhost/status
$ curl -s localhost/status
pool: www
process manager: dynamic
start time: 15/Oct/2020:14:22:08 +0900
start since: 4756
accepted conn: 13755
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 15
active processes: 1
total processes: 16
max active processes: 10
max children reached: 0
slow requests: 0
curl -s localhost/status?json | jq
$ curl -s localhost/status?json | jq
{
"pool": "www",
"process manager": "dynamic",
"start time": 1602739328,
"start since": 4623,
"accepted conn": 13482,
"listen queue": 0,
"max listen queue": 0,
"listen queue len": 0,
"idle processes": 14,
"active processes": 2,
"total processes": 16,
"max active processes": 10,
"max children reached": 0,
"slow requests": 0
}
php-fpm 상태
- pool - the name of the pool. Mostly it will be www.
- process manager - possible values static, dynamic or ondemand. We never use static. Trying ondemand is on todo list.
- start time - the date and time FPM has started or reloaded. Reloading PHP-FPM (service php5-fpm reload) reset this value.
- start since - number of seconds since FPM has started
- accepted conn - the number of request accepted by the pool
- listen queue - the number of request in the queue of pending connections. If this number is non-zero, then you better increase number of process FPM can spawn.
- max listen queue - the maximum number of requests in the queue of pending connections since FPM has started
- listen queue len - the size of the socket queue of pending connections
- idle processes - the number of idle processes
- active processes- the number of active processes
- total processes - the number of idle + active processes
- max active processes - the maximum number of active processes since FPM has started
- max children reached - number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase max process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.
- slow requests - Enable php-fpm slow-log before you consider this. If this value is non-zero you may have slow php processes. Poorly written mysql queries are generally culprit.
728x90
PHP-FPM 전체 상태
curl -s localhost/status?full
$ curl -s localhost/status?full
pool: www
process manager: dynamic
start time: 15/Oct/2020:14:22:08 +0900
start since: 5961
accepted conn: 17169
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 14
active processes: 2
total processes: 16
max active processes: 10
max children reached: 0
slow requests: 0
************************
pid: 21021
state: Idle
start time: 15/Oct/2020:14:22:08 +0900
start since: 5961
requests: 1073
request duration: 31941
request method: GET
request URI: /index.php
content length: 0
user: -
script: /opt/public/index.php
last request cpu: 93.92
last request memory: 2097152
************************
pid: 21022
state: Idle
start time: 15/Oct/2020:14:22:08 +0900
start since: 5961
requests: 1077
request duration: 23221
request method: GET
request URI: /index.php
content length: 0
user: -
script: /opt/public/index.php
last request cpu: 86.13
last request memory: 2097152
************************
pid: 21023
state: Idle
start time: 15/Oct/2020:14:22:08 +0900
start since: 5961
requests: 1071
request duration: 17155
request method: POST
request URI: /index.php
content length: 58
user: -
script: /opt/public/index.php
last request cpu: 58.29
last request memory: 2097152
php-fpm 상태
- pid - the PID of the process. You can use this PID to kill a long running process.
- state - the state of the process (Idle, Running, …)
- start time - the date and time the process has started
- start since - the number of seconds since the process has started
- requests - the number of requests the process has served
- request duration - the duration in µs of the requests
- request method - the request method (GET, POST, …)
- request URI - the request URI with the query string
- content length - the content length of the request (only with POST)
- user - the user (PHP_AUTH_USER) (or ‘-‘ if not set)
- script - the main PHP script called (or ‘-‘ if not set)
- last request cpu - the %cpu the last request consumed. it’s always 0 if the process is not in Idle state because CPU calculation is done when the request processing has terminated
- last request memorythe - max amount of memory the last request consumed. it’s always 0 if the process is not in Idle state because memory calculation is done when the request processing has terminated
참고URL
- 변군이글루 블로그 : NGINX와 PHP-FPM을 연동하여 PHP 스크립트를 처리하는 방법
- 변군이글루 블로그 : CentOS 7에서 PHP-FPM 7.4를 설치하는 방법
- PHP Documentation : PHP Manual Configuration
728x90
반응형
'리눅스' 카테고리의 다른 글
도커 컨테이너에서 타임존을 설정하는 방법 (0) | 2020.10.27 |
---|---|
취약점을 방지하기 위한 보안 HTTP 헤더를 설정하기 (0) | 2020.10.21 |
NGINX 및 PHP-FPM Access Log 포맷 설정 (1) | 2020.10.15 |
리눅스에서 tcping을 설치하고 사용하는 방법 (0) | 2020.10.14 |
openssl 인증서 만료일 조회 (0) | 2020.10.14 |