Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
にわ
July 19, 2026
Programming
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
PHP Conference 2026 LT 登壇資料
にわ
July 19, 2026
More Decks by にわ
See All by にわ
「値はあるのに空判定」される怪奇現象を追ったら、犯人は __isset だった話 / PHPerKaigi 2026 ルーキーズLT
shibuchaaaan
0
77
Other Decks in Programming
See All in Programming
数百円から始めるRuby電子工作
tarosay
0
160
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.8k
バグを直したら useEffect が消えた
colorful12
2
450
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
710
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
620
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
270
FDEが実現するAI駆動経営の現在地
gonta
2
280
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
980
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
760
プロポーザルを書いてもらう
pvcresin
0
550
the container ship “Apple Silicon”@WWDC26 Recap -Japan-\(region).swift
shingangan
0
130
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.7k
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
410
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Designing for Timeless Needs
cassininazir
1
440
So, you think you're a good person
axbom
PRO
2
2.1k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
530
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
230
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
710
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Building AI with AI
inesmontani
PRO
1
1.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
430
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
Transcript
php-fpmのプロセスが枯渇した日 〜調査・対処・ そして本当にやるべきだったこと〜 にわ @PHP Conference 2026
自己紹介 丹羽美希(にわみき) 趣味 お酒、バンド、バイクが好き ベース弾いてます 仕事 ユースタイルラボラトリー (ちょっと古い) 社内システム開発担当
504 Gateway Timeout 3
500エラーとかじゃないから、 PHPの処理に到達する以前に apacheが死んでるのでは? 4
apacheが死んでた ↓ とりあえずシステム復旧のた めapache再起動 5
apacheが亡くなった現場 // まずは直近のapacheエラーログ確認 $ tail -n 50 /var/log/httpd/error_log … [mpm_event:error]
[pid 3417425:tid 139922572937536] AH03490: scoreboard is full, not at MaxRequestWorkers.Increase ServerLimit. 6
FastCGI Process Manager 7
php-fpmは 「PHPの実行エンジン」 プロセス リクエスト
php-fpmの状況確認 $ ps aux | grep 'php-fpm' apache 2487148 2.1
3.7 821056 67984 ? S 15:37 0:20 php-fpm: pool www apache 2487155 1.4 3.6 745496 66868 ? S 15:38 0:13 php-fpm: pool www apache 2487223 1.5 4.3 757628 79476 ? S 15:38 0:14 php-fpm: pool www …(いっぱい) // 数を確認 $ ps aux | grep php-fpm | wc -l 22 9
php-fpmのプロセス数設定 $ grep "pm.max_children" /etc/php-fpm.d/www.conf pm.max_children = 20 10
php-fpmのプロセス上限 行っちゃってる!!! 11
php-fpm のエラーログを確認 $ tail /var/log/php-fpm/error.log [WARNING] pool www: server reached
pm.max_children setting (20), consider raising it 12
①プロセス数増やせば 解決やん! 13
pm.max_children設定数の考え方 pm.max_children = サーバーの利用可能メモリ ÷ 平均的な PHPプロセスのメモリ使用量 14
サーバーの利用可能メモリ $ free -m total used free Mem: 1774 407
275 Swap: 2047 483 1564 shared buff/cache available 134 1091 1056 15
PHPプロセスのメモリ使用量平均 $ ps aux | grep 'php-fpm' apache 2499211 6.7
4.4 754848 80760 ? S 17:25 0:27 php-fpm: pool www apache 2499212 5.7 3.5 811144 64740 ? S 17:25 0:23 php-fpm: pool www apache 2499354 4.4 3.2 736460 58424 ? S 17:27 0:12 php-fpm: pool www apache 2499426 3.7 4.1 821104 74896 ? S 17:28 0:08 php-fpm: pool www apache 2499497 3.5 3.4 810872 62064 ? S 17:29 0:06 php-fpm: pool www 16
1056MB / 68.1768MB = 15.48914プロセス 分使える 17
②そもそもなんで プロセスこんな溜まったん? ↓ phpの処理が遅いのが問題? 18
めっちゃ session_start()あるけど何!? [07-Jan-2026 15:39:58] [pool www] pid 2487291 script_filename =
/project/XXX.php [0x00007fd1f0013410] session_start() /project/config.php:22 [07-Jan-2026 15:39:58] [pool www] pid 2487294 script_filename = /project/YYY.php [0x00007fd1f0013410] session_start() /project/config.php:22 … 19
session_start()が遅くなった原因 1. 2. 3. 4. 重いSQL処理がプロセスを長時間占有 重い処理がセッションを掴んだまま走り続ける 後続リクエストが session_start() でロック解除待ちに連鎖
30個のプロセスがすべて「待ち」で埋まる → Swapまで使い果たしてフリーズ 20
どうすべきだったのか? 正しいプロセス数を設定 プロセスを詰まらせない設計 • メモリ計算なしに数値を増や • 重いSQLのチューニング すのは危険 • 重い処理もチューニング!
• 利用可能メモリ ÷ 1プロセス 非同期化するのも手 のメモリ使用量 • まず実測 21
まとめ 1. WebのPHPはphp-fpmくんが動かしてくれている (他の場合もある) 2. 実測と適切な設定をしましょう! 3. プロセスを詰まらせない設計が、安定稼働の根本 22
ご清聴ありがとうございました!