{"id":1140,"date":"2026-09-16T03:39:57","date_gmt":"2026-09-16T03:39:57","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1140"},"modified":"2026-10-05T22:02:31","modified_gmt":"2026-10-05T22:02:31","slug":"how-to-reduce-mysql-memory-usage-small-server","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/","title":{"rendered":"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A MySQL or MariaDB server that swaps, gets OOM-killed, or refuses new connections is almost always misconfigured for the memory it has &mdash; not short of memory. On a 1&nbsp;GB or 2&nbsp;GB VPS you cannot give the database &#8220;enough&#8221; RAM, so you have to give it the right RAM. This procedure walks through where MySQL&#8217;s memory actually goes, which settings to cut, and how to verify the result instead of hoping.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Establish a baseline before touching anything<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You cannot prove an improvement without a before-and-after. Record the process RSS and the kernel&#8217;s assessment of available memory under your normal workload:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps -o rss= -C mysqld | awk '{printf \"mysqld RSS: %.0f MB\\n\", $1\/1024}'\nfree -m\ncat \/proc\/meminfo | grep -E 'MemAvailable|SwapCached'\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>MemAvailable<\/code> is the honest number &mdash; not <code>free<\/code>. If it collapses toward zero while your server runs, you have a real problem to solve rather than a cosmetic one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Find the largest consumer: the InnoDB buffer pool<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On almost every small install this is the biggest line item, and it is frequently sized by copy-paste. Check whether it is actually being used:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -e \"SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool_pages%';\"\nmysql -e \"SELECT @@innodb_buffer_pool_size\/1024\/1024 AS pool_mb;\"\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Divide <code>pages_data<\/code> by <code>pages_total<\/code>. That ratio is your real fill level. If it is under half on a read-heavy workload, shrink the pool to match the working set &mdash; you reclaim RAM for free. A common safe starting point on 1&nbsp;GB is 256&nbsp;MB; on 2&nbsp;GB, 512&nbsp;MB. Grow only when the fill ratio stays high under load.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Reclaim per-connection buffers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These settings are harmless in isolation but multiply by connection count. Defaults like a 256&nbsp;KB <code>sort_buffer_size<\/code> and 128&nbsp;KB <code>join_buffer_size<\/code> are generous for small applications and can be cut without user-visible impact:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[mysqld]\nmax_connections        = 40\nsort_buffer_size       = 256K\njoin_buffer_size       = 128K\nread_buffer_size       = 128K\nread_rnd_buffer_size    = 128K\ntmp_table_size         = 16M\nmax_heap_table_size    = 16M\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Do not set <code>max_connections<\/code> to a fantasy number you will never reach. Use your app&#8217;s real pool size plus headroom. A server that allows 500 connections but only ever sees 20 pays planning overhead for connections that never exist.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Disable what you do not query<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The performance schema is a diagnostics engine, and it is expensive on tiny hosts. If you are not actively querying it, turn it off in the config and it stops consuming memory entirely:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[mysqld]\nperformance_schema = OFF\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same reasoning applies to the query cache on MariaDB, which is disabled by default in modern versions for good reason, and to unused storage engines you have compiled in but never instantiate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Make pressure visible instead of fatal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Even a perfect budget can be exceeded by a runaway query. Tune the kernel so rising memory pressure shows up as swap activity you can observe, and cap the database&#8217;s own footprint so it cannot consume the whole host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysctl vm.swappiness=10\nsysctl vm.overcommit_memory=0\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a hard ceiling, use a systemd slice or cgroup v2 <code>MemoryMax<\/code> on the MySQL unit. This is the difference between a database that degrades gracefully and one that takes your SSH session down with it. Hosting the database on a <a href=\"https:\/\/virtualserversvps.com\/\">properly-sized virtual server<\/a> with predictable memory accounting makes these guardrails far easier to reason about.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Verify the change<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Restart MySQL, replay the same workload you baselined, and re-measure the exact commands from step 1. Then confirm the buffers are actually at their new values, because a typo in the config block silently leaves the old default in place:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -e \"SELECT @@sort_buffer_size, @@join_buffer_size, @@innodb_buffer_pool_size;\"\nps -o rss= -C mysqld | awk '{printf \"new mysqld RSS: %.0f MB\\n\", $1\/1024}'\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The difference between the old RSS and the new one is your reclaimed memory. Keep the config in version control alongside the measurements, so the next administrator inherits a documented budget rather than a mystery. A box that stays inside its memory envelope is exactly the kind of workload <a href=\"https:\/\/virtualserversvps.com\/\">premium cloud solutions<\/a> are built to run reliably &mdash; but only after someone does the arithmetic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A verified procedure for reducing MySQL memory on a 1-2 GB VPS: baseline the RSS, right-size the buffer pool, trim per-connection buffers, and confirm the reclaimed memory.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1140","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>Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"A verified procedure for reducing MySQL memory on a 1-2 GB VPS: baseline the RSS, right-size the buffer pool, trim per-connection buffers, and confirm the reclaimed memory.\" \/>\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\/how-to-reduce-mysql-memory-usage-small-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure\" \/>\n<meta property=\"og:description\" content=\"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-16T03:39:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-05T22:02:31+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\/how-to-reduce-mysql-memory-usage-small-server\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/\",\"name\":\"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-09-16T03:39:57+00:00\",\"dateModified\":\"2026-10-05T22:02:31+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"A verified procedure for reducing MySQL memory on a 1-2 GB VPS: baseline the RSS, right-size the buffer pool, trim per-connection buffers, and confirm the reclaimed memory.\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure\"}]},{\"@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":"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure - Virtual Servers VPS Blog","description":"A verified procedure for reducing MySQL memory on a 1-2 GB VPS: baseline the RSS, right-size the buffer pool, trim per-connection buffers, and confirm the reclaimed memory.","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\/how-to-reduce-mysql-memory-usage-small-server\/","og_locale":"en_US","og_type":"article","og_title":"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure","og_description":"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure","og_url":"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-09-16T03:39:57+00:00","article_modified_time":"2026-10-05T22:02:31+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\/how-to-reduce-mysql-memory-usage-small-server\/","url":"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/","name":"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-09-16T03:39:57+00:00","dateModified":"2026-10-05T22:02:31+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"A verified procedure for reducing MySQL memory on a 1-2 GB VPS: baseline the RSS, right-size the buffer pool, trim per-connection buffers, and confirm the reclaimed memory.","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/how-to-reduce-mysql-memory-usage-small-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Cutting MySQL Memory on a Small VPS: A Verified, Repeatable Procedure"}]},{"@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\/1140","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=1140"}],"version-history":[{"count":2,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1140\/revisions"}],"predecessor-version":[{"id":1305,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1140\/revisions\/1305"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}