TechBuzzPro

Fix High CPU Usage on Dedicated Server

· 4 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can fix high CPU usage on your dedicated server by identifying the root cause—typically a runaway process, inefficient application, or misconfigured service—and taking targeted steps to stop or optimize it. This guide walks you through diagnosing and resolving the issue safely and effectively. Begin only after ensuring you have administrative access (SSH or console) and a recent backup of critical services and configurations.

What You'll Need

  • SSH access to your server (or direct console access if in a data center)
  • Basic command-line proficiency (using Linux commands like top, htop, ps, systemctl)
  • Administrative (root or sudo) privileges
  • Access to application and system logs (usually in /var/log)
  • Monitoring tools (such as htop, iotop, or atop) if not already installed

Step-by-Step

  1. Log in to your server via SSH using your credentials. Use a terminal on your local machine and run: ssh username@your-server-ip. Once connected, ensure you have sudo access or are logged in as root.
  2. Check current CPU usage with the top command. Press Shift + P to sort processes by CPU usage. Look for any process consuming an unusually high percentage (e.g., over 70% consistently).
  3. Install htop for a more user-friendly view if not already available. Run sudo apt install htop on Debian/Ubuntu or sudo yum install htop on CentOS/RHEL. Then launch it with htop.
  4. Identify the problematic process. Note its process ID (PID), command name, and user. If it's a known service (e.g., Apache, MySQL, Node.js app), proceed to step 6. If it's unknown, research the process name online or check if it might be malicious.
  5. For unknown or suspicious processes, run ps -fp [PID] to get more details. Check if the executable path is in a standard directory like /usr/bin or a suspicious location. Use lsof -p [PID] to see what files and ports it's using.
  6. Determine if the high CPU usage is expected. For example, a backup script or cron job might temporarily spike CPU. Check scheduled tasks with crontab -l and sudo crontab -l.
  7. If the process is legitimate but misbehaving, restart the associated service. For example: sudo systemctl restart apache2 (Debian/Ubuntu) or sudo systemctl restart httpd (CentOS/RHEL). Monitor CPU usage afterward.
  8. If the process is not managed by systemd, stop it manually using kill [PID]. If it doesn’t respond, use kill -9 [PID]. Avoid -9 unless necessary, as it forces termination without cleanup.
  9. Check system logs for clues. Use sudo journalctl -xe for recent logs or inspect specific logs in /var/log/ (e.g., syslog, messages, or application-specific logs).
  10. Investigate application-level issues. If a web application (e.g., WordPress, Node.js) is causing high CPU, check for inefficient code, infinite loops, or unindexed database queries. Enable application logging if available.
  11. Optimize or limit resource usage. Use cpulimit to cap CPU for a specific process: sudo cpulimit -p [PID] -l 50 limits it to 50%. Alternatively, use cgroups for long-term control.
  12. Update your system and applications. Run sudo apt update && sudo apt upgrade or sudo yum update to ensure no known bugs are causing performance issues.
  13. Reboot the server if necessary. After resolving the issue, a clean reboot ensures all services start fresh. Use sudo reboot.

Common Mistakes

Killing the wrong process can crash your server or disrupt services. Always double-check the PID and command name. Avoid using kill -9 as the first option—it can leave files corrupted or locks unreleased. Restarting services without checking logs may cause the same issue to recur. Ignoring scheduled tasks or cron jobs is another frequent oversight—many high-CPU incidents stem from misconfigured automation.

Tips

Set up real-time monitoring with tools like htop or atop to catch spikes early. Use iotop if you suspect disk I/O is contributing to CPU load. Configure email alerts via sysstat or a monitoring service. Document changes you make—this helps during audits or future troubleshooting. Run CPU-intensive tasks during off-peak hours.

Troubleshooting

If CPU usage remains high after killing a process, another instance may have respawned it—check for cron jobs or service restart policies. If the server becomes unresponsive, use the provider’s out-of-band console (like IPMI or KVM over IP) to access it. If logs show no clear cause, consider a kernel issue—update the OS or consult your hosting provider. If you suspect a DDoS attack, use netstat -an | grep :80 to check for excessive connections, and implement firewall rules with ufw or iptables.

Frequently Asked Questions

Can a virus cause high CPU usage on a Linux server?

Yes, malware or cryptominers can run hidden processes. Check unusual processes and scan with tools like rkhunter or ClamAV.

Should I reboot immediately when CPU is high?

No—first identify the cause. A reboot masks the problem and may not fix it if the process restarts automatically.

How do I prevent this from happening again?

Set up monitoring, limit resource-heavy processes, keep software updated, and audit cron jobs and user scripts regularly.

Does high CPU affect server performance?

Yes—high CPU can slow response times, delay tasks, and make the server unresponsive under load.

Can a single website cause high CPU?

Yes—poorly coded scripts, traffic spikes, or database queries on one site can overload the server, especially on shared hosting setups.

Is it safe to limit CPU with cpulimit?

Yes, but use it temporarily. Long-term limits should use cgroups or container limits (e.g., Docker) for better control and stability.