Worker Processes
Learning Focus
By the end of this lesson you will know how to monitor PHP worker counts, memory, and health.
Monitoring PHP Workers
# Count active workers
ps aux | grep lsphp | grep -v grep | wc -l
# View per-worker memory usage
ps aux | grep lsphp | awk '{printf "PID: %s Memory: %.1f MB\n", $2, $6/1024}'
# Total PHP memory usage
ps aux | grep lsphp | awk '{sum += $6} END {printf "Total: %.1f MB\n", sum/1024}'
Worker Health Indicators
| Indicator | Healthy | Problem |
|---|---|---|
| Worker count | Matches expected max | All workers busy constantly |
| Per-worker memory | Stable, under memory_limit | Growing over time (leak) |
| Worker age | Mixed ages | All workers very new (crashing and restarting) |
What to Do When Workers Are Saturated
- Check if caching is working (reduce dynamic requests)
- Optimize slow queries and application code
- Increase
Max Connectionsif RAM allows - Consider upgrading server resources
Key Takeaways
- Monitor PHP worker count and memory to detect bottlenecks and leaks.
- All workers busy constantly means requests are queuing.
- Optimize application and caching before adding more workers.
What's Next
- Return to the Logging and Monitoring module for the complete overview.