{"id":955,"date":"2026-08-23T22:39:05","date_gmt":"2026-08-23T22:39:05","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=955"},"modified":"2026-09-02T22:08:13","modified_gmt":"2026-09-02T22:08:13","slug":"linux-kernel-parameters-vps-network-performance","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/","title":{"rendered":"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">While network sysctl tuning gets most of the attention in VPS performance guides, the <code>vm.*<\/code> kernel parameters have an equally large impact on day-to-day stability. These settings control how the kernel manages memory: when it swaps, how aggressively it writes dirty pages to disk, and what happens when memory runs out. On a VPS with limited RAM \u2014 typically 1 GB to 4 GB \u2014 getting these values wrong can cause slowdowns, excessive I\/O, or unexpected OOM kills. This guide covers the vm.* parameters that matter most and how to tune them for a virtualized environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding vm.swappiness<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Swappiness controls the kernel&#8217;s preference for keeping processes in RAM versus swapping them to disk. The value ranges from 0 to 200:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>0:<\/strong> Only swap when absolutely necessary (OOM pressure)<\/li>\n<li><strong>1:<\/strong> Minimum swapping \u2014 good for most VPS workloads<\/li>\n<li><strong>10:<\/strong> Recommended for low-RAM VPS (1-2 GB)<\/li>\n<li><strong>60:<\/strong> Default on most Linux distributions<\/li>\n<li><strong>100:<\/strong> Aggressive swapping \u2014 useful for desktop systems<\/li>\n<li><strong>200:<\/strong> Maximum swapping \u2014 avoid on a VPS<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The default of 60 is designed for general-purpose desktops where the kernel should page out less-frequently-used memory to leave room for file caches. On a VPS, this default causes excessive swapping, which translates to high disk I\/O and latency. A lower value keeps your application processes in memory where they belong.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check current swappiness\ncat \/proc\/sys\/vm\/swappiness\n\n# Set to 10 for a low-RAM VPS\nsudo sysctl -w vm.swappiness=10\n\n# Make permanent\nsudo sh -c 'echo \"vm.swappiness=10\" >> \/etc\/sysctl.conf'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a deeper dive into VPS performance tuning, <a href=\"https:\/\/virtualserversvps.com\/blog\/category\/performance-optimization\/\">browse our performance optimization guides<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tuning vm.dirty_ratio and vm.dirty_background_ratio<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These two parameters control when the kernel writes dirty pages (modified data in memory that has not yet been written to disk) back to storage.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Default<\/th><th>VPS Recommendation<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td><code>dirty_background_ratio<\/code><\/td><td>10%<\/td><td>5%<\/td><td>Start writing dirty pages to disk in the background<\/td><\/tr><tr><td><code>dirty_ratio<\/code><\/td><td>20%<\/td><td>10%<\/td><td>Block processes until dirty pages are flushed<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On a VPS, the default values allow too many dirty pages to accumulate before flushing begins. When a large write happens (e.g., a database checkpoint or a file upload), the kernel blocks all processes until the dirty pages are written to disk. This causes visible latency spikes. Lowering both values smooths out I\/O by flushing smaller batches more frequently.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Set conservative dirty page limits\nsudo sysctl -w vm.dirty_background_ratio=5\nsudo sysctl -w vm.dirty_ratio=10\n\n# Make permanent\nsudo sh -c 'cat >> \/etc\/sysctl.conf <<EOF\nvm.dirty_background_ratio=5\nvm.dirty_ratio=10\nEOF'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">vm.vfs_cache_pressure: Keeping Inode\/Dentry Caches Under Control<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The VFS (Virtual File System) cache stores recently accessed directory entries (dentries) and inodes. On a busy VPS with many files (e.g., a WordPress site with thousands of cached pages), this cache can grow large. The <code>vfs_cache_pressure<\/code> parameter controls how aggressively the kernel reclaims these caches.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Default (100):<\/strong> Balanced reclamation<\/li>\n<li><strong>Lower (50):<\/strong> Keep cache entries longer \u2014 more memory used, better performance for repeated file access<\/li>\n<li><strong>Higher (200):<\/strong> Reclaim cache aggressively \u2014 frees memory at the cost of more disk I\/O<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For a web server VPS, setting vfs_cache_pressure to 50 can improve performance by keeping frequently accessed file metadata in memory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl -w vm.vfs_cache_pressure=50\nsudo sh -c 'echo \"vm.vfs_cache_pressure=50\" >> \/etc\/sysctl.conf'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">OOM Behavior: vm.overcommit_memory and vm.overcommit_ratio<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Linux overcommits memory by default: it allows processes to allocate more virtual memory than physical RAM + swap. When a process actually tries to use the memory, the kernel must find pages to free. If it cannot, the OOM (Out-Of-Memory) killer terminates a process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On a VPS, the default overcommit behavior can lead to unpredictable OOM kills at the worst possible moment. The safest setting is <code>vm.overcommit_memory=2<\/code>, which disables overcommit and allocates memory strictly based on available RAM + swap:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Disable overcommit (strict accounting)\nsudo sysctl -w vm.overcommit_memory=2\nsudo sysctl -w vm.overcommit_ratio=50  # Allow 50% overhead for allocations\n\n# Make permanent\nsudo sh -c 'echo \"vm.overcommit_memory=2\" >> \/etc\/sysctl.conf'\nsudo sh -c 'echo \"vm.overcommit_ratio=50\" >> \/etc\/sysctl.conf'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With <code>overcommit_memory=2<\/code>, the kernel will reject memory allocations that exceed available capacity. Applications that try to allocate more memory than exists will fail immediately with an error instead of causing a random OOM kill later. This is much easier to debug.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">vm.min_free_kbytes: Reserving Memory for Critical Allocations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This parameter reserves a minimum amount of free memory for critical kernel allocations. If the system runs out of memory entirely, the kernel cannot even run the OOM killer. Setting a reasonable reserve prevents this deadlock scenario.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Reserve 64 MB on a 2 GB VPS (roughly 3%)\nsudo sysctl -w vm.min_free_kbytes=65536\nsudo sh -c 'echo \"vm.min_free_kbytes=65536\" >> \/etc\/sysctl.conf'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A good rule of thumb is 3-5% of total RAM. On a 1 GB VPS, set <code>min_free_kbytes<\/code> to 32768 (32 MB). On a 4 GB VPS, set it to 131072 (128 MB).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Complete vm.* sysctl Configuration for a VPS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a complete set of vm.* parameters tuned for a low-to-mid-range VPS (1-4 GB RAM, SSD storage):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/sysctl.d\/99-vps-vm.conf\n# Memory management tuning for VPS\n\n# Reduce swap tendency\nvm.swappiness=10\n\n# Flush dirty pages more frequently\nvm.dirty_background_ratio=5\nvm.dirty_ratio=10\n\n# Keep directory cache in memory longer\nvm.vfs_cache_pressure=50\n\n# Strict overcommit policy\nvm.overcommit_memory=2\nvm.overcommit_ratio=50\n\n# Reserve memory for critical kernel allocations\nvm.min_free_kbytes=65536\n\n# Reduce page-cluster size (pages read ahead on swap)\nvm.page-cluster=0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Apply with <code>sudo sysctl -p \/etc\/sysctl.d\/99-vps-vm.conf<\/code>. Monitor memory usage with <code>free -h<\/code> and <code>vmstat 1<\/code> after applying to verify the system behaves as expected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Monitoring and Validation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After tuning, validate that your changes are having the desired effect:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check current values\nsysctl vm.swappiness vm.dirty_ratio vm.dirty_background_ratio\n\n# Monitor swap usage\nfree -h\nswapon --show\n\n# Check OOM status\ndmesg | grep -i \"oom\"\n\n# Monitor page faults and swap activity\nvmstat 1 10<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you see swap usage increasing after tuning, your swappiness value may still be too high, or your VPS simply needs more RAM. For persistent memory pressure, <a href=\"https:\/\/virtualserversvps.com\">compare VPS plans on our homepage<\/a> to find a configuration with adequate memory for your workload.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The vm.* kernel parameters directly control how your VPS handles memory pressure, disk I\/O, and process stability. By tuning swappiness, dirty page ratios, overcommit behavior, and cache pressure, you can reduce latency, prevent OOM kills, and make more efficient use of limited RAM. Apply these settings on every new VPS as part of your initial hardening process.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While network sysctl tuning gets most of the attention in VPS performance guides, the vm.* kernel parameters have an equally large impact on day-to-day stability. These settings control how 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":14,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-955","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 vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"While network sysctl tuning gets most of the attention in VPS performance guides, the vm.* kernel parameters have an equally large impact on day-to-day\" \/>\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-kernel-parameters-vps-network-performance\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS\" \/>\n<meta property=\"og:description\" content=\"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-23T22:39:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-02T22:08:13+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/\",\"name\":\"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-23T22:39:05+00:00\",\"dateModified\":\"2026-09-02T22:08:13+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"While network sysctl tuning gets most of the attention in VPS performance guides, the vm.* kernel parameters have an equally large impact on day-to-day\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS\"}]},{\"@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 vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS - Virtual Servers VPS Blog","description":"While network sysctl tuning gets most of the attention in VPS performance guides, the vm.* kernel parameters have an equally large impact on day-to-day","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-kernel-parameters-vps-network-performance\/","og_locale":"en_US","og_type":"article","og_title":"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS","og_description":"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS","og_url":"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-23T22:39:05+00:00","article_modified_time":"2026-09-02T22:08:13+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/","url":"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/","name":"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-23T22:39:05+00:00","dateModified":"2026-09-02T22:08:13+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"While network sysctl tuning gets most of the attention in VPS performance guides, the vm.* kernel parameters have an equally large impact on day-to-day","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/linux-kernel-parameters-vps-network-performance\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Tuning vm.* Kernel Parameters: Swappiness, Dirty Ratio, and OOM Behavior on a VPS"}]},{"@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\/955","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=955"}],"version-history":[{"count":3,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/955\/revisions"}],"predecessor-version":[{"id":1040,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/955\/revisions\/1040"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}