perf(docker): Phase 1 效能優化——OPcache revalidate 調校、composer 重裝修正、healthcheck 修復 #33
Reference in New Issue
Block a user
Delete Branch "perf/phase1-opcache"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
摘要
本機 API 延遲 2.5s → 0.2s(約 10 倍)。三個修正都對 VPS 同樣適用且有益。
根因修正(重要)
初版優化計畫判定「OPcache 被停用」是錯誤診斷(CLI 量測假象,
opcache.enable_cli預設關)。fpm 的 OPcache 一直開著,真凶是:revalidate_freq=2× Windows bind mount:每 2 秒重新 stat ~850 個腳本。鐵證:2 秒窗口內 0.23s、窗口外 2.5s變更
docker/php/local.ini:revalidate_freq 2→30、memory 192M、max_files 20000docker/php/docker-entrypoint.sh:composer 改 lock 內容比對(vendor/.composer.lock.installed標記檔)docker-compose.yml:healthcheck 改打 127.0.0.1docs/analysis/2026-06-11-performance-optimization-plan.md驗收實測
部署注意(VPS)
docker compose build app && docker compose up -d app(ini 與 entrypoint 都 build 進 image)docker compose exec app kill -USR2 1🤖 Generated with Claude Code