- Load average is not a percentage. Compare it with your core count: load 4 on 4 cores is fully busy, load 4 on 16 cores is quiet.
- Read the
availablecolumn infree -h, notfree. Linux uses spare RAM as cache and hands it back when a process needs it. - High
wain top means processes are waiting on the disk, and more CPU will not help. dfshows free space;dushows what is using it. Check inodes too: a disk can be full with space remaining.- One reading tells you very little. Take three, a few minutes apart, before you decide anything.
How do I check CPU usage on a Linux server?
Run uptime for the load average, then top to see which processes use the CPU. Load average counts the processes running or waiting to run. It is not a percentage, so compare it with your number of CPU cores (nproc): load 4 on 4 cores is fully busy.
$ uptime
10:24:31 up 47 days, 3:12, 2 users, load average: 2.31, 1.87, 1.42
# 1min 5min 15min
# How many cores do you have?
nproc
# Load per core: the number that actually means something
echo "$(cut -d' ' -f1 /proc/loadavg) / $(nproc) cores"| Load on a 4-core server | Means |
|---|---|
| Under 4.0 | Nothing is waiting. Healthy |
| Around 4.0 | Fully used, with no spare capacity |
| 8.0 | Twice the work the machine can do. Requests are queueing |
| 1min far above 15min | A spike happening now |
| 15min far above 1min | It has already passed. Look at the logs, not at top |
The last two rows are why you read all three figures, not just the first.
top
# %Cpu(s): 12.5 us, 3.1 sy, 0.0 ni, 82.2 id, 2.1 wa, 0.0 hi, 0.1 si
# ^^^^ user ^^^ system ^^^^ idle ^^^ I/O WAIT
# Useful keys inside top:
# P sort by CPU
# M sort by memory
# 1 show every core separately
# c show the full command line
# k kill a process
# q quit
# htop is far easier to read if you can install it
sudo apt install -y htop && htopwa. It is the share of time the CPU sat idle waiting for the disk.High wa is a disk problem, not a CPU problem
If wa stays above 10 percent, your processes are stuck waiting for storage. A faster CPU changes nothing. The fix is faster disks, less disk activity, or more RAM so the cache can serve the reads.
How do I check memory usage correctly?
Run free -h and read the available column. Linux fills unused RAM with a cache of recently read files on purpose, so the free column is nearly always small and nearly always irrelevant. The cache is handed back to any process that needs it.
$ free -h
total used free shared buff/cache available
Mem: 7.8Gi 3.1Gi 262Mi 145Mi 4.4Gi 4.2Gi
Swap: 2.0Gi 128Mi 1.9Gi
# ^^^^^^ ^^^^^^
# looks alarming the truth: 4.2Gi spare
# What is using it, biggest first
ps -eo pid,ppid,rss,comm --sort=-rss | head -15
# Total memory used by all PHP-FPM workers, in MB
ps -ylC php-fpm8.3 --sort:rss | awk 'NR>1 {s+=$8} END {printf "%.0f MB\n", s/1024}'| Column | Means | Worry when |
|---|---|---|
| total | Physical RAM installed | Never |
| used | In use by processes | It nears total and available is low |
| free | Completely untouched | Never: low here is normal |
| buff/cache | File cache, given back on demand | Never |
| available | What a new process could actually get | Below about 10 percent of total |
Only the last row is a warning sign. Alerting on free gives constant false alarms.
# The out-of-memory killer leaves a record
sudo dmesg -T | grep -i 'killed process'
sudo journalctl -k | grep -i 'out of memory'
# Swap usage per process: heavy swapping is why a server feels frozen
for f in /proc/*/status; do
awk '/^Name|^VmSwap/ {printf "%s ", $2} END {print ""}' "$f" 2>/dev/null
done | grep -v ' 0 kB' | sort -k2 -rn | headThe OOM killer usually picks your database
It targets the process using the most memory, which on a web server is nearly always MySQL or MariaDB. The site then fails with a database connection error that looks nothing like a memory problem. Check dmesg before you chase the connection error.
How do I check disk space and find what is using it?
df shows how full each filesystem is. du shows which directories fill it. You need both. Check inodes as well (the slots that track each file): a filesystem that runs out of them refuses new files even with plenty of space left.
# Free space per filesystem
df -h
# Inodes: a disk can be 'full' at 40% space used
df -i
# Biggest directories at the top level, sorted
sudo du -h --max-depth=1 / 2>/dev/null | sort -rh | head -15
# Then narrow down
sudo du -h --max-depth=1 /var 2>/dev/null | sort -rh | head
# Biggest individual files anywhere
sudo find / -type f -size +500M -exec ls -lh {} \; 2>/dev/null | awk '{print $5, $9}'
# ncdu is worth installing: an interactive, browsable du
sudo apt install -y ncdu && sudo ncdu /varDeleting a file does not always free the space
If a process still has the file open, the space stays in use until that process closes it or restarts. This is why deleting a huge log file can leave df unchanged. sudo lsof +L1 lists deleted files that are still open, and the process holding each one.
# Log files, the most common cause by far
sudo du -sh /var/log/* | sort -rh | head
# Truncate a huge live log without breaking the writing process
sudo truncate -s 0 /var/log/nginx/access.log
# Old kernels on Debian and Ubuntu
sudo apt autoremove --purge
# Package manager caches
sudo apt clean # Debian / Ubuntu
sudo dnf clean all # RHEL family
# Docker, which quietly accumulates a great deal
docker system df
docker system prune -a --volumes # read what this will delete firsttruncate -s 0, not rm, on a log that is being written to. rm leaves the space held by the open file.How do I check disk I/O?
When wa is high in top, disk input and output (I/O) is the limit. Two tools split the job: iostat shows how busy each disk is, and iotop shows which process is using it.
sudo apt install -y sysstat iotop
# Per-device utilisation, refreshing every 2 seconds
iostat -xz 2
# %util near 100 means the device is saturated
# await is average wait time per request in ms
# Which process is doing the I/O
sudo iotop -o # -o shows only processes actually doing I/O
# Per-process totals, no extra tools needed
sudo grep -H '' /proc/*/io 2>/dev/null | grep read_bytes | sort -t: -k3 -rn | head%util above 90 with a rising await means storage is the bottleneck.On a virtual server, watch %steal in top too. It is time your CPU was ready to run but the host machine gave to another customer. If it stays above a few percent, the physical machine is overloaded, and no tuning on your side will fix it.
What should I check first when a server feels slow?
Work in this order. It takes about a minute and separates the four causes behind nearly every case.
- 1
uptime. Load against core count. High load with low CPU use points at disk or memory, not computation. - 2
free -h. Readavailable. Low available plus swap activity means the server is thrashing (constantly moving memory to disk), and everything else will look bad as a result. - 3
df -handdf -i. A full disk breaks everything downstream in confusing ways, so rule it out early. - 4
top, sorted by CPU then by memory. Now you know which process is responsible, which is what lets you act. - 5The logs for that process. Linux system logs and where to find them covers where each service writes and how to follow it.
echo '--- load / cores ---'; uptime; nproc
echo '--- memory ---'; free -h
echo '--- disk ---'; df -h | grep -vE 'tmpfs|udev'
echo '--- inodes ---'; df -i | grep -vE 'tmpfs|udev'
echo '--- top CPU ---'; ps -eo pcpu,pid,user,comm --sort=-pcpu | head -6
echo '--- top RAM ---'; ps -eo rss,pid,user,comm --sort=-rss | head -6
echo '--- OOM kills ---'; sudo dmesg -T | grep -i 'killed process' | tail -5One reading is an anecdote
A single snapshot cannot tell a passing spike from a lasting problem. Take three, a few minutes apart, and compare. For something that has already happened, you need continuous monitoring. On G7Cloud, the dashboard shows each site's CPU and memory over the last 7 days, so you can see the moment it went wrong. See platform monitoring.
If the process at the top of the list is PHP, the cause is usually in the application, not the server. Troubleshooting high CPU and memory on WordPress picks up from there.
Frequently asked questions
What is a good load average on a Linux server?
Anything below your core count. Load 3 on a 4-core machine is healthy; load 3 on a single-core machine means requests are queueing three deep. Divide the load by the output of nproc for the figure that means something.
Why does free -h show almost no free memory?
Linux uses spare RAM as a file cache, because idle memory is wasted memory, and it gives that cache back as soon as a process needs it. Read the available column instead: it is what a new process could get. Low free with healthy available is normal.
What does wa mean in top?
I/O wait: the share of time the CPU sat idle waiting for the disk. If it stays above 10 percent, storage is your bottleneck and more CPU will not help. Use iostat -xz 2 and iotop -o to find the disk and the process responsible.
My disk shows free space but I get "no space left on device". Why?
You have run out of inodes, the slots that track individual files. Check with df -i. Millions of small session or cache files use them up long before the space runs out. Delete the small files rather than hunting for large ones.
I deleted a large log file but df still shows the disk full. Why?
A process still has the file open, so the space stays in use until that process closes it. Find it with sudo lsof +L1, then restart the process holding the file. Next time, use truncate -s 0 file.log instead of rm on a live log.
How do I find which process is using the most memory?
ps -eo rss,pid,user,comm --sort=-rss | head sorts by memory in use. In top or htop, press M. Many small workers, such as a PHP-FPM pool, can add up to far more than the single largest process.
About G7Cloud Engineering
Articles written by the engineers who build and run G7Cloud: UK managed hosting and the AI Website Builder. We write about what we operate every day: containers, backups, databases, and the small-business websites that run on them.
More about G7Cloud →