Skip to main content

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

IndicatorHealthyProblem
Worker countMatches expected maxAll workers busy constantly
Per-worker memoryStable, under memory_limitGrowing over time (leak)
Worker ageMixed agesAll workers very new (crashing and restarting)

What to Do When Workers Are Saturated

  1. Check if caching is working (reduce dynamic requests)
  2. Optimize slow queries and application code
  3. Increase Max Connections if RAM allows
  4. 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