Performance Monitoring — CPU, Memory, Disk, Network
Users say notes-api "feels slow". That is a symptom, not a diagnosis. A server has only a few resources that can run out, and a short, fixed checklist tells you which one is to blame in a couple of minutes.
The rule
Check the four resources in order: CPU, memory, disk, network.
For each resource, ask three questions: how busy is it, is work queueing for it, and are there errors? That is the idea behind the well-known USE method: utilisation, saturation, errors.
CPU. uptime shows the load average over 1, 5 and 15 minutes: roughly how many tasks were running or waiting. Compare it with the number of cores from nproc. A load of 2.0 on 4 cores has spare room; 7.8 on 2 cores means work is queueing. top shows which process is using it.
Memory. free -h shows memory. Read the available column, not free: Linux fills spare memory with disk cache and gives it back on demand, so a small free value is normal. Real trouble is low available, heavy swap use, or the kernel's out-of-memory killer ending processes (dmesg or journalctl -k shows it).
Disk. df -h shows space per filesystem. df -i shows inodes, the slots for file entries: millions of tiny files can exhaust them while space remains. du -sh /var/log/* finds what is big. iostat -x 1 or vmstat 1 shows whether the disk is the bottleneck, with processes waiting on input and output.
Network. ss -s summarises connections; ip -s link shows traffic and errors per interface.
uptime && nproc
free -h
df -h && df -i
vmstat 1 5The shortcut
Always walk the same order, top to bottom, and do not stop at the first odd number until you have seen all four. Fixed order keeps you from chasing the resource you happen to suspect.
CPU
uptimeshows a load of 7.8;nprocsays 2 cores. CPU is saturated.
The trap: seeing "free: 120M" and deciding the server is out of memory. Check available before you panic.
Drills
Answer fast — trust the rule.
A 4-core server shows a load average of 4.0. What does that suggest?
In free -h, which column best shows how much memory new programs can use?
Writes fail with "No space left on device", but df -h shows 30% free. What do you check next?
Which command shows the number of CPU cores to compare against the load average?
Remember
- Check the four resources in order: CPU, memory, disk, network.
- Shortcut: same order every time; compare load with
nproc, read memory'savailable. - Trap: panicking over low
freememory or forgetting inodes.
