Home/Engineer/Troubleshooting/CPU Overload Diagnosis — top…
TroubleshootingIntermediateUbuntuDebianCentOScputophtop

CPU Overload Diagnosis — top · htop · perf · uptime

How to pinpoint CPU-heavy processes with top/htop, check load trends with uptime/vmstat, and find bottleneck causes with perf and strace.

Contents
  1. Step 1 — Assess Current Load
  2. Step 2 — Identify CPU-Consuming Processes
  3. Step 3 — Analyze Bottlenecks Inside the Process
  4. Step 4 — Causes by CPU Type
  5. Step 5 — Temporary Mitigation
  6. Checklist

Step 1 — Assess Current Load

Bash
# Check Load Average (1-min / 5-min / 15-min averages)
uptime
# Example: load average: 4.20, 3.80, 2.10
# Overload if higher than the number of CPU cores
nproc                  # Check CPU core count

# Real-time CPU status
vmstat 2 10            # 2-second interval, 10 samples

# Key columns
# us: user space, sy: kernel, wa: I/O wait, id: idle
# si/so: swap in/out (high values indicate memory shortage)

Step 2 — Identify CPU-Consuming Processes

Bash
# After launching top
top
# P key: sort by CPU
# M key: sort by memory
# k key: kill process by PID
# 1 key: show per-core CPU

# One-shot snapshot (sorted)
ps aux --sort=-%cpu | head -15

# Track CPU for a specific process
pidstat -u -p 1234 2 5   # PID 1234, 2-second interval, 5 samples

Step 3 — Analyze Bottlenecks Inside the Process

Bash
# strace — trace system calls
strace -p 1234 -c       # System call statistics summary
strace -p 1234 -e trace=read,write  # Specific calls only

# perf — performance counter profiling
sudo apt install -y linux-tools-common linux-tools-$(uname -r)

# Collect CPU events for 10 seconds
sudo perf record -g -p 1234 -- sleep 10

# Analyze results
sudo perf report

# System-wide hotspots (5 seconds)
sudo perf top

# lsof — check how many files the process has open
sudo lsof -p 1234 | wc -l

Step 4 — Causes by CPU Type

When us (user) CPU is high

Bash
# Suspect infinite loops or inefficient algorithms
# Check stack traces (Python)
sudo py-spy top --pid 1234

# Java
sudo jstack 1234 | grep -A 5 "RUNNABLE"

# Node.js
kill -USR1 1234   # Enable node --prof mode

When sy (kernel) CPU is high

Bash
# Suspect excessive system calls
strace -p 1234 -c -S calls | head -20

# Check interrupts
cat /proc/interrupts | sort -k2 -rn | head -10

When wa (I/O wait) CPU is high

Bash
# I/O bottleneck (see the dedicated troubleshooting guide)
iostat -x 2 5
iotop -o

Step 5 — Temporary Mitigation

Bash
# Limit CPU usage of a specific process (cgroups)
sudo apt install -y cpulimit
cpulimit -p 1234 -l 50    # Limit PID 1234 to 50% CPU

# Lower priority with nice
renice -n 15 -p 1234

# Adjust OOM Killer score (protect important processes)
echo -1000 > /proc/1234/oom_score_adj

Checklist

  • Is load average consistently exceeding the core count?
  • Is a single process occupying 100% of a CPU?
  • Was there a recent deploy or code change?
  • Is the wa ratio high? → Switch to I/O bottleneck troubleshooting
  • Is the process count abnormally high? → Suspect a fork bomb
#cpu#top#htop#perf#Troubleshooting
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Questions & answers

Ask a question about this guide. We'll review and reply.