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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
にわ
July 19, 2026
Programming
550
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
96
Other Decks in Programming
See All in Programming
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
7.7k
Kubernetes祭り #2 OP/ED
bells17
0
100
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
170
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Workers Cache を知る
syumai
0
340
Agents on Rails - Rails at Scale 2026
irinanazarova
0
340
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
AIに “答え“を書かせるのを やめてみた
___akari11
0
110
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
160
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
R8 の設定見直しでアプリサイズ削減
andpad
0
190
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
320
Featured
See All Featured
Test your architecture with Archunit
thirion
2
2.4k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
620
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
390
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Making Projects Easy
brettharned
120
6.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
KATA
mclloyd
PRO
35
16k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
460
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
WCS-LA-2024
lcolladotor
0
850
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
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
ご清聴ありがとうございました!