Solution:
Root Cause: Unoptimized Database Queries or Saturated Worker Pool Concurrency
Under high web traffic or slow backend database queries, application pools (e.g., PHP-FPM
www workers or Gunicorn processes) spawn up to their maximum child limit, driving CPU saturation across all available cores.
Step-by-Step Fix:
1Analyze Worker Process Trees:
View parent and child worker relationships:pstree -ap | grep -E 'php-fpm|nginx|apache2|node|python'Count total running worker instances:ps aux | grep php-fpm | wc -l2Identify Slow Scripts or Database Queries:
For PHP-FPM, check the slow log path defined in your pool configuration:tail -f /var/log/php-fpm/www-slow.logFor MySQL, check running queries executing longer than threshold:mysql -e 'SHOW FULL PROCESSLIST;' | grep -v 'Sleep'3Safely Reload or Gracefully Restart Process Pools:
Avoid killing individual workers manually, as parent managers will respawn them. Reload the service configuration:PHP-FPM: sudo systemctl reload php8.2-fpmNginx: sudo systemctl reload nginxApache: sudo apachectl graceful4Kill Orphaned Worker Clusters (Emergency Cleanup):
If services fail to reload, terminate all workers by process name:pkill -f php-fpm or killall -9 node