Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Terminal Knowledge  ›  Lesson

Performance Monitoring — CPU, Memory, Disk, Network

Performance Monitoring 12 minPerformance problems are diagnosed by checking CPU, memory, disk and network in a fixed order, looking at how busy each is, whether work is queueing and whether there are errors.

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 5

The 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.

Why is notes-api slow?Step 1 of 4
  1. CPU

    uptime shows a load of 7.8; nproc says 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.

quick drill

A 4-core server shows a load average of 4.0. What does that suggest?

quick drill

In free -h, which column best shows how much memory new programs can use?

quick drill

Writes fail with "No space left on device", but df -h shows 30% free. What do you check next?

quick drill

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's available.
  • Trap: panicking over low free memory or forgetting inodes.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainThe slow-server checklist

notes-api is slow on a 2-core server. Explain the commands you would run for each of the four resources and how you would read the key number in each.