How to Analyze CPU and Memory Usage on Linux Servers

A step-by-step method to read Linux CPU and memory data: load average, steal, iowait, MemAvailable, swap activity, PSI and cgroup limits.

Aug 2, 2025 - 16:52
Nov 9, 2026 - 15:06
 0  69
TOPICDevOps BasicsPractical guide
How to Analyze CPU and Memory Usage on Linux Servers

To analyze CPU and memory on a Linux server, start with load average and per-CPU time (user, system, iowait, steal) from top, mpstat or vmstat, then check memory with free and /proc/meminfo, judging by "available" rather than "free." Pressure Stall Information in /proc/pressure shows whether tasks are actually waiting. Then find the responsible process or cgroup.

Most guides list commands. This one is about reading the numbers: what each figure means, which ones mislead, and a step-by-step order for deciding whether a server is short of CPU, short of memory, or just busy. It is part of our Linux and RHEL 10 guide cluster. For a catalogue of tools, see best tools for troubleshooting Linux performance; for process-level views, see monitoring processes with ps, top and htop.

Key takeaways

  • Load average counts tasks that are running, waiting for CPU and, on Linux, waiting in uninterruptible sleep (usually disk or NFS I/O). A high load does not always mean the CPU is busy.
  • Split CPU time into user, system, iowait, steal and idle before drawing conclusions. High steal on a VM means the hypervisor is not giving you the CPU you expected.
  • "Free" memory is usually low on a healthy server because Linux uses spare RAM as page cache. Use the "available" column (MemAvailable).
  • Swap in use is not a problem by itself. Continuous swap-in and swap-out (vmstat si and so) is.
  • PSI files in /proc/pressure/ report the share of time tasks were stalled on CPU, memory or I/O, which is the most direct measure of "is this hurting?"
  • Always compare against a baseline. Collect history with sar or a metrics system so you know what normal looks like.

A five-step method

  1. Is anything waiting? Check load average against CPU count, and PSI.
  2. What kind of CPU time? Break it down per CPU with mpstat or top.
  3. Is memory short? Look at available memory, swap activity and reclaim.
  4. Who is responsible? Find the process, thread or cgroup.
  5. Is this new? Compare with history from sar or monitoring.

Step 1: load average and pressure

uptime
# 10:42:17 up 31 days,  3:05,  2 users,  load average: 7.85, 6.12, 3.40

nproc
# 8

The three numbers are 1, 5 and 15 minute averages. Read them as a trend: here load is rising. Compare with the CPU count from nproc. A load of 7.85 on 8 CPUs could be fine or could be painful, depending on what makes up the load.

On Linux, load includes tasks in uninterruptible sleep (state D), which usually means waiting on disk or network storage. So a server with a stuck NFS mount can show load of 40 with idle CPUs. Check how many tasks are in each state:

vmstat 1 5
# procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
#  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
#  9  0      0 412340  90212 5123400   0    0     3    41 3210 5400 82  9  9  0  0

Column r is runnable tasks (running or waiting for CPU) and b is tasks blocked in uninterruptible sleep. If r stays above the CPU count, you have CPU contention. If b is high, look at storage instead.

Pressure Stall Information

PSI answers a better question than load: how much time were tasks stalled waiting for a resource? The kernel exposes it in /proc/pressure/cpu, /proc/pressure/memory and /proc/pressure/io, and per cgroup in cpu.pressure, memory.pressure and io.pressure on cgroup v2.

cat /proc/pressure/memory
# some avg10=4.12 avg60=2.87 avg300=0.95 total=81234567
# full avg10=1.03 avg60=0.66 avg300=0.21 total=20345678
  • some is the percentage of time at least one task was stalled on the resource.
  • full is the percentage of time all non-idle tasks were stalled at once. Sustained full pressure on memory means the workload is thrashing.
  • avg10, avg60 and avg300 are averages over 10, 60 and 300 seconds; total is cumulative stall time in microseconds.

The kernel documentation notes that CPU full is undefined at system level and is reported as zero there. Use CPU some at system level and full inside cgroups.

Step 2: break CPU time down

mpstat -P ALL 1 3     # from the sysstat package
FieldMeaningIf it is high
%usrApplication code in user spaceNormal for compute work. Profile the application if it is unexpected.
%sysKernel work: system calls, networking, memory managementLook for many small syscalls, heavy network traffic, lock contention or memory reclaim.
%iowaitCPU idle while some task waits for I/OPoints to storage, not CPU. Check with iostat.
%stealTime the hypervisor gave your vCPU to someone elseThe VM is undersized for its CPU credits or the host is busy. Resize or move instance type.
%irq, %softHardware and software interrupt handlingHeavy network packet rates; check interrupt distribution across CPUs.
%idleNothing to doSpare capacity.

Look per CPU, not only the total. One CPU at 100 percent with seven idle often means a single-threaded process or all network interrupts landing on one core. The average says 12 percent busy while the application is actually maxed out.

iowait is easy to misread. It is idle time with outstanding I/O, so it can fall when CPU work rises even though the disk problem has not changed. Treat it as a hint to check iostat -xz 1, not as a CPU metric.

In top, the same breakdown appears on the %Cpu(s) line as us, sy, ni, id, wa, hi, si and st. Press 1 to show each CPU.

Step 3: read memory correctly

free -h
#                total        used        free      shared  buff/cache   available
# Mem:            31Gi        12Gi       420Mi       1.1Gi        18Gi        17Gi
# Swap:          4.0Gi       256Mi       3.7Gi

This server has only 420 MiB free, which looks alarming, but 17 GiB available. Linux keeps file data in page cache and reclaims it when applications need memory, so "available" is the figure that matters. It comes from MemAvailable in /proc/meminfo, the kernel's estimate of memory that can be used without swapping.

grep -E 'MemTotal|MemAvailable|Cached|Dirty|AnonPages|Shmem|Slab|SReclaimable|SUnreclaim|Committed_AS|CommitLimit' /proc/meminfo
FieldWhat it tells you
MemAvailableMemory usable without swapping. Trend this.
AnonPagesProcess memory not backed by files (heaps, stacks). Growth here over days suggests a leak.
CachedPage cache. Large is normal and mostly reclaimable.
ShmemShared memory and tmpfs. Counted in cache but not easily reclaimable.
DirtyData waiting to be written to disk. Large values mean writes are backing up.
SReclaimable / SUnreclaimKernel slab caches. A growing SUnreclaim can indicate a kernel or driver leak.
Committed_AS vs CommitLimitHow much memory processes have asked for versus the overcommit limit.

Swap and reclaim

Some swap in use is normal: the kernel moves idle pages out to make room for cache. The warning sign is activity. In vmstat 1, sustained non-zero si (swap in) and so (swap out) means the system is moving pages back and forth under pressure. sar -B 1 shows paging and reclaim rates; high pgscand/s (direct reclaim) means processes are stalling to free memory themselves. Memory PSI confirms whether this is hurting.

The OOM killer

When the kernel cannot reclaim enough memory, it kills a process. Check the kernel log:

journalctl -k | grep -i -E 'out of memory|oom-kill|killed process'

In containers and systemd services, the limit is often the cgroup rather than the whole machine. A container can be OOM-killed while the host has plenty of free memory.

Step 4: find who is responsible

# Top CPU and memory consumers
ps -eo pid,ppid,user,%cpu,%mem,rss,cmd --sort=-%cpu | head -15
ps -eo pid,user,rss,vsz,cmd --sort=-rss | head -15

# Per-process CPU and memory over time (sysstat)
pidstat -u 1 5
pidstat -r 1 5

# Threads of one busy process
top -H -p 12345

RSS (resident set size) is the memory a process has in RAM, but shared libraries and shared memory are counted in every process that maps them, so adding RSS across processes overstates usage. For a precise per-process number, read Pss from /proc/PID/smaps_rollup, which divides shared pages among the processes sharing them.

Look at cgroups, not just processes

On a modern systemd distribution such as RHEL 10, every service and container runs in a cgroup. systemd-cgtop shows CPU, memory and I/O per cgroup, which maps directly to services. For a single cgroup on cgroup v2:

systemd-cgtop
cat /sys/fs/cgroup/system.slice/nginx.service/memory.current
cat /sys/fs/cgroup/system.slice/nginx.service/memory.max
cat /sys/fs/cgroup/system.slice/nginx.service/memory.events   # look at oom_kill
cat /sys/fs/cgroup/system.slice/nginx.service/cpu.stat         # nr_throttled, throttled_usec

A rising nr_throttled in cpu.stat means the cgroup is hitting its CPU limit. The application slows down even though the host shows idle CPU. This is a frequent cause of latency in Kubernetes pods with tight CPU limits.

Step 5: compare with history

A single snapshot tells you little. sysstat collects data in the background once its timer is enabled, and sar reads it back:

sudo systemctl enable --now sysstat
sar -u            # CPU today
sar -r            # memory today
sar -q            # run queue and load
sar -u -f /var/log/sa/sa05   # CPU on the 5th of the month

The file location can differ between distributions, so check your package documentation. For fleets, export the same metrics with Prometheus node_exporter and graph them; our guide to Prometheus and Grafana together shows the setup.

Reading common patterns

What you seeLikely meaningNext check
Load high, vmstat r high, %usr high, CPU PSI some highReal CPU saturationProfile the top process; scale out or add CPUs
Load high, vmstat b high, CPUs idleTasks blocked on I/Oiostat -xz 1, NFS or disk latency
%steal above a few percentNoisy neighbour or exhausted burst creditsInstance type and credit balance
%sys high with many context switchesSyscall-heavy or lock-contended workloadpidstat -w, perf top
Free low, available high, no swap activityHealthy page cacheNothing to fix
Available falling for days, AnonPages risingMemory leakPer-process RSS or PSS trend
si/so non-zero, memory PSI full risingThrashingReduce workload or add memory; check limits
Container slow, host idle, nr_throttled risingCPU limit throttlingRaise the limit or remove it if requests are set

Turning analysis into alerts

Alert on symptoms that hurt rather than raw percentages. Good candidates are sustained memory PSI full, MemAvailable below a level you derive from your baseline, swap-in rate, CPU steal, cgroup OOM kills and CPU throttling for latency-sensitive services. A CPU at 90 percent with no pressure and good response times is a well-used server, not an incident. For tuning once you know the bottleneck, see performance tuning tips for RHEL 10 and Linux shell commands DevOps engineers use daily.

Learn Linux performance hands-on

Reading vmstat, sar, PSI and cgroup files on real servers is part of our Linux administration training, taught in the Kharadi, Pune classroom and live online.

FAQ

How do I check CPU usage in Linux?

Use top for a live view (press 1 for each CPU), mpstat -P ALL 1 for a per-CPU breakdown of user, system, iowait and steal time, and sar -u for history once sysstat is collecting data.

Why does Linux show so little free memory?

Linux uses spare RAM as page cache and gives it back when applications need it. Check the available column in free or MemAvailable in /proc/meminfo, which estimates memory usable without swapping.

Is a high load average always bad?

No. Linux load includes tasks waiting on disk or network I/O as well as tasks using or waiting for CPU. Compare it with the CPU count and check vmstat r and b columns and PSI to see what is actually waiting.

What is CPU steal time?

Steal is time your virtual CPU was ready to run but the hypervisor ran something else. Sustained steal means the VM is not getting the CPU it expects, often because of a busy host or exhausted burst credits.

What is Pressure Stall Information in Linux?

PSI reports the percentage of time tasks were stalled waiting for CPU, memory or I/O, over 10, 60 and 300 second windows. It is read from /proc/pressure and from cgroup v2 pressure files.

Is using swap a sign of a memory problem?

Not by itself. Idle pages are often swapped out to make room for cache. Continuous swap-in and swap-out activity, seen in vmstat si and so columns, is the real warning sign.

How do I find which process uses the most memory?

Run ps -eo pid,rss,cmd --sort=-rss | head for a quick list, or pidstat -r over time. For accurate shared memory accounting read Pss from /proc/PID/smaps_rollup, and use systemd-cgtop to see usage per service.

References

Interested in learning more?Get a callback from our training advisors.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.