optimize-docker-php-fpm
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "optimize-docker-php-fpm" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-498fbc427f8c1004b6047b3b5d946e6d3f9df4feddaf0150dc6cb19e627d8b31. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Optimize PHP-FPM configuration inside Docker containers. Tune process management, request handling, and resource allocation for production workloads to improve performance and stability.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Optimizes PHP-FPM configuration in Docker containers. Tunes process manager, request handling, and resource allocation for production workloads.
- Testing
- Not tested
Browse files
Frontmatter
name: optimize-docker-php-fpm
description: Optimizes PHP-FPM configuration in Docker containers. Tunes process manager, request handling, and resource allocation for production workloads.PHP-FPM Configuration Optimization
Provides production-ready PHP-FPM tuning for Docker containers based on workload type and available resources.
Process Manager Modes
┌─────────────────────────────────────────────────────────────────┐
│ PHP-FPM PROCESS MANAGERS │
├─────────────────────────────────────────────────────────────────┤
│ STATIC: [W][W][W][W][W][W][W][W] Fixed pool │
│ Best for: dedicated containers, predictable load │
│ DYNAMIC: [W][W][W][W][ ][ ][ ][ ] Scales up/down │
│ Best for: variable load, shared resources │
│ ONDEMAND: [ ][ ][ ][ ][ ][ ][ ][ ] Starts on request │
│ Best for: low-traffic, dev environments │
└─────────────────────────────────────────────────────────────────┘
Memory Calculation Formula
max_children = (available_memory - system_overhead) / avg_worker_memory
Where:
available_memory = container_memory_limit
system_overhead = ~50MB (OS + PHP-FPM master + nginx)
avg_worker_memory = 30-60MB (depends on application)
| Container Memory | System Overhead | Worker Memory | max_children |
|---|---|---|---|
| 256MB | 50MB | 40MB | 5 |
| 512MB | 50MB | 40MB | 11 |
| 1024MB | 50MB | 40MB | 24 |
| 2048MB | 50MB | 50MB | 39 |
Measure actual worker memory:
ps aux | grep "php-fpm: pool" | awk '{sum+=$6; n++} END {print sum/n/1024 " MB"}'
Configuration by Workload
API Workload (Many Fast Requests)
[www]
pm = static
pm.max_children = 20
request_terminate_timeout = 30s
request_slowlog_timeout = 5s
pm.max_requests = 1000
slowlog = /proc/self/fd/2
Worker Workload (Few Long Requests)
[www]
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 4
request_terminate_timeout = 300s
request_slowlog_timeout = 30s
pm.max_requests = 200
Mixed Workload
[www]
pm = dynamic
pm.max_children = 15
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 8
request_terminate_timeout = 60s
request_slowlog_timeout = 10s
pm.max_requests = 500
Dynamic Mode Formulas
pm.start_servers = (min_spare + max_spare) / 2
pm.min_spare_servers = max_children * 0.25
pm.max_spare_servers = max_children * 0.75
pm.max_requests by Application Type
| Application Type | Recommended Value |
|---|---|
| Stateless API | 1000-5000 |
| Framework with ORM | 500-1000 |
| Legacy application | 100-500 |
| Memory-intensive processing | 50-200 |
Health Check and Monitoring
pm.status_path = /status
ping.path = /ping
ping.response = pong
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD php-fpm-healthcheck || exit 1
Key status metrics to monitor:
- active processes: current load
- listen queue: requests waiting (should be 0)
- max children reached: need more workers
- slow requests: performance issues
Docker-Specific Settings
; Logging to stdout/stderr
error_log = /proc/self/fd/2
access.log = /proc/self/fd/2
; Must be "no" in containers: workers inherit vars from docker run -e / compose environment
clear_env = no
catch_workers_output = yes
decorate_workers_output = no
Before/After Comparison
| Metric | Default | Optimized (static) | Improvement |
|---|---|---|---|
| max_children | 5 | 20 | +300% capacity |
| Idle memory (512MB) | 200MB wasted | ~50MB overhead | -75% waste |
| Request latency (p99) | 500ms | 150ms | -70% |
| Throughput (req/s) | 50 | 200 | +300% |
| Memory leak recovery | Never | Every 1000 req | Predictable |
Complete Production Configuration
[global]
error_log = /proc/self/fd/2
log_level = warning
daemonize = no
[www]
user = www-data
group = www-data
listen = 0.0.0.0:9000
pm = static
pm.max_children = 20
pm.max_requests = 1000
request_terminate_timeout = 30s
request_slowlog_timeout = 5s
slowlog = /proc/self/fd/2
pm.status_path = /status
ping.path = /ping
ping.response = pong
clear_env = no
catch_workers_output = yes
decorate_workers_output = no
access.log = /proc/self/fd/2
access.format = "%R - %u %t \"%m %r\" %s %{mili}dms %{mega}MMB %C%%"
Generation Instructions
- Determine workload type: API, Worker, or Mixed
- Calculate max_children: Based on container memory and worker memory
- Select PM mode: Static for production, dynamic for variable load
- Configure timeouts: Based on expected request duration
- Set max_requests: Based on application memory behavior
- Enable monitoring: Status page, health check, slow log
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供生产环境 PHP-FPM 配置优化方案
- 包含内存计算公式和具体配置模板
- 覆盖 API/Worker/Mixed 多种工作负载场景
Highlights
- description 完整描述功能边界
- 明确说明针对 Docker 容器中的 PHP-FPM 优化
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
文档结构完整但缺少明确的适用场景说明章节
Recommendation: 建议添加 When to Use 章节说明适用场景和前提条件
Highlights
- 六步生成指令清晰明确
- 提供完整的生产环境配置示例
- frontmatter 完整且规范
Highlights
- 配置参数有计算公式支撑
- 包含健康检查和监控方案
- 覆盖主要异常场景处理
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.