vmstat — system load summary
💬 "vmstat command"
vmstat summarizes CPU, memory, and I/O in a single line. It quickly identifies where the bottleneck is.
Starting from the second line, the values are actual measurements; specify an interval to observe continuously.
- r / b: number of processes waiting to run / blocked.
- si / so: swap in/out. If not 0, it indicates memory pressure.
- bi / bo: block I/O. This is a disk bottleneck indicator.
- wa: percentage of CPU waiting on I/O. If high, it indicates a disk bottleneck.
Frequently used options
| Option | Description |
|---|---|
| <interval> <count> | e.g., vmstat 1 5 (5 times at 1-second intervals) |
| -s | Memory-related statistics summary |
| -d | Per-disk statistics |
| -w | Wide output format |
Three essential command combinations
vmstat 1 5— system summary at 1-second intervals, 5 timesvmstat -s | head— memory statistics summaryvmstat -d | head -5— per-disk I/O statistics
💬 "Just point out one pattern commonly used on real production servers"
Here are common situations encountered on real production servers, organized step by step.
Step 1 · Summary observation
Measure for a few seconds and observe the trend.
vmstat 1 5
Step 2 · Identify the bottleneck
If si/so is high, it is memory; if wa is high, it is disk.
vmstat 1 5 | awk '{print $1,$2,$7,$8,$16}'
Step 3 · Find the cause
Look at the process using that resource.
ps -eo pid,%cpu,rss,comm --sort=-rss | head
How it is used in practice
1. Identifying I/O bottlenecks
Situation — The server is slow, but the CPU is idle.
vmstat 1 5
Result — If wa (wait) is high and bi/bo is large, it is a disk bottleneck.
Point — Use iostat to narrow down which disk, then identify the process.
2. Detecting swap usage
Situation — Check whether memory is insufficient.
vmstat 1 5 | awk 'NR>2{print $7,$8}'
Result — If si/so is not 0, swap is actually being used.
Point — Heavy swapping causes a sharp drop in performance.
Things to keep in mind
- The first line is an average since boot, so do not use it as a measurement.
- A single run without an interval is a snapshot and misses trends.
- In containers, host-wide values may be displayed.
Actual execution output
This is the result of observing CPU, memory, and I/O status at 1-second intervals.
!vmstat command execution result: system load summary
Production server
Source (HTML): https://games.aidebatehub.com/programs/linux/troubleshooting/vmstat.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments