Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP-FPM をもっと理解しよう

naoki85
December 15, 2018

PHP-FPM をもっと理解しよう

PHPアプリケーションが動いているサーバーがメモリ不足でアラートがあがる。どうやらphp-fpmがメモリを消費しているようだ。その時は付け焼き刃でphp-fpmの設定値を調整して対応したが、改めてちゃんと理解したいと思った。 そんな私とあなたに向けた内容(注:知識を整理したい方向けの予定です)

naoki85

December 15, 2018
Tweet

More Decks by naoki85

Other Decks in Technology

Transcript

  1. 

  2. 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  
  3. 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 
  4. Fast CGI CGI27'7bV J-5)(XLZRa"! FfbV!> -5)(XLZRHN !  +,$7.6(KB^ 

    FastCGI-5)(#0148U]YdA  dA[: Og# @W \Q -5%3/A<eJD8&7*c`;9C_ P?-5)( Ha !Th-5)(0148G] ]SbVI -5)(Ha  Wikipedia  -5)(#014=M SEHaeJ#
  5. Web%%2ApacheNginx3 ❖Apache ❖Nginx l !"%#+  PHP,1 - */ 

    l Web%%)& $ PHP' 2CGI ,1(.3 l CGI  PHP $0' 
  6. • docker • Zabbix Alpine Linux   • Nginx

    • PHP-FPM ϩʔΧϧͰ/HJOY 1)1'1. Λ;BCCJYͰ؂ࢹ͢Δαϯϓϧ
  7.   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
  8. dynamic WARNING: [pool www] server reached pm.max_children setting (5), consider

    raising it max_children     max_children 100  
  9. 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
  10. 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    
  11.   ❖ $ (  $+&  ➢$ ➢"%$

    ➢$%$ ❖ %% !# * ,' ➢static ➢dynamic ➢ondemand ❖ )-