Struggling with high CPU usage on cPanel/WHM after update: Need advice on server resource management
Hey everyone,
Following up on my previous struggles with cPanel administration, I recently updated my cPanel/WHM installation to the latest version, hoping to iron out some kinks. While some minor issues were resolved, I've now hit a wall with persistent high CPU usage, making my sites sluggish and occasionally unresponsive.
It seems like after the update, certain processes are just eating up resources, specifically during peak hours. I'm running a few WordPress sites and a couple of custom PHP apps. The server isn't heavily loaded in terms of traffic, but the CPU spikes are insane.
Here's what I've tried so far:
- Checked Apache logs for suspicious activity or excessive requests.
- Optimized MySQL databases and checked slow query logs (nothing major).
- Restarted Apache and MySQL services multiple times.
- Disabled Mod_Security temporarily (no change).
- Reviewed the 'Process Manager' in WHM, but the culprits seem to shift, often showing 'httpd' or 'php-fpm' processes consuming high percentages.
- Increased PHP memory limits slightly.
I ran top during one of the spikes, and here's a snippet of what I'm seeing:
top - 15:30:05 up 2 days, 3:15, 1 user, load average: 3.50, 2.80, 2.10
Tasks: 180 total, 2 running, 178 sleeping, 0 stopped, 0 zombie
%Cpu(s): 75.3 us, 5.2 sy, 0.0 ni, 19.4 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
MiB Mem : 7985.0 total, 120.0 free, 4500.0 used, 3365.0 buff/cache
MiB Swap: 2048.0 total, 1800.0 free, 248.0 used. 2800.0 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12345 nobody 20 0 560000 120000 50000 S 25.0 1.5 0:15.23 httpd
12346 nobody 20 0 550000 110000 45000 S 20.0 1.4 0:12.87 httpd
12347 nobody 20 0 540000 100000 40000 S 18.0 1.3 0:10.55 php-fpm
8910 root 20 0 100000 5000 2000 R 5.0 0.1 0:01.10 top
The load average is consistently high, and the CPU usage percentage is alarming for a server that isn't under heavy traffic. I'm really scratching my head here about effective server resource management in cPanel/WHM.
Has anyone experienced similar issues after a cPanel update? What are your go-to strategies for diagnosing and resolving high CPU usage, especially concerning httpd or php-fpm processes? Are there any specific cPanel/WHM configurations or third-party tools that could help me fine-tune my server's performance and prevent these spikes?
Help a brother out please...
2 Answers
Wei Lee
Answered 10 hours agoFirstly, for `httpd` (Apache), you need to see exactly what requests are being processed during these spikes. Enable and monitor mod_status (accessible via `/server-status` on your domain). This will show you active connections, what they're doing, and from which IPs. Often, it reveals bot activity, brute-force attempts on login pages, or specific slow scripts. Based on your server's RAM, you might need to adjust Apache's MaxRequestWorkers (or `MaxClients` if you're on an older MPM) to prevent too many processes from spawning and consuming all available memory, which then leads to excessive swapping and CPU thrashing. For `php-fpm`, the key is tuning its process manager settings. In WHM, navigate to "MultiPHP Manager" -> "PHP-FPM Settings". You'll want to adjust `pm.max_children`, `pm.start_servers`, `pm.min_spare_servers`, and `pm.max_spare_servers`. These values need to be carefully balanced against your server's available RAM. A common mistake is setting `pm.max_children` too high, leading to memory exhaustion. Start with conservative values and incrementally increase them while monitoring memory usage.
Given you're running WordPress, aggressive caching is non-negotiable for server optimization. Ensure you're using a robust caching plugin (like WP Rocket, LiteSpeed Cache, or W3 Total Cache) and consider implementing object caching (e.g., Redis or Memcached) if you have enough RAM. This significantly reduces the load on PHP and MySQL. Also, do a thorough audit of your WordPress plugins and themes. Outdated or poorly coded plugins are notorious for causing high CPU usage. Utilize tools like Query Monitor to identify slow queries or scripts within your WordPress environment. For overall server resource management and to prevent one user's site from impacting others, consider implementing CloudLinux's LVE (Lightweight Virtual Environment) if your server supports it. It allows you to set specific CPU, RAM, and I/O limits per cPanel account, which is a game-changer for shared hosting or reseller environments to ensure consistent performance tuning. Finally, always check your cron jobs โ sometimes a misconfigured or resource-intensive cron script can run wild during off-peak hours and cause unexpected spikes.
Have you had a chance to look into your Apache `mod_status` output during a spike, or specific `php-fpm` slow logs to pinpoint the exact scripts causing the issue?Nour Hassan
Answered 10 hours agoOh, wow, this is super helpful Wei Lee! Seriously, appreciate the detailed breakdown and the specific points on `mod_status` and PHP-FPM settings. I'm definitely going to check `mod_status` during the next spike to see what's really happening, and now I'm thinking my `pm.max_children` might be way off for my server's RAM.