{"id":813,"date":"2026-08-06T23:28:54","date_gmt":"2026-08-06T23:28:54","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=813"},"modified":"2026-10-20T22:05:30","modified_gmt":"2026-10-20T22:05:30","slug":"monitor-vps-cpu-ram-disk-usage-real-time","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/","title":{"rendered":"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI"},"content":{"rendered":"<div style=\"padding:20px\">\n<p>A slow server does not hide its bottleneck: the Linux kernel accounts for every nanosecond of CPU time, every major page fault, every block-layer request and every dropped packet. The difficulty is turning that firehose into a decision in under a minute. This is a drill-down procedure \u2014 one-second system snapshot, then per-process attribution, then device-level and memory-level confirmation \u2014 using only tools that ship with a normal distribution or one <code>apt install sysstat<\/code>. All of it reads from <code>\/proc<\/code> and <code>\/sys<\/code>, so it works identically on any Linux instance, whether that is <a href=\"https:\/\/virtualserversvps.com\/\">a properly sized VPS with dedicated CPU shares<\/a> or a cramped container.<\/p>\n<h2>Step 1: Establish the Baseline Before Anything Is Wrong<\/h2>\n<p>Tuning and diagnosis both fail without a baseline. Capture one while the box is healthy, so a later reading has something to be compared against:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;mkdir -p \/var\/log\/baseline\nvmstat 1 60 &gt; \/var\/log\/baseline\/vmstat.txt\ncat \/proc\/pressure\/cpu \/proc\/pressure\/memory \/proc\/pressure\/io \\\n  &gt; \/var\/log\/baseline\/psi.txt\nsar -u -r -d 1 5 &gt; \/var\/log\/baseline\/sar.txt&lt;\/code&gt;<\/code><\/pre>\n<p>Two numbers matter most in that baseline: <code>r<\/code> (run queue) and the PSI <code>avg10<\/code> values. A healthy idle box shows <code>r<\/code> at or below the vCPU count and PSI <code>avg10<\/code> under 1.00 for all three resources.<\/p>\n<h2>Step 2: The One-Second Snapshot<\/h2>\n<p><code>vmstat 1<\/code> remains the densest single command on Linux. Read the columns in a fixed order rather than scanning them:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;vmstat 1 5\n# procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----\n#  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st&lt;\/code&gt;<\/code><\/pre>\n<table>\n<tr>\n<th>Column<\/th>\n<th>Threshold that means &#8220;act&#8221;<\/th>\n<th>What it implies<\/th>\n<\/tr>\n<tr>\n<td><code>r<\/code><\/td>\n<td>sustained &gt; vCPUs<\/td>\n<td>CPU oversubscription inside the guest<\/td>\n<\/tr>\n<tr>\n<td><code>si<\/code>\/<code>so<\/code><\/td>\n<td>any sustained non-zero<\/td>\n<td>Active swapping; memory problem, not disk<\/td>\n<\/tr>\n<tr>\n<td><code>bi<\/code>\/<code>bo<\/code><\/td>\n<td>bo &gt; 50 MB\/s with <code>wa<\/code> high<\/td>\n<td>Write path saturated; check dirty ratio and device<\/td>\n<\/tr>\n<tr>\n<td><code>in<\/code><\/td>\n<td>&gt; 50k\/s on a 4-vCPU box<\/td>\n<td>Interrupt storm \u2014 often network at high pps<\/td>\n<\/tr>\n<tr>\n<td><code>cs<\/code><\/td>\n<td>&gt; 100k\/s idle-ish<\/td>\n<td>Thread pool too large, or lock contention<\/td>\n<\/tr>\n<tr>\n<td><code>st<\/code><\/td>\n<td>&gt; 2% sustained<\/td>\n<td>Hypervisor steal \u2014 guest tuning cannot fix it<\/td>\n<\/tr>\n<\/table>\n<p>The <code>st<\/code> row deserves emphasis. Steal time means your vCPU was runnable but the hypervisor scheduled someone else. If the baseline was 0.2% and the current reading is 6%, the instance is being oversubscribed on the host, and every sysctl in the following sections is theatre. Confirm with <code>mpstat -P ALL 1<\/code> to see whether steal is spread across all vCPUs or concentrated on one \u2014 concentrated steal usually indicates a co-scheduled noisy neighbour or a pinned host thread.<\/p>\n<h2>Step 3: Attribute CPU to a Process<\/h2>\n<p><code>top<\/code> averages over its refresh interval and hides short spikes. <code>pidstat<\/code> reports true deltas between samples and separates the accounting:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;sudo apt install sysstat\npidstat -u -p ALL 1      # user\/system CPU per process\npidstat -r -p ALL 1      # page faults, RSS growth\npidstat -d -p ALL 1      # disk read\/write per process\npidstat -w -p ALL 1      # voluntary\/involuntary context switches&lt;\/code&gt;<\/code><\/pre>\n<p>Read <code>%usr<\/code> and <code>%system<\/code> separately. A process at 100% <code>%system<\/code> with a small <code>%usr<\/code> is spending its time in syscalls \u2014 typically small-buffer read\/write loops, excessive <code>futex<\/code> traffic, or a tracing agent. That is tunable or starvable; a process at 100% <code>%usr<\/code> needs a faster core or fewer threads.<\/p>\n<p><code>pidstat -w<\/code> is the underrated one. Involuntary context switches (<code>nvcswch\/s<\/code>) climbing on a process whose <code>%CPU<\/code> is below 100 means it is being preempted \u2014 either the run queue is full or its CPU affinity is competing with another hot thread. Voluntary switches (<code>cswch\/s<\/code>) in the tens of thousands per second usually mean lock contention, not I\/O, especially in JVM and Go workloads.<\/p>\n<h2>Step 4: Localise Disk Pressure Properly<\/h2>\n<p>High <code>wa<\/code> in vmstat points at storage; <code>iostat -x 1<\/code> tells you which layer. The trap is that <code>%util<\/code> is nearly meaningless on NVMe, where a device can service hundreds of parallel requests and still show high utilisation at trivial latency.<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;iostat -x 1\n# Device  r\/s   w\/s  rkB\/s  wkB\/s  r_await  w_await  aqu-sz  %util&lt;\/code&gt;<\/code><\/pre>\n<ul>\n<li><code>r_await<\/code>\/<code>w_await<\/code> are the numbers that matter. On local NVMe, sub-millisecond is normal; on network-backed block storage, 0.5\u20132 ms is expected and fine.<\/li>\n<li><code>aqu-sz<\/code> rising while latency stays flat means the queue is absorbing bursts \u2014 healthy. Rising <code>aqu-sz<\/code> with rising latency means the device is the wall.<\/li>\n<li>Compare guest <code>w\/s<\/code> against the provider&#8217;s throttle. Many plans cap IOPS; when the cap is hit, latency jumps in a step, not a slope. A step change at a suspiciously round number is the signature.<\/li>\n<\/ul>\n<p>Cross-check with PSI, which quantifies the time <em>someone was actually stalled<\/em> rather than how busy the device looked:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;cat \/proc\/pressure\/io\n# some avg10=12.43 avg60=8.11 avg300=3.02 total=9183421\n# full avg10=9.87 avg60=6.44 avg300=2.11 total=7211233&lt;\/code&gt;<\/code><\/pre>\n<p>The <code>full<\/code> line means every runnable task was stalled on I\/O. Sustained <code>full avg10<\/code> above 5 on a database host is a capacity problem, not a tuning problem.<\/p>\n<h2>Step 5: Memory \u2014 Beyond &#8220;Free RAM&#8221;<\/h2>\n<p><code>free -m<\/code> is the most misread command in the toolbox: low <code>free<\/code> with a large <code>buff\/cache<\/code> is correct kernel behaviour. What matters is reclaim pressure.<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;grep -E 'pgscan|pgsteal|allocstall|oom' \/proc\/vmstat\ncat \/proc\/pressure\/memory\ngrep -E 'AnonHugePages|Shmem|FilePmdMapped' \/proc\/meminfo\nslabtop -o -s c | head -15&lt;\/code&gt;<\/code><\/pre>\n<p>Rising <code>pgscan_direct<\/code> and <code>allocstall<\/code> mean allocations are blocking on reclaim \u2014 the working set no longer fits. A large <code>slabtop<\/code> dentry or inode cache after a file-heavy workload is normal; a runaway <code>kmalloc-*<\/code> slab is a kernel leak, usually from a filesystem or network driver, and shows up as steady growth that survives a workload restart.<\/p>\n<p>Then confirm with per-process RSS versus PSS, because RSS double-counts shared pages:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;sudo smem -t -k -c \"pname uss pss rss\" | sort -k3 -h | tail -10&lt;\/code&gt;<\/code><\/pre>\n<h2>Step 6: The 60-Second Decision<\/h2>\n<ol>\n<li><code>vmstat 1 1<\/code> \u2014 if <code>st<\/code> is high, stop; the host is the problem.<\/li>\n<li>If <code>si<\/code>\/<code>so<\/code> are non-zero, go to memory and fix the working set or add RAM.<\/li>\n<li>If <code>r<\/code> &gt; vCPUs with low <code>wa<\/code>, go to <code>pidstat -u<\/code> and find the hog or the thread explosion.<\/li>\n<li>If <code>wa<\/code> is high, go to <code>iostat -x<\/code>, compare latency against the baseline, and check PSI io <code>full<\/code>.<\/li>\n<li>If all three are clean but the application is slow, the bottleneck has moved outside the kernel: DNS, TLS handshakes, an upstream dependency, or the client&#8217;s network.<\/li>\n<\/ol>\n<p>Instrument the result. A five-line cron job that appends the five decisive numbers every minute gives you the history needed to correlate incidents:<\/p>\n<pre class=\"wp-block-code\"><code>&lt;code&gt;*\/1 * * * * \/usr\/bin\/vmstat 1 1 | tail -1 &gt;&gt; \/var\/log\/baseline\/minute.log&lt;\/code&gt;<\/code><\/pre>\n<p>Rotate it with <code>logrotate<\/code> at a 7-day retention \u2014 roughly 3 MB at that rate \u2014 and you have a forensic trail that answers &#8220;was it us or the host&#8221; without a monitoring stack. If the readings consistently show the instance is the smaller half of the equation, sizing is the fix rather than more tuning: see the <a href=\"https:\/\/virtualserversvps.com\/\">provider plan dimensions and CPU allocation model<\/a> before spending another evening chasing sysctl values. Measurement first, provisioning second, tuning third \u2014 in that order, the numbers always win.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A slow server does not hide its bottleneck: the Linux kernel accounts for every nanosecond of CPU time, every major page fault, every block-layer request and every dropped packet. The&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":13,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-813","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"A slow server does not hide its bottleneck: the Linux kernel accounts for every nanosecond of CPU time, every major page fault, every block-layer request\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI\" \/>\n<meta property=\"og:description\" content=\"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-06T23:28:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-20T22:05:30+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/\",\"name\":\"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-06T23:28:54+00:00\",\"dateModified\":\"2026-10-20T22:05:30+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"A slow server does not hide its bottleneck: the Linux kernel accounts for every nanosecond of CPU time, every major page fault, every block-layer request\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI - Virtual Servers VPS Blog","description":"A slow server does not hide its bottleneck: the Linux kernel accounts for every nanosecond of CPU time, every major page fault, every block-layer request","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/","og_locale":"en_US","og_type":"article","og_title":"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI","og_description":"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI","og_url":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-06T23:28:54+00:00","article_modified_time":"2026-10-20T22:05:30+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/","url":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/","name":"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-06T23:28:54+00:00","dateModified":"2026-10-20T22:05:30+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"A slow server does not hide its bottleneck: the Linux kernel accounts for every nanosecond of CPU time, every major page fault, every block-layer request","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/monitor-vps-cpu-ram-disk-usage-real-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Reading Linux Performance in Under 60 Seconds: vmstat, pidstat and PSI"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=813"}],"version-history":[{"count":5,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/813\/revisions"}],"predecessor-version":[{"id":1454,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/813\/revisions\/1454"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}