Skip to content

DevOps Operations / Service monitoring · Step 5 of 7

Lesson: Resource SaturationSwitch
← DevOps Operations

Delivery and containers

Resource Saturation

Find out which limited resource a service is running out of.

Saturation is the point where a resource has more work than it can handle, so work waits in a queue or fails. Services slow down or crash when CPU, memory, disk, or a configured limit runs out.

CPU and load

bash
$ nproc
2
$ uptime
 11:02:10 up 3 days,  4:11,  1 user,  load average: 5.80, 4.10, 2.00

Load average counts tasks that are running or waiting to run, and on Linux also tasks in uninterruptible sleep, usually waiting for disk. A load of 5.8 on 2 CPUs suggests a queue. Here the 1 minute value is higher than the 15 minute value, so pressure is rising. Use top or ps to find the busy process.

Memory

bash
$ free -h
               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       2.9Gi       120Mi        40Mi       800Mi       650Mi
Swap:          1.0Gi       600Mi       424Mi

Look at available, not just free. Linux uses spare memory for cache and can reclaim much of it. If memory runs out, the kernel's OOM killer may end a process. Search for it with sudo journalctl -k | grep -i 'out of memory'.

vmstat 1 shows activity each second. Sustained non-zero values in the si and so columns mean pages are moving in from and out to swap.

Disk

A disk can run out of space or of inodes, the records that describe files:

bash
$ df -h /var
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G   19G  300M  99% /
$ df -i /var

If df -i shows 100 percent, you cannot create new files even with free space. For a busy disk, iostat -x 1 from the sysstat package shows device activity and wait times.

Limits and connections

Services also hit their own limits, such as open files or worker counts. Read a running process's limits from /proc/PID/limits. ss -s summarises sockets, and ss -ltn lists listening TCP sockets.

A high percentage alone is not always trouble. Watch for queues, rising latency and errors together. Trends help too: a disk that gains a little every day will fill on a predictable date.

Try it

On a test machine, record nproc, uptime, free -h, df -h and df -i. Decide which resource has the least headroom. The packages and disk lab gives more disk practice.

Check your understanding

Resource Saturation

All 3 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.