All modules in this track (25)
In this module, you'll learn to:
- Work an incident in a fixed order: symptom, change, scope, evidence, hypothesis, fix
- Check CPU, memory, disk, and network for utilization, saturation, and errors
- Run a 60-second checklist and read what each command is telling you
Before you start: finish Part 2, especially Processes, Signals & File Descriptors and Memory, the Page Cache & the OOM Killer. Open a shell on your lab VM with multipass shell lab, and install the tools:
sudo apt install -y sysstat stress-ng
Method beats memory
New engineers often troubleshoot by recognition: "last time it was the disk, so check the disk". That works for problems you've seen before and fails on everything else. Experienced engineers follow a method, so they make progress even on problems they've never met, and they can hand the investigation to someone else halfway through.
Three habits matter most:
- Define the symptom with a number. "Slow" isn't a symptom; "the checkout page takes 8 seconds instead of 300 ms since 14:05" is.
- Ask what changed. Most incidents follow a change. Check
less /var/log/apt/history.log,journalctl --since "2 hours ago",lastfor recent sign-ins, and your deploy history. - Write as you go. Note each command, what it showed, and the time. It stops you repeating checks, and it becomes the incident timeline.
Check every resource the same way
The USE method, from performance engineer Brendan Gregg, gives you a checklist that doesn't depend on guessing. For every resource, ask three questions:
- Utilization: how busy is it, as a percentage of its capacity?
- Saturation: is work queueing because it's too busy?
- Errors: is it failing?
| Resource | Utilization | Saturation | Errors |
|---|---|---|---|
| CPU | vmstat 1: us + sy; mpstat -P ALL 1 per CPU | vmstat r column above the CPU count; load average | Rare; dmesg |
| Memory | free -m: used versus available | Swapping (vmstat si and so); OOM kills | dmesg |
| Disk | iostat -xz 1: %util | iostat await rising; processes in D state (vmstat b column) | dmesg I/O errors; filesystem turned read-only |
| Network | sar -n DEV 1 against the link's speed | Drops; TCP retransmits (sar -n ETCP 1); full conntrack table | ip -s link errors |
Saturation is the one people miss. A disk at 60% utilization can still be the bottleneck if requests are queueing behind each other.
The first 60 seconds
Netflix's performance team published a checklist of ten commands to run in the first minute on any slow Linux server. It covers the USE questions for every resource:
| Command | Look for |
|---|---|
uptime | Load averages over 1, 5, and 15 minutes: rising, falling, or steady? |
sudo dmesg -T | tail | OOM kills, disk errors, dropped packets: the kernel's complaints |
vmstat 1 | r above the CPU count (CPU saturation), b (D state), si/so (swapping), wa (waiting on I/O), st (steal) |
mpstat -P ALL 1 | One CPU at 100% while the others idle: a single-threaded bottleneck |
pidstat 1 | Which processes are using the CPU |
iostat -xz 1 | %util near 100 and await in tens of milliseconds: a saturated disk |
free -m | available memory |
sar -n DEV 1 | Network throughput compared with the interface's limit |
sar -n TCP,ETCP 1 | New connections per second, and retransmits (a sign of network trouble) |
top | A final overview, to check what the other commands suggested |
Press Ctrl+C to stop each one after a few seconds. You won't use every column every time, but running the whole list stops you fixing the first thing you notice and missing the real cause.
Try it · A CPU-bound server. Load both CPUs, then run the checklist and see how it shows up:
stress-ng --cpu 2 --timeout 60s &
uptime # the 1-minute load climbs towards 2
vmstat 1 5 # r is about 2, us is near 100, id near 0
mpstat -P ALL 1 3 # both CPUs busy
pidstat 1 3 # stress-ng is the process using itHigh load, idle CPUs
Users say the server is sluggish. The load average is high, but when you look at top, the CPUs are mostly idle. Start the background job that's behind it, the way the scheduler starts it every night:
sudo systemd-run --unit=nightly-export \
stress-ng --hdd 4 --hdd-opts dsync --timeout 600sNow forget what you just ran. Your job: find what's slowing the server down, using the checklist rather than memory, and stop it. Try it before opening a hint.
Hint 1 · Where to look
- The load average counts more than processes using the CPU. Work through the checklist and look for the resource that's saturated, not the one that's busy.
Hint 2 · Which tool
- In
vmstat 1, watch thebandwacolumns. Iniostat -xz 1, watch%utilandawait.ps -eo pid,stat,cmd | awk '$2 ~ /D/'lists processes in D state, andpidstat -d 1shows which processes are doing the disk I/O.
Hint 3 · The cause and the fix
- Cause: the
nightly-exportjob makes many small synchronous disk writes. Its workers spend most of their time in D state, waiting on the disk, and D-state processes count towards the load average. The disk is saturated (%utilnear 100, risingawait), while the CPUs have little to do:wais high andusis low. - Fix:
systemctl status nightly-exportidentifies the job; stop it now withsudo systemctl stop nightly-export. For good: run it when the server is quiet, give it a lower I/O priority (IOWeight=in its unit, orionice -c3), or move it to its own disk. - Prevent it: alert on disk saturation (
awaitand%util), not only on CPU. A load-average alert on its own can't tell you which resource is the problem.
Implementation notes
- Load average is a count, not a percentage. Compare it with the number of CPUs (
nproc), and remember it includes processes waiting on disk. st(steal) above a few percent on a cloud VM means the hypervisor is giving your CPU time to someone else. On burstable instance types it often means CPU credits have run out.- Restart last. A restart can fix the symptom and destroy the evidence. Capture the checklist output, and logs, before restarting anything.
- Keep the timeline as you go. A list of "14:05 alert, 14:07 vmstat shows b=6, 14:09 found nightly-export" turns into the postmortem with no extra work.
Key terms
- Symptom: a precise, measured description of what's wrong, for whom, and since when.
- USE method: for every resource, check utilization, saturation, and errors.
- Saturation: work queueing because a resource is fully busy.
- Load average: the average number of processes running, waiting for CPU, or in D state.
- iowait (
wa): CPU time spent idle while waiting for I/O. - Steal (
st): CPU time a virtual machine wanted but the hypervisor gave to another. - Mitigate versus fix: restore service now, remove the cause after.
Pop quiz
Five questions: three on the ideas in this module, and two scenarios where you apply them. The order changes every time you take it, and 4 out of 5 passes.
5 questions. Decide on your answer to each, then check it.
-
Concept
What are the three questions the USE method asks about every resource?
Show answer
Utilization, saturation, and errors
For CPU, memory, disk, and network, ask how busy it is, whether work is queueing, and whether it's failing. Saturation is the one most often missed.
-
Concept
In
vmstat 1output on a 4-CPU server, thercolumn stays around 12. What does that mean?Show answer
About 12 processes want CPU at once, so the CPUs are saturated
rcounts processes running or waiting to run. Consistently more than the CPU count means work is queueing for CPU. -
Concept
Why ask "what changed?" early in an incident?
Show answer
Most incidents follow a change, so it's often the fastest route to the cause
Deploys, config edits, package upgrades, and traffic shifts cause most incidents. Checking them first often turns a long investigation into a short one.
-
Scenario
A cloud VM is slow.
topshows the CPUs 40% idle, butvmstatreportsstat 35%. What's happening?Show answer
The hypervisor is withholding CPU time, often because a burstable instance has run out of credits
Steal time is CPU the VM wanted but didn't get. On burstable instances it usually means CPU credits are exhausted; a different instance type or size fixes it.
-
Scenario
During an incident, a colleague wants to restart the database straight away "to see if that helps". What do you suggest first?
Show answer
Capture the checklist output and recent logs, then decide; a restart can destroy the evidence
Restarting may restore service, which is sometimes the right call, but it wipes the state that explains the problem. A minute of evidence-gathering first is usually worth it.