Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
Search
にわ
July 19, 2026
Programming
510
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
92
Other Decks in Programming
See All in Programming
App Intentsのビルドプロセスを支える技術
kntkymt
0
390
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
330
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
150
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
280
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
490
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
130
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
120
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
480
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
560
WebAssembly in Android Apps 〜 WASMはJNIの夢を見るか
keiji
1
110
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
250
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
720
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
4
510
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
4 Signs Your Business is Dying
shpigford
187
23k
Site-Speed That Sticks
csswizardry
13
1.5k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
YesSQL, Process and Tooling at Scale
rocio
174
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
520
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
ご清聴ありがとうございました!