{"id":1059,"date":"2026-09-04T22:46:59","date_gmt":"2026-09-04T22:46:59","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1059"},"modified":"2026-09-04T22:46:59","modified_gmt":"2026-09-04T22:46:59","slug":"vps-mysql-mariadb-optimization-low-memory","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/","title":{"rendered":"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Running MySQL or MariaDB on a 1-2 GB VPS requires careful configuration. Out of the box, these databases allocate memory assuming a dedicated server with several gigabytes of RAM. On a budget VPS, that default configuration triggers swap usage, OOM kills, and cascading performance degradation. Here is how to tune MySQL and MariaDB for low-memory environments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Start with a Memory Budget<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before touching MySQL configuration, calculate your available memory. On a 2 GB VPS running Nginx, PHP-FPM, and MySQL, roughly 500-800 MB should be allocated to the database. Subtract the OS overhead (200 MB), Nginx (50 MB), and PHP-FPM (200 MB), and you are left with about 800 MB for MySQL. On a 1 GB VPS, budget 300-400 MB at most.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">InnoDB Buffer Pool: The Most Important Setting<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The InnoDB buffer pool caches data and indexes in memory. Set it to 60-70% of your MySQL memory budget. For a 2 GB VPS with 800 MB allocated to MySQL: <code>innodb_buffer_pool_size = 512M<\/code>. For a 1 GB VPS with 400 MB allocated: <code>innodb_buffer_pool_size = 256M<\/code>. Add this to your <code>\/etc\/mysql\/mariadb.conf.d\/50-server.cnf<\/code> or <code>\/etc\/mysql\/my.cnf<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reduce Per-Connection Memory Usage<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">MySQL allocates memory per connection. The defaults are generous and will exhaust your VPS under even moderate concurrency. Adjust these values:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sort_buffer_size = 256K\nread_buffer_size = 128K\nread_rnd_buffer_size = 256K\njoin_buffer_size = 256K\nmax_connections = 30<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These settings reduce per-connection overhead from several megabytes to under 1 MB. With 30 connections, total connection memory stays under 30 MB. If your application needs more connections, use a connection pooler like ProxySQL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Query Cache and Temporary Tables<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For MariaDB, enable the query cache with a small allocation: <code>query_cache_size = 32M<\/code> and <code>query_cache_type = 1<\/code>. For MySQL 8.0+, the query cache is removed \u2014 use application-level caching instead. Keep temporary tables in memory: <code>tmp_table_size = 32M<\/code> and <code>max_heap_table_size = 32M<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Swap Prevention and Monitoring<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On a low-memory VPS, MySQL memory spikes can trigger swap. Monitor with <code>free -h<\/code> and <code>sar -r 1<\/code>. If MySQL hits swap, performance collapses. Add <code>vm.swappiness=10<\/code> to <code>\/etc\/sysctl.conf<\/code> to discourage the kernel from swapping unless absolutely necessary.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check your InnoDB buffer pool hit rate with <code>SHOW ENGINE INNODB STATUS\\G<\/code> and look for the buffer pool hit rate \u2014 aim for 99% or higher. For benchmarks comparing VPS plans with different RAM configurations, visit our <a href=\"https:\/\/www.virtualserversvps.com\">hosting comparison page<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Configuration Template<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>[mysqld]\ninnodb_buffer_pool_size = 512M\ninnodb_log_file_size = 128M\ninnodb_flush_log_at_trx_commit = 2\nsort_buffer_size = 256K\nread_buffer_size = 128K\njoin_buffer_size = 256K\nmax_connections = 30\ntmp_table_size = 32M\nmax_heap_table_size = 32M\ntable_open_cache = 256\nquery_cache_size = 32M\nquery_cache_type = 1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Apply these changes, restart MySQL, and benchmark with <code>mysqlslap<\/code> to verify the impact. A well-tuned low-memory instance can handle thousands of queries per second for typical web workloads.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running MySQL or MariaDB on a 1-2 GB VPS requires careful configuration. Out of the box, these databases allocate memory assuming a dedicated server with several gigabytes of RAM. On&#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":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1059","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>MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM - Virtual Servers VPS Blog<\/title>\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\/vps-mysql-mariadb-optimization-low-memory\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM\" \/>\n<meta property=\"og:description\" content=\"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-04T22:46:59+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\/vps-mysql-mariadb-optimization-low-memory\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/\",\"name\":\"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-09-04T22:46:59+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM\"}]},{\"@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 and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM - Virtual Servers VPS Blog","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\/vps-mysql-mariadb-optimization-low-memory\/","og_locale":"en_US","og_type":"article","og_title":"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM","og_description":"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM","og_url":"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-09-04T22:46:59+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\/vps-mysql-mariadb-optimization-low-memory\/","url":"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/","name":"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-09-04T22:46:59+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/vps-mysql-mariadb-optimization-low-memory\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"MySQL and MariaDB Tuning for Low-Memory VPS: Configuration That Fits 1-2 GB RAM"}]},{"@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\/1059","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=1059"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1059\/revisions"}],"predecessor-version":[{"id":1060,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1059\/revisions\/1060"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}