SkillSprout
Chapter 2 · Lesson 11
Advanced
1 min read

Diagnose CPU, Memory and I/O

Overview

Performance diagnosis starts with measurements. CPU, memory, disk I/O and network bottlenecks produce different symptoms. A high load average is not always CPU saturation, and memory pressure may come from cache behavior or active application use.

Detailed Notes

CPU and load

bash
uptime
top
ps -eo pid,stat,%cpu,%mem,comm --sort=-%cpu | head

Load average is the number of runnable or uninterruptible tasks over 1, 5 and 15 minutes. Compare it with CPU core count.

bash
nproc

Memory

bash
free -h
vmstat 1

Read free, active memory, swap and memory reclaimed. Linux uses spare memory for cache, so low "free" does not alone mean a memory failure.

Disk I/O

bash
iostat -xz 1
pidstat -d 1

Look for queue depth, utilization and await. iowait means CPU time waiting for I/O, but it can coexist with available CPU.

Network

bash
ss -s
ss -tunap
sar -n DEV 1
  • ss lists sockets and listening ports.
  • sar samples interface traffic and error counts.

Diagnosis method

  1. Reproduce or sample the incident.
  2. Measure CPU, memory, I/O and network separately.
  3. Identify the top process or socket connection.
  4. Check whether saturation tracks application traffic.
  5. Change one variable and measure again.

Do not kill the highest-CPU process until you know whether it is intentional work, a runaway loop or a duplicate worker.

Common Interview Questions

Finished this lesson?

0 of 25 lessons done · 0% of the course