Linux Performance Diagnostics: CPU Load, Disk I/O Wait & Socket Analysis
Diagnose high load averages, uninterruptible disk I/O bottlenecks, port conflicts, SYN flood socket states, and OOM Killer kernel events on Linux cloud servers.
When a cloud server becomes unresponsive or API latency spikes, rebooting the instance without inspecting kernel telemetry destroys valuable root-cause evidence. Mastering Linux’s native diagnostic triad—CPU scheduling (
vmstat/htop), Block I/O (iostat/iotop), and Socket state tables (ss)—allows you to pinpoint whether a bottleneck stems from CPU saturation, disk flushing, or a network connection leak in under 60 seconds.
1. Decoding Load Average & CPU States (uptime & vmstat)
Run uptime or top to inspect the 1-minute, 5-minute, and 15-minute Load Average:
uptime
# Example output: 14:22:05 up 45 days, 2 users, load average: 3.45, 1.80, 0.92
In Linux, Load Average measures not only threads actively executing on CPU cores (R state), but also threads blocked in Uninterruptible Sleep (D state) waiting for disk or network I/O. To distinguish CPU saturation from I/O blocking, run vmstat 1 5:
vmstat 1 5
Interpreting the cpu Columns in vmstat:
| Column | Meaning | Diagnostic Threshold & Action |
|---|---|---|
us (User) |
CPU time spent executing user-space application code (Node.js, PHP, Go, crypto) | Sustained > 85% indicates compute saturation; profile application loops or upgrade vCPU cores |
sy (System) |
CPU time spent in kernel space (context switches, iptables, syscall overhead) | High sy (> 30%) often points to excessive packet interrupts or millions of tiny syscalls |
wa (I/O Wait) |
CPU time spent idle while waiting for local disk read/write completion | Sustained > 20% indicates heavy database flushing, unindexed queries, or swap thrashing |
st (Steal) |
Time the hypervisor scheduled physical CPU cores to other tenants | On FlawlessNode enterprise EPYC/Xeon nodes, st normally remains 0%–1% |
2. Pinpointing Disk I/O Bottlenecks (iostat & iotop)
If wa (I/O Wait) is elevated or processes appear stuck in the D state inside htop, install sysstat and iotop to identify the exact process hammering the NVMe disk:
# Ubuntu / Debian
sudo apt update && sudo apt install -y sysstat iotop-c htop
# Rocky Linux / AlmaLinux
sudo dnf install -y sysstat iotop htop
2.1 Inspecting Block Device Latency with iostat
iostat -xz 1 5
Focus on two metrics for vda:
r_await/w_await: Average time (in milliseconds) for read/write requests to be serviced. On FlawlessNode PCIe 4.0 NVMe storage, healthy latency is typically0.2msto2.0ms.%util: Percentage of elapsed time during which I/O requests were issued to the device.
2.2 Finding the Offending Process with iotop
# Show only processes actively performing disk I/O (-o)
sudo iotop -oP
Common culprits include unthrottled backup archiving (tar/gzip), runaway swap paging (kswapd0), or unindexed SQL table scans (mysqld).
3. Auditing Network Sockets & Port Bindings (ss)
The modern ss (Socket Statistics) utility queries the Linux kernel’s tcp_diag netlink interface directly and executes orders of magnitude faster than legacy netstat when tens of thousands of sockets are open.
3.1 Summary of All TCP Connection States
ss -s
Total: 482
TCP: 315 (estab 140, closed 152, orphaned 2, timewait 148)
- High
estab(ESTABLISHED): Active concurrent client sessions. - High
syn-recv(SYN_RECV): Potential TCP SYN flood attack; ensurenet.ipv4.tcp_syncookies = 1is enabled. - High
close-wait(CLOSE_WAIT): Indicates a bug in your local application (e.g., an HTTP client or database pool failing to call.close()on sockets after the remote peer disconnected).
3.2 Identifying Which Process Owns a Specific Port
# List all listening TCP (-t) and UDP (-u) sockets with process PIDs (-p) and numeric ports (-n)
sudo ss -tulnp
# Filter for a specific port (e.g., port 443)
sudo ss -tulnp 'sport = :443'
4. Post-Mortem Investigation: Kernel OOM Killer Logs (dmesg)
If MySQL, Redis, Docker, or your backend process suddenly vanishes without writing an application crash log, it was almost certainly terminated by the Linux Kernel OOM (Out-of-Memory) Killer.
Inspect the kernel ring buffer with human-readable timestamps:
sudo dmesg -T | grep -E -i 'oom|killed process|out of memory'
Example output when physical RAM and Swap are both exhausted:
[Fri Oct 23 18:14:02 2026] Out of memory: Killed process 4812 (node) total-vm:2458120kB, anon-rss:1784200kB, pgtables:3840kB, oom_score_adj:0
How to Remediate OOM Terminations:
- Configure a 2GB–4GB NVMe Swap File as an emergency memory cushion (see Swap File Configuration & Linux Memory Management);
- Cap per-service memory consumption using
MemoryMax=in systemd ormem_limitin Docker Compose; - Upgrade instance RAM cleanly via the FlawlessNode Client Portal without losing data.
5. Finding Deleted Files Still Holding Disk Space (lsof)
Sometimes df -h reports that your root disk is 99% full, yet du -sh /* only adds up to a few gigabytes. This happens when a large log file is deleted (rm /var/log/large.log) while a running process still holds an open file descriptor to it.
Locate open but unlinked (deleted) files:
sudo lsof +L1
Restart the service listed in the COMMAND / PID column (or truncate files in place using truncate -s 0 /path/to/logfile instead of rm) to immediately release the disk blocks back to the filesystem.