optimize-docker-compose-resources
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-compose-resources" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-0aa5d3c62e1226c5918e99344ac7a5ee6720f889830685715f76f48069b20f46. 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
Guidance and configuration examples for optimizing Docker Compose resource allocation in PHP stacks, addressing memory limits, CPU constraints, and service scaling strategies to improve resource usage in local and test environments.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Optimizes Docker Compose resource allocation for PHP stacks. Configures memory limits, CPU constraints, and service scaling.
- Testing
- Not tested
Browse files
Frontmatter
name: optimize-docker-compose-resources
description: Optimizes Docker Compose resource allocation for PHP stacks. Configures memory limits, CPU constraints, and service scaling.Docker Compose Resource Optimization
Configures resource allocation, constraints, and scaling for PHP application stacks.
Resource Allocation Overview
┌─────────────────────────────────────────────────────────────────┐
│ PHP STACK RESOURCE DISTRIBUTION (4GB Host) │
├─────────────────────────────────────────────────────────────────┤
│ PHP-FPM: ████████████████████░░░░░░░░░░ 1024MB (25%) │
│ MySQL: ████████████████████████░░░░░░ 1536MB (38%) │
│ Redis: ████████░░░░░░░░░░░░░░░░░░░░░░ 512MB (13%) │
│ Nginx: ████░░░░░░░░░░░░░░░░░░░░░░░░░░ 256MB (6%) │
│ RabbitMQ: ████████░░░░░░░░░░░░░░░░░░░░░░ 512MB (13%) │
│ System: ████░░░░░░░░░░░░░░░░░░░░░░░░░░ 256MB (6%) │
└─────────────────────────────────────────────────────────────────┘
Recommended Resource Limits
| Service | Memory Limit | Memory Reservation | CPU Limit | CPU Reservation |
|---|---|---|---|---|
| PHP-FPM | 512MB-1GB | 256MB | 1.0 | 0.25 |
| Nginx | 128MB-256MB | 64MB | 0.5 | 0.1 |
| MySQL | 1GB-2GB | 512MB | 1.5 | 0.5 |
| PostgreSQL | 1GB-2GB | 512MB | 1.5 | 0.5 |
| Redis | 256MB-512MB | 128MB | 0.5 | 0.1 |
| RabbitMQ | 512MB-1GB | 256MB | 1.0 | 0.25 |
Service Configurations
PHP-FPM
php-fpm:
deploy:
resources:
limits: { cpus: "1.0", memory: 1024M }
reservations: { cpus: "0.25", memory: 256M }
replicas: 2
tmpfs: ["/tmp:size=64M"]
healthcheck:
test: ["CMD", "php-fpm-healthcheck"]
interval: 30s
timeout: 5s
start_period: 10s
MySQL
mysql:
deploy:
resources:
limits: { cpus: "1.5", memory: 2048M }
reservations: { cpus: "0.5", memory: 512M }
shm_size: "256m"
command: >
--innodb-buffer-pool-size=1G --innodb-log-file-size=256M
--max-connections=200 --tmp-table-size=64M
ulimits:
nofile: { soft: 65536, hard: 65536 }
Redis
redis:
deploy:
resources:
limits: { cpus: "0.5", memory: 512M }
reservations: { cpus: "0.1", memory: 128M }
command: redis-server --maxmemory 384mb --maxmemory-policy allkeys-lru --save "" --appendonly no
tmpfs: ["/data:size=384M"]
RabbitMQ
rabbitmq:
deploy:
resources:
limits: { cpus: "1.0", memory: 1024M }
reservations: { cpus: "0.25", memory: 256M }
environment:
RABBITMQ_VM_MEMORY_HIGH_WATERMARK: 0.6
RABBITMQ_DISK_FREE_LIMIT: 128MB
Logging Configuration
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
| Service | max-size | max-file | Total Disk |
|---|---|---|---|
| PHP-FPM | 10m | 3 | 30MB |
| Nginx | 20m | 5 | 100MB |
| MySQL | 10m | 3 | 30MB |
| Redis | 5m | 2 | 10MB |
tmpfs for Ephemeral Data
tmpfs:
- /tmp:size=64M,mode=1777
- /app/var/cache:size=128M
- /app/var/log:size=32M
Benefits: faster I/O, no disk writes, auto-cleaned on restart.
shm_size for Databases
postgres:
shm_size: "256m" # shared_buffers, WAL buffers, lock tables
mysql:
shm_size: "256m" # InnoDB buffer pool, temp tables
ulimits Configuration
| ulimit | Default | Recommended | Purpose |
|---|---|---|---|
| nofile | 1024 | 65536 | Max open files/sockets |
| nproc | 1024 | 4096 | Max processes |
| memlock | 64KB | unlimited | Memory locking (Redis) |
Scaling with Replicas
php-fpm:
deploy:
replicas: 3
endpoint_mode: dnsrr
resources:
limits: { cpus: "0.5", memory: 512M }
# Total: 1.5 CPU, 1536M memory across 3 replicas
# Nginx resolves php-fpm to all replicas via DNS round-robin
Before/After Comparison
| Metric | No Limits | With Limits | Improvement |
|---|---|---|---|
| OOM kills | Frequent | Rare | Predictable |
| Noisy neighbor | Common | Prevented | Isolated |
| Memory waste | 30-50% | < 10% | -80% waste |
| Log disk usage | Unbounded | < 200MB | Controlled |
| Recovery time | Minutes | Seconds | Faster restarts |
Generation Instructions
- Inventory services: List all containers in the stack
- Assess host resources: Total CPU and memory available
- Allocate proportionally: Database > App > Cache > Proxy
- Set limits and reservations: Limits cap usage, reservations guarantee minimum
- Configure logging: Prevent unbounded disk growth
- Add health checks: Enable automatic recovery
- Test under load: Verify no OOM kills or throttling
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 针对PHP技术栈的Docker Compose资源优化,解决实际部署痛点
- 提供详细的资源配置建议和最佳实践
- 包含内存、CPU、日志、tmpfs等多维度优化方案
Highlights
- 触发词覆盖PHP、Docker Compose、资源分配等核心关键词
- description清晰准确,边界定义明确
- 支持多种资源优化场景的触发
Highlights
- 文档结构清晰,分模块详细说明
- 提供完整的配置示例和参数说明
- 包含before/after对比和最佳实践指导
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.