Summary
Production WordPress deployment is showing a steady increase in memory usage over time (memory creep), which appears to grow until the container is at risk of crashing. We are running on AWS ECS using EC2-backed containers.
Environment
- Repository: MESH-Research/knowledge-commons-wordpress
- Deployment: production (ECS, EC2 launch type)
- Service: wordpress-prod (multiple color instances: wp-green / wp-blue)
Observed behavior
- One of the WordPress production containers (wp-green) exhibits a gradual upward trend in memory utilization over multiple days.
- Periodic spikes are visible, but the baseline memory usage slowly increases over time (see evidence below).
- This behaviour suggests a memory leak or accumulation of in-memory state that is not released, ultimately increasing the risk of container OOM and crash.
Evidence
- CloudWatch/monitoring graph showing memory utilization for production containers (one-week window):
- The green series (wordpress-prod-3 wp-green) shows a clear upward trend from ~20% to ~40% (and higher on spikes) across the captured timeframe.
- The orange series (wp-cron) shows frequent short spikes (cron activity) but does not explain the persistent baseline increase.
Impact
- Production stability risk: containers may reach memory limits and be terminated / restarted by ECS, causing degraded performance or downtime for end users.
- Potential data-loss risk is low (stateless containers with persistent storage elsewhere) but restarts increase error rates and user-visible errors.
Suspected causes
- Long-running PHP processes (PHP-FPM) or a plugin/theme causing memory to be retained between requests.
- Improper object caching configuration (in-memory caches persisting beyond intended lifecycle).
- Background jobs or cron tasks (wp-cron) accumulating state or leaking memory on repeated execution.
- Native extension or third-party library (e.g., image processing, search indexing) leaking memory.
Immediate mitigation suggestions
- Temporarily reduce container memory reservation/limit or add an automated restart policy to recycle containers before they hit OOM (short-term stopgap).
- Scale out additional ECS tasks to reduce pressure on individual containers while investigating.
- Disable or roll back recent plugin/theme changes deployed shortly before the trend began (if applicable).
Recommended investigation steps
- Collect more detailed runtime diagnostics from an affected container:
- PHP-FPM status and process list (top/ps) over time.
- per-process memory usage (e.g., ps aux --sort=-rss, pmap, smem) and heap snapshots where feasible.
- PHP error logs and slow logs around spike times.
- List of active plugins and recent changes/deploys.
- Reproduce in a staging environment with high-traffic/certain cron schedules to see whether memory grows similarly.
- Run memory-profiler on PHP (e.g., Xdebug/profiler, Blackfire, or other tools) for longer-running worker processes.
- Check object-cache (Redis/Memcached) configuration and any in-memory object retention code paths.
- Inspect background jobs / WP-Cron tasks for accumulating data or failing to free resources.
- Correlate memory spikes with deployment events and cron spikes shown in the monitoring graph.
Priority
- High: production stability is affected and the issue can lead to container restarts and user-visible errors.
Attachments
- Monitoring graph included above.
Summary
Production WordPress deployment is showing a steady increase in memory usage over time (memory creep), which appears to grow until the container is at risk of crashing. We are running on AWS ECS using EC2-backed containers.
Environment
Observed behavior
Evidence
Impact
Suspected causes
Immediate mitigation suggestions
Recommended investigation steps
Priority
Attachments