How to Diagnose and Fix High CPU Usage on a VPS

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

  1. uptime — confirm load is genuinely elevated relative to core count
  2. top / ps aux --sort=-%cpu — identify the specific process
  3. Check that process's own logs for the root cause
  4. Rule out malicious activity if the process is unrecognized
  5. 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
  • high cpu usage, cpu troubleshooting, load average, vps performance
  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

Website Down? A Step-by-Step Troubleshooting Checklist

When a website goes down, working through checks in the right order saves critical time. This...

VPS Unreachable/Can't Connect via SSH: Troubleshooting Guide

Losing SSH access to your VPS is stressful, but most causes are fixable without needing to...

How to Fix "No Space Left on Device" Errors

A full disk can silently break databases, log writing, package installations, and web...

How to Diagnose and Fix Out of Memory (OOM) Errors

When a Linux server runs out of available RAM, the kernel's OOM (Out of Memory) killer forcibly...

How to Troubleshoot DNS Propagation Issues

DNS changes don't take effect everywhere instantly — caching at multiple levels means...