{"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-10-16T22:03:10","modified_gmt":"2026-10-16T22:03:10","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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Running MySQL or MariaDB on a 1-2 GB VPS is entirely practical, but the default configuration is written for a machine with far more RAM than you have. Left alone, the server will happily size the InnoDB buffer pool at 128 MB, allocate per-connection buffers that multiply into hundreds of megabytes, and get your database killed by the OOM killer under a modest connection spike. This walkthrough builds a configuration that fits a small VPS, measures it, and explains every number.<\/p>\n\n\n<p class=\"wp-block-paragraph\">This is the companion to the broader database tuning material in our <a href=\"https:\/\/virtualserversvps.com\/\">VPS performance tuning guides<\/a>. The principles are the same: know your budget, size the big allocations first, and verify with real metrics rather than guesses.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Calculate the Memory Budget Before Touching Config<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Start with the total RAM and subtract everything that is not the database server. On a 1 GB box running a web stack, the OS, the web server and PHP-FPM may consume 400-600 MB. That leaves 400-600 MB for MySQL. This is the number you must not exceed, and the buffer pool is where most of it should go.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>free -m\nps_mem 2>\/dev\/null || for p in $(pgrep -f 'httpd|php-fpm|nginx|mysqld|mariadbd'); do echo -n \"$p \"; awk '\/VmRSS\/{print $2\/1024\" MB\"}' \/proc\/$p\/status; done<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Write the budget down. If your database has 300 MB of hot data and you can spare 400 MB, an InnoDB buffer pool of 256-320 MB is right. Oversizing the pool to 700 MB on a 1 GB VPS just moves the OOM kill from the database to a random victim later.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Size InnoDB Buffer Pool and Log Files<\/h2>\n\n\n<p class=\"wp-block-paragraph\">The buffer pool is the single most important setting. It caches data and index pages. MyISAM also has a key buffer, but you should be on InnoDB for anything transactional, so keep the MyISAM key buffer small and let InnoDB take the memory.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>[mysqld]\ninnodb_buffer_pool_size = 320M\ninnodb_buffer_pool_instances = 1\ninnodb_log_file_size = 128M\ninnodb_log_files_in_group = 2\ninnodb_flush_log_at_trx_commit = 2\ninnodb_flush_method = O_DIRECT<\/code><\/pre>\n\n\n<ul class=\"wp-block-list\"><li><code>innodb_buffer_pool_size<\/code>: 40-50% of the memory you budgeted for MySQL<\/li>\n<li><code>innodb_buffer_pool_instances<\/code>: keep at 1 on small VPS to avoid overhead<\/li>\n<li><code>innodb_log_file_size<\/code>: larger reduces checkpoint churn; 128M is a good small-box value<\/li>\n<li><code>innodb_flush_log_at_trx_commit = 2<\/code>: trades a one-second durability window for far fewer fsyncs<\/li>\n<li><code>innodb_flush_method = O_DIRECT<\/code>: avoids double buffering through the page cache<\/li><\/ul>\n\n\n<p class=\"wp-block-paragraph\">That last setting matters more than people expect on a small VPS with limited RAM. Without <code>O_DIRECT<\/code>, InnoDB pages can live in both the buffer pool and the OS page cache, silently halving your effective cache and pushing you toward swap.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Cap Per-Connection Buffers \u2014 They Multiply<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Memory that looks harmless per connection explodes across hundreds of them. Every active session allocates sort buffers, join buffers and read buffers. The <code>max_connections<\/code> limit times those per-thread buffers is your worst-case RAM, and it is almost always larger than the buffer pool.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>sort_buffer_size = 256K\njoin_buffer_size = 256K\nread_buffer_size = 128K\nread_rnd_buffer_size = 128K\ntmp_table_size = 16M\nmax_heap_table_size = 16M\nmax_connections = 50<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">On a 1 GB VPS, 50 connections times roughly 2 MB of worst-case per-thread buffers is about 100 MB, which fits alongside the pool. Do not set <code>max_connections<\/code> to 500 because you read a tutorial for an 8 GB server. Use a connection pooler in front, or set <code>thread_cache_size<\/code> to a modest value and let connections queue.<\/p>\n\n\n<p class=\"wp-block-paragraph\">Watch the actual usage rather than trusting the theoretical worst case: <code>SHOW STATUS LIKE 'Threads_connected'<\/code> and <code>SHOW STATUS LIKE 'Threads_running'<\/code>. If you never exceed twenty concurrent connections, the theoretical 50-connection ceiling gives you generous headroom.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Reduce Temporary Table and Sort Pressure<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Small <code>tmp_table_size<\/code> is a common cause of mysterious disk usage: when an in-memory temporary table grows beyond the limit, MySQL spills it to disk, which then needs a file sort. On a VPS with fast NVMe this is survivable, but it still multiplies I\/O. Raise the in-memory limits modestly and fix the queries that create giant temp tables in the first place.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>SHOW GLOBAL STATUS LIKE 'Created_tmp%';\nSHOW GLOBAL STATUS LIKE 'Created_tmp_disk_tables';\nSHOW FULL PROCESSLIST;<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If <code>Created_tmp_disk_tables<\/code> is a large fraction of <code>Created_tmp_tables<\/code>, your queries are sorting large result sets. Index the ORDER BY and GROUP BY columns, and check with <code>EXPLAIN<\/code> before adding more memory. On a small VPS, query fixes are almost always cheaper than RAM.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Turn On the Slow Query Log and Measure<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Tuning without measurement is superstition. Enable the slow query log with a low threshold, let it run for a day, and read the top offenders. This is the same evidence-based approach we recommend throughout our <a href=\"https:\/\/virtualserversvps.com\/\">VPS tuning guides<\/a>.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>slow_query_log = 1\nslow_query_log_file = \/var\/log\/mysql\/slow.log\nlong_query_time = 0.5\nlog_queries_not_using_indexes = 0\n\nmysqldumpslow -s t -t 10 \/var\/log\/mysql\/slow.log<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Leave <code>log_queries_not_using_indexes<\/code> off in production \u2014 it floods the log on busy apps. Once you have the top ten slow queries, index or rewrite them, then re-measure. Expect the buffer pool hit ratio to rise and disk reads to fall.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Watch the OOM Killer and Set a Safety Net<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Even a well-tuned small database can spike. Protect the system by giving the database process a lower OOM score adjustment and by monitoring memory pressure, so you see trouble before the kernel acts.<\/p>\n\n\n<ul class=\"wp-block-list\"><li><code>systemctl edit mariadb<\/code> and add <code>OOMScoreAdjust=-500<\/code> so the kernel prefers other victims<\/li>\n<li>Monitor <code>\/proc\/pressure\/memory<\/code> for rising stall time<\/li>\n<li>Alert on swap-in rate with <code>vmstat 1<\/code> before the kernel reaches for the OOM killer<\/li>\n<li>Keep backups verified so a crash never becomes data loss<\/li><\/ul>\n\n\n<p class=\"wp-block-paragraph\">Run <code>mysqltuner.pl<\/code> and <code>tuning-primer.sh<\/code> as sanity checks, but treat their advice as suggestions, not commands. Their recommendations assume steady load and can push a small VPS toward swap if applied blindly.<\/p>\n\n\n<h2 class=\"wp-block-heading\">A Fitting Configuration Baseline<\/h2>\n\n\n<p class=\"wp-block-paragraph\">For a 1 GB VPS with a typical WordPress or small application database, the baseline above \u2014 a 320 MB buffer pool, one instance, modest per-connection buffers, 50 connections and a 0.5-second slow query threshold \u2014 runs comfortably and leaves the rest of the system room to work. For a 2 GB box, raise the pool to about 768 MB and <code>max_connections<\/code> to 100, and keep everything else proportional.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The discipline is simple: budget RAM, allocate most of it to InnoDB, cap per-connection memory, and verify with the slow query log and status counters. Ten minutes of sizing beats an afternoon of guessing, and it keeps your small VPS serving traffic instead of swapping.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running MySQL or MariaDB on a 1-2 GB VPS is entirely practical, but the default configuration is written for a machine with far more RAM than you have. Left alone,&#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":8,"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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"Running MySQL or MariaDB on a 1-2 GB VPS is entirely practical, but the default configuration is written for a machine with far more RAM than you have.\" \/>\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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough\" \/>\n<meta property=\"og:description\" content=\"MySQL and MariaDB Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough\" \/>\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 property=\"article:modified_time\" content=\"2026-10-16T22:03:10+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=\"6 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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-09-04T22:46:59+00:00\",\"dateModified\":\"2026-10-16T22:03:10+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"Running MySQL or MariaDB on a 1-2 GB VPS is entirely practical, but the default configuration is written for a machine with far more RAM than you have.\",\"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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough\"}]},{\"@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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough - Virtual Servers VPS Blog","description":"Running MySQL or MariaDB on a 1-2 GB VPS is entirely practical, but the default configuration is written for a machine with far more RAM than you have.","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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough","og_description":"MySQL and MariaDB Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough","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","article_modified_time":"2026-10-16T22:03:10+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"6 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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-09-04T22:46:59+00:00","dateModified":"2026-10-16T22:03:10+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"Running MySQL or MariaDB on a 1-2 GB VPS is entirely practical, but the default configuration is written for a machine with far more RAM than you have.","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 Performance Tuning for Low-Memory VPS: A 1-2 GB RAM Configuration Walkthrough"}]},{"@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":3,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1059\/revisions"}],"predecessor-version":[{"id":1416,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1059\/revisions\/1416"}],"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}]}}