Skip to content

Troubleshooting guide

High CPU usage on a Linux server: find the cause

High CPU is either useful work you need more capacity for, or waste you can remove. A few commands tell you which, and which process is responsible.

3 min read9 sectionsUpdated

On this page

Key points

  • Read the CPU breakdown: us, sy, wa and st mean very different things.
  • Load average counts waiting tasks too, including those waiting on disk.
  • Find the process, then the thread, then the code.
  • In containers, compare against the CPU limit, not the host.

Start with top

bash
top -o %CPU          # sort by CPU; press 1 to see each core
uptime               # load averages for 1, 5 and 15 minutes
vmstat 1 5           # r = run queue, wa = iowait, st = steal
mpstat -P ALL 1 3    # per-core usage (sysstat package)
pidstat 1 5          # per-process CPU over time

Reading the CPU breakdown

FieldMeaningHigh usually means
usUser spaceYour application is busy: real work or inefficient code
syKernelMany system calls, context switches, networking
waWaiting for I/ODisk bottleneck, not CPU; check iostat
stStealThe hypervisor gives your VM less CPU; noisy neighbours or burst credits exhausted
si / hiInterruptsVery high network packet rates

Drill into the process

bash
# Threads inside the busy process
top -H -p <pid>

# What is it doing? Sample stacks for 30 seconds (perf package)
sudo perf top -p <pid>
sudo perf record -F 99 -p <pid> -g -- sleep 30 && sudo perf report

# Language-specific profilers
py-spy top --pid <pid>                 # Python
jcmd <pid> Thread.print                # Java thread dump
node --cpu-prof app.js                 # Node.js CPU profile

Common causes

  • Traffic growth: CPU tracks request rate. Scale out or optimize hot paths found in traces.
  • A runaway job or loop: one process at 100% of one core regardless of traffic.
  • Garbage collection pressure: memory near the heap limit makes the runtime collect constantly.
  • Regex or JSON on large inputs: catastrophic backtracking or huge payloads.
  • Crypto mining malware: unknown processes using CPU constantly. Investigate as a security incident.
  • Steal time: burstable instances that ran out of credits.

Containers and CPU limits

A container limited to 0.5 CPU at 100% of its limit is throttled while the host may look idle. Check throttling in /sys/fs/cgroup/cpu.stat (nr_throttled, throttled_usec) and measure usage as a share of the limit. VitalRix infrastructure monitoring shows CPU as a share of the cores an instance may use, taken from its container limit when there is one, and alerts per instance when CPU stays too high.

Frequently asked questions

What is a normal load average?

Compare it with the number of cores. A load of 4 on a 4-core machine means fully busy; above that, tasks are waiting. A high load with low CPU usage usually means tasks waiting on disk.

Is 100% CPU always bad?

Not if latency is fine and it is temporary, such as a batch job. It is bad when request latency rises, which shows up in p95 and p99.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.