{"id":965,"date":"2026-08-24T22:37:51","date_gmt":"2026-08-24T22:37:51","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=965"},"modified":"2026-09-26T22:03:29","modified_gmt":"2026-09-26T22:03:29","slug":"mysql-mariadb-performance-tuning-low-ram-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/","title":{"rendered":"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">MySQL and MariaDB are the most common cause of an OOM kill on a 1\u20132 GB VPS, and the usual fix \u2014 &#8220;lower innodb_buffer_pool_size&#8221; \u2014 often makes things worse because it ignores where the rest of the memory went. This article works through the actual budget on constrained servers: what each buffer costs, which ones scale with connections, and how to size them so the database stays in RAM and the kernel does not reach for the OOM killer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Read the real memory map first<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start from what the running server reports, not from a config template. Connect and run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT\n  VARIABLE_NAME, VARIABLE_VALUE\nFROM performance_schema.global_status\nWHERE VARIABLE_NAME IN (\n  'Innodb_buffer_pool_pages_total',\n  'Innodb_buffer_pool_pages_free',\n  'Threads_connected'\n);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then check the OS view with <code>ps_mem<\/code> or <code>smem -tk<\/code>, which accounts for shared pages properly. RSS from <code>ps<\/code> overstates MySQL&#8217;s footprint because the buffer pool is shared memory; <code>PSS<\/code> from <code>smem<\/code> is the number to compare against your RAM budget.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The four buffers that actually matter<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>innodb_buffer_pool_size<\/strong> \u2014 the big one. Targets 60\u201370% of RAM on a dedicated database host; on a web VPS that also runs PHP, keep it lower (see below).<\/li>\n<li><strong>Per-connection buffers<\/strong> \u2014 <code>sort_buffer_size<\/code>, <code>join_buffer_size<\/code>, <code>read_buffer_size<\/code>, <code>read_rnd_buffer_size<\/code>. These are allocated <em>per connection<\/em> when needed, so the worst case is workers \u00d7 size.<\/li>\n<li><strong>tmp_table_size \/ max_heap_table_size<\/strong> \u2014 in-memory temp tables, also per connection.<\/li>\n<li><strong>InnoDB log and dictionary<\/strong> \u2014 <code>innodb_log_buffer_size<\/code> plus a few hundred MB of fixed overhead you cannot configure away.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The trap is the per-connection group. Setting <code>sort_buffer_size = 16M<\/code> with 50 max connections means a theoretical 800 MB of sort memory on a server that only has 1 GB. Most connections never allocate it, but a bad query plan on a busy day will.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A measured budget for a 2 GB VPS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Assume the VPS runs the web stack too. Reserve roughly: 350 MB for the OS and page cache floor, 300 MB for PHP-FPM and nginx, then give the rest to MySQL. That lands here:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[mysqld]\ninnodb_buffer_pool_size      = 512M\ninnodb_buffer_pool_instances = 2\ninnodb_log_file_size         = 128M\ninnodb_flush_method          = O_DIRECT\n\n# per-connection, deliberately small\nsort_buffer_size             = 1M\njoin_buffer_size             = 1M\nread_buffer_size             = 512K\nread_rnd_buffer_size         = 512K\ntmp_table_size               = 16M\nmax_heap_table_size          = 16M\n\nmax_connections              = 40\ntable_open_cache             = 400\ninnodb_open_files            = 400\n\nperformance_schema           = OFF\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Two deliberate choices stand out. First, <code>innodb_buffer_pool_instances = 2<\/code> with a 512M pool reduces mutex contention on multi-core instances without splitting the pool so finely that it wastes memory. Second, disabling <code>performance_schema<\/code> frees 100\u2013200 MB on MariaDB builds where it is enabled by default \u2014 re-enable it temporarily when you need to diagnose, then turn it off again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Watch it rather than guess it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After applying changes, restart (buffer pool size is not fully online-settable in older versions) and watch the working set over a few days:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SHOW STATUS LIKE 'Innodb_buffer_pool_read%';\n-- read_requests vs reads: the miss ratio is reads \/ read_requests<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the miss ratio stays under ~1% after a day of normal traffic, the pool is large enough and you should not grow it. If it sits at 5%+, you are either under-provisioned or running queries that scan more than they need \u2014 check <code>EXPLAIN<\/code> before adding RAM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Match the budget to the server, not the template<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On a 1 GB VPS, drop the pool to 256M and cut <code>max_connections<\/code> to 25. On a 4 GB server that only runs the database, push the pool to 2\u20133 GB and raise per-connection buffers only when you see sort or join spills in <code>SHOW STATUS LIKE 'Created_tmp_disk_tables'<\/code>. Sizing is a subtraction problem: total RAM minus everything that is not MySQL, and the remainder is your pool. Run the same arithmetic against any <a href=\"https:\/\/virtualserversvps.com\/\">managed or self-managed hosting<\/a> plan you deploy and the OOM kills stop being mysterious.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL and MariaDB are the most common cause of an OOM kill on a 1\u20132 GB VPS, and the usual fix \u2014 &#8220;lower innodb_buffer_pool_size&#8221; \u2014 often makes things worse because&#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":6,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-965","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>MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"MySQL and MariaDB are the most common cause of an OOM kill on a 1\u20132 GB VPS, and the usual fix \u2014 &quot;lower innodb_buffer_pool_size&quot; \u2014 often makes things worse\" \/>\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\/mysql-mariadb-performance-tuning-low-ram-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork\" \/>\n<meta property=\"og:description\" content=\"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-24T22:37:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-26T22:03: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\/mysql-mariadb-performance-tuning-low-ram-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/\",\"name\":\"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-24T22:37:51+00:00\",\"dateModified\":\"2026-09-26T22:03:29+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"MySQL and MariaDB are the most common cause of an OOM kill on a 1\u20132 GB VPS, and the usual fix \u2014 \\\"lower innodb_buffer_pool_size\\\" \u2014 often makes things worse\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork\"}]},{\"@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":"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork - Virtual Servers VPS Blog","description":"MySQL and MariaDB are the most common cause of an OOM kill on a 1\u20132 GB VPS, and the usual fix \u2014 \"lower innodb_buffer_pool_size\" \u2014 often makes things worse","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\/mysql-mariadb-performance-tuning-low-ram-vps\/","og_locale":"en_US","og_type":"article","og_title":"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork","og_description":"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork","og_url":"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-24T22:37:51+00:00","article_modified_time":"2026-09-26T22:03: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\/mysql-mariadb-performance-tuning-low-ram-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/","name":"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-24T22:37:51+00:00","dateModified":"2026-09-26T22:03:29+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"MySQL and MariaDB are the most common cause of an OOM kill on a 1\u20132 GB VPS, and the usual fix \u2014 \"lower innodb_buffer_pool_size\" \u2014 often makes things worse","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/mysql-mariadb-performance-tuning-low-ram-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"MySQL on a Constrained VPS: Budgeting Buffers by Subtraction, Not Guesswork"}]},{"@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\/965","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=965"}],"version-history":[{"count":2,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/965\/revisions"}],"predecessor-version":[{"id":1229,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/965\/revisions\/1229"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}