Sustained high CPU usage can slow down your entire server and every application running on it. This guide covers finding the exact cause and resolving it.
Step 1 — Confirm CPU Is Actually the Bottleneck
uptime
Compare the load average (1/5/15-minute values) to your VPS's number of CPU cores. Sustained load consistently above your core count indicates genuine CPU saturation.
Step 2 — Identify the Top CPU-Consuming Process
top
Or non-interactively:
ps aux --sort=-%cpu | head -10
Step 3 — Investigate the Specific Process
ps -p PID -o pid,ppid,cmd,%cpu,%mem
Common Causes and Fixes
A Runaway or Crashed Application Process
Check the application's own logs for errors indicating an infinite loop or crash-restart cycle:
docker logs CONTAINER_NAME
sudo journalctl -u your-app-service -n 100
Database Running Expensive Queries
For MySQL/MariaDB, enable and check the slow query log — see How to Tune MySQL/MariaDB Performance for a VPS.
A Cron Job Running Too Frequently or Overlapping
crontab -l
Check if a scheduled task is running more often than intended, or overlapping with a previous still-running instance.
Legitimate Traffic Spike
Check web server access logs for an unusual volume of requests:
sudo tail -f /var/log/nginx/access.log
Malicious Activity (Cryptomining, Compromise)
An unfamiliar process consuming 100% CPU, especially with an unusual or randomly-named binary, can indicate compromise:
ps aux --sort=-%cpu | head -5
If unrecognized, investigate immediately — see How to Detect and Remove Rootkits on a Linux VPS, and review recent login activity in How to Monitor Auth Logs and Detect Intrusion Attempts.
Step 4 — Resolving It
Restart a misbehaving application:
sudo systemctl restart your-app-service
Or a stuck container:
docker restart CONTAINER_NAME
For a process you need to stop entirely (see How to Find and Stop Processes Using Too Many Resources for full detail):
kill PID
Step 5 — Prevent Recurrence
Set resource limits on containerized services so a single container can't consume all CPU:
deploy:
resources:
limits:
cpus: '0.5'
For systemd services:
[Service]
CPUQuota=50%
Common Errors
High load average but top shows nothing obviously consuming CPU — check for high I/O wait instead; see How to Fix High Disk I/O Wait Issues, since top's load average includes processes waiting on disk, not just CPU-bound ones.
Diagnostic Checklist
uptime— confirm load is genuinely elevated relative to core counttop/ps aux --sort=-%cpu— identify the specific process- Check that process's own logs for the root cause
- Rule out malicious activity if the process is unrecognized
- Apply a fix (restart, query optimization, resource limits) and re-verify with
uptime
Related Articles
- How to Find and Stop Processes Using Too Many Resources
- How to Check VPS Resource Usage (CPU, RAM & Disk)
- How to Detect and Remove Rootkits on a Linux VPS
