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
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.
nproc
Memory
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
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
ss -s
ss -tunap
sar -n DEV 1
sslists sockets and listening ports.sarsamples interface traffic and error counts.
Diagnosis method
- Reproduce or sample the incident.
- Measure CPU, memory, I/O and network separately.
- Identify the top process or socket connection.
- Check whether saturation tracks application traffic.
- 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

