Slide 1

Slide 1 text

PHP-FPM  2018 12 15 @PHP Conference 2018  Zaim naoki85

Slide 2

Slide 2 text

naoki85 •  Zaim: 2017 10 •   naoki85_201612 PHP Ruby 

Slide 3

Slide 3 text

800      

Slide 4

Slide 4 text

Zaim     https://blog.zaim.co.jp

Slide 5

Slide 5 text



Slide 6

Slide 6 text

Zaim Zabbix  Slack    Slack   

Slide 7

Slide 7 text

…  

Slide 8

Slide 8 text

  PHP-FPM     FPM 

Slide 9

Slide 9 text

 &"! $#'   PHP 7  $#    %

Slide 10

Slide 10 text

     … …

Slide 11

Slide 11 text

PHP     WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 42 total children  

Slide 12

Slide 12 text

  PHP-FPM    

Slide 13

Slide 13 text

 http://php.net/manual/ja/install.fpm.php

Slide 14

Slide 14 text

 % https://qiita.com/kotarella1110/items/634f6fafeb33ae0f51dc  $   ! #"  

Slide 15

Slide 15 text

CGI _Common Gateway Interface` "#)&/(*-%,+IW03 PC B=8PV_$,! .'`ZJ A \[  &/(*-%,+:3B= >9QOD $,! .'\5 1S4 &/(*-%,+2*-%,+ <7  6NTG$,! .'\5 FLUH  @M &/(*- %,+?^*-%,+]EL;K CGI  Wikipedia  PHP@XTGWeb&/(/[ $,! . 'YR 

Slide 16

Slide 16 text

Fast CGI CGI27'7bV J-5)(XLZRa"! FfbV!> -5)(XLZRHN !  +,$7.6(KB^  FastCGI-5)(#0148U]YdA  dA[: Og# @W \Q -5%3/A

Slide 17

Slide 17 text

Web%%2ApacheNginx3 ❖Apache ❖Nginx l !"%#+  PHP,1 - */  l Web%%)& $ PHP' 2CGI ,1(.3 l CGI  PHP $0' 

Slide 18

Slide 18 text

࣮ࡍʹࢼͤͳ͍ͩΖ͏͔ɻɻ!

Slide 19

Slide 19 text

ϩʔΧϧͰ/HJOY 1)1'1. Λ;BCCJYͰ؂ࢹ͢Δαϯϓϧ https://github.com/naoki85/monitor_php_with_zabbix

Slide 20

Slide 20 text

● docker ● Zabbix Alpine Linux   ● Nginx ● PHP-FPM ϩʔΧϧͰ/HJOY 1)1'1. Λ;BCCJYͰ؂ࢹ͢Δαϯϓϧ

Slide 21

Slide 21 text



Slide 22

Slide 22 text

ςετʹ͸ "QBDIF#FODIΛ࢖༻ https://httpd.apache.org/docs/2.4/programs/ab.html ex) ab -n 1000 -c 10 http://127.0.0.1/

Slide 23

Slide 23 text

ϩάͳͲͷઃఆ

Slide 24

Slide 24 text

FPM  status_path pm.status_path = /fpm-status ex) http://localhost/fpm-status

Slide 25

Slide 25 text

  ex) access.log = /var/log/php7/$pool.access.log   ex) php_admin_value[error_log] = /var/log/php7/$pool.error.log php_admin_flag[log_errors] = on   ex) slowlog = /var/log/php7/$pool.slow.log request_slowlog_timeout = 10s php_admin_value[error_l

Slide 26

Slide 26 text

 ❖static ❖dynamic ❖ondemand

Slide 27

Slide 27 text

static ❖  ❖pm.max_children  max_children 5 

Slide 28

Slide 28 text

static active process idle process 5 1 4 0

Slide 29

Slide 29 text

static ❖Active process  Idle process  max_children   

Slide 30

Slide 30 text

dynamic ❖  ❖pm.max_children:  ❖pm.start_servers:   ❖pm.min_spare_servers:   ❖pm.max_spare_servers:  

Slide 31

Slide 31 text

dynamic    ❖pm.max_children: 5 ❖pm.start_servers: 2 ❖pm.min_spare_servers: 1 ❖pm.max_spare_servers: 3

Slide 32

Slide 32 text

dynamic active process idle process 5 1 2 0

Slide 33

Slide 33 text

dynamic total process Available Memory 5 2

Slide 34

Slide 34 text

dynamic ❖   max_children  ❖Active process   Idle process 

Slide 35

Slide 35 text

ondemand ❖$'% " ❖pm.max_children: & ❖pm.process_idle_timeout: !( )%+ ❖ pm.start_servers #  *

Slide 36

Slide 36 text

ondemand active process idle process 5 1

Slide 37

Slide 37 text

ondemand ❖ " !  ❖#  ❖%  $&

Slide 38

Slide 38 text

dynamic  

Slide 39

Slide 39 text

dynamic WARNING: [pool www] server reached pm.max_children setting (5), consider raising it max_children     max_children 100  

Slide 40

Slide 40 text

dynamic WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 5 total children ❖ 8 ❖ 0 ❖ active 5

Slide 41

Slide 41 text

dynamic ALERT: [pool www] pm.start_servers(10) must not be less than pm.min_spare_servers(1) and not greater than pm.max_spare_servers(3) ❖start_servers min_spare_servers  ❖start_servers max_spare_servers  min_spare_servers  max_spare_servers    

Slide 42

Slide 42 text

dynamic ❖start_servers: 10 ❖min_spare_servers: 10 ❖max_spare_servers: 50 warning  total process

Slide 43

Slide 43 text

dynamic accepted connection idle process

Slide 44

Slide 44 text

dynamic ❖   => spare_servers   ❖     Available memory

Slide 45

Slide 45 text

 

The current time is .

 Chrome  Page Load Time  

Slide 46

Slide 46 text

  ❖     ➢0.86 s ❖    ➢1.18 s

Slide 47

Slide 47 text

  ❖ $ (  $+&  ➢$ ➢"%$ ➢$%$ ❖ %% !# * ,' ➢static ➢dynamic ➢ondemand ❖ )- 

Slide 48

Slide 48 text

Ruby / PHP