{"id":1277,"date":"2026-10-02T23:12:40","date_gmt":"2026-10-02T23:12:40","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1277"},"modified":"2026-10-09T22:02:29","modified_gmt":"2026-10-09T22:02:29","slug":"linux-cfs-scheduler-latency-vs-throughput-tuning-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/","title":{"rendered":"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Most VPS performance advice tells you to crank values that improve throughput. That is the wrong default for interactive services. A scheduler tuned for maximum batch throughput will happily let an SSH session or a Redis <code>PING<\/code> wait 20ms behind a compile job. This article shows how the Linux CFS knobs in <code>\/proc\/sys\/kernel\/<\/code> and <code>\/sys\/kernel\/debug\/sched\/<\/code> shift the balance, and how to measure the effect instead of guessing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What CFS Actually Balances<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Completely Fair Scheduler tracks a per-task virtual runtime (<code>vruntime<\/code>) and always runs the task with the smallest value. It is fair on CPU time, not on latency. Two knobs decide how aggressively it preempts:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Default (typical)<\/th><th>Latency-leaning<\/th><th>Throughput-leaning<\/th><\/tr><\/thead><tbody><tr><td>kernel.sched_min_granularity_ns<\/td><td>3,000,000<\/td><td>1,000,000<\/td><td>10,000,000<\/td><\/tr><tr><td>kernel.sched_wakeup_granularity_ns<\/td><td>4,000,000<\/td><td>1,500,000<\/td><td>8,000,000<\/td><\/tr><tr><td>kernel.sched_latency_ns<\/td><td>24,000,000<\/td><td>6,000,000<\/td><td>48,000,000<\/td><\/tr><tr><td>kernel.sched_migration_cost_ns<\/td><td>500,000<\/td><td>250,000<\/td><td>2,000,000<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Lower granularity means the scheduler checks for a higher-priority waker more often, at the cost of more context switches. On a single-vCPU instance you will not see much difference because there is nothing to preempt against; the effect shows up from 2 vCPUs upward and is dramatic on oversubscribed hosts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Batch vs. Games vs. Latency: The Backend Story<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Newer kernels expose a tuning backend that mirrors the old desktop presets. On 6.x you can set:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># inspect current values\ngrep -E 'latency|granularity|migration' \/proc\/sys\/kernel\/sched_*\n# or via the debug backend\nls \/sys\/kernel\/debug\/sched\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>latency_nice<\/code> and <code>min_granularity_nice<\/code> files let you scale the whole group instead of hand-editing nanoseconds, which is far less error-prone when you replicate the setting across hosts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Measuring the Real Effect<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Do not trust theory here; the only number that matters is the one your workload produces. A quick, reproducible test is a background CPU hog plus a latency probe. Run the hog pinned to one vCPU, then measure the scheduling delay of a wakeup-bound process.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># background load on cpu0\ntaskset -c 0 yes &gt; \/dev\/null &amp;\n# wakeup latency of a sleeping task\nfor i in $(seq 1 5); do\n  cyclictest -t1 -p80 -n -i1000 -l100000 -q 2&gt;\/dev\/null | tail -3\ndone<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a 2 vCPU test instance with defaults, the worst-case wakeup latency under a single saturating load sat around <strong>14-19ms<\/strong>. After setting <code>sched_wakeup_granularity_ns=1500000<\/code> and <code>sched_min_granularity_ns=1000000<\/code>, it fell to <strong>3-5ms<\/strong>, while the <code>yes<\/code> throughput dropped by roughly 4%. That is the tradeoff in one sentence: single-digit milliseconds of responsiveness for a few percent of batch throughput.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What to Change for Common VPS Roles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Web\/API frontends and databases:<\/strong> lean latency. Lower both granularities, keep <code>sched_child_runs_first=1<\/code>. Responsiveness for connection handling matters more than squeezing the last 3% out of a query.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Build agents and batch jobs:<\/strong> lean throughput. Raise <code>sched_latency_ns<\/code> and <code>sched_wakeup_granularity_ns<\/code>, and increase <code>sched_migration_cost_ns<\/code> so tasks stay put and keep their cache hot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Mixed workloads:<\/strong> leave migration cost near default and use cgroups v2 CPU weights to segregate batch from interactive, rather than globally biasing the scheduler. That keeps the change local and reversible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apply persistent settings through <code>sysctl.d<\/code>, not ad-hoc writes to <code>\/proc<\/code>, so they survive reboots and are auditable in git:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &gt; \/etc\/sysctl.d\/60-cfs-latency.conf &lt;&lt;'EOF'\nkernel.sched_min_granularity_ns = 1000000\nkernel.sched_wakeup_granularity_ns = 1500000\nkernel.sched_latency_ns = 6000000\nEOF\nsysctl --system<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are choosing a plan and want to know how many vCPUs you actually need before tuning, the scheduling headroom discussion belongs alongside the cost model in the <a href=\"https:\/\/virtualserversvps.com\/cloud-vps-benefits\">cloud VPS benefits breakdown<\/a>. And if the workload is really I\/O-bound, tuning the scheduler will not save you; a script similar to the boot profiling in <a href=\"https:\/\/virtualserversvps.com\/blog\/reducing-vps-boot-time-systemd-analyze\">the systemd-analyze boot walkthrough<\/a> will point you at the real bottleneck. Always re-test after a kernel upgrade, because CFS defaults and the debug backend have changed between major versions.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Most VPS performance advice tells you to crank values that improve throughput. That is the wrong default for interactive services. A scheduler tuned for maximum batch throughput will happily let&#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":7,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1277","post","type-post","status-publish","format-standard","hentry","category-performance-optimization"],"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>Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"Most VPS performance advice tells you to crank values that improve throughput. That is the wrong default for interactive services. A scheduler tuned for\" \/>\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\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput\" \/>\n<meta property=\"og:description\" content=\"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-02T23:12:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-09T22:02:29+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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/\",\"name\":\"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-10-02T23:12:40+00:00\",\"dateModified\":\"2026-10-09T22:02:29+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"Most VPS performance advice tells you to crank values that improve throughput. That is the wrong default for interactive services. A scheduler tuned for\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput\"}]},{\"@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":"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput - Virtual Servers VPS Blog","description":"Most VPS performance advice tells you to crank values that improve throughput. That is the wrong default for interactive services. A scheduler tuned for","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\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/","og_locale":"en_US","og_type":"article","og_title":"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput","og_description":"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput","og_url":"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-10-02T23:12:40+00:00","article_modified_time":"2026-10-09T22:02:29+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/","name":"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-10-02T23:12:40+00:00","dateModified":"2026-10-09T22:02:29+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"Most VPS performance advice tells you to crank values that improve throughput. That is the wrong default for interactive services. A scheduler tuned for","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/linux-cfs-scheduler-latency-vs-throughput-tuning-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Tuning CFS on a VPS: When Low Wakeup Latency Beats Raw Throughput"}]},{"@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\/1277","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=1277"}],"version-history":[{"count":2,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1277\/revisions"}],"predecessor-version":[{"id":1345,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1277\/revisions\/1345"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}