appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

Performance troubleshooting

Lesson 1 of 412 minAdvanced

A short method to find out whether the CPU, memory, disk or network is the bottleneck.

When a server is slow, do not guess. Check the four resources in turn and read the numbers.

CPU and load

uptime          # load averages for 1, 5 and 15 minutes
top             # live view (press 1 for each core, M to sort by memory)
vmstat 1 5      # every second, five times

The load average counts processes running or waiting. As a rule of thumb, a load above the number of cores for long periods means queueing. Linux also counts processes waiting for disk, so high load with an idle CPU points to I/O.

Memory

free -h
ps aux --sort=-%mem | head

Look at the available column, not "free". Linux uses spare memory as cache, which is good. Danger signs are active swapping (si/so in vmstat) and the kernel OOM killer in dmesg.

Disk and network

iostat -x 1       # %util and await per device (package sysstat)
df -h             # space
df -i             # inodes
ss -s             # socket summary

CarefulA disk can be "full" because it ran out of inodes (too many small files) even when df -h shows free space. Always check df -i as well.

NoteChange one thing at a time and measure again. Record the numbers before and after.

Test yourself

Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.

1. Load is very high but the CPU is mostly idle. What is likely?
2. Which memory column should you trust to see what is usable?
Hintdf with a flag for human-readable.

Key terms