Question

I've read so many articles regarding MariaDB optimization for low memory servers. There are a lot of guides about that but people are always sharing their own configuration. That makes it difficult to understand for me or other beginners.

According to the below guide, MariaDB foundation suggests me to disable performance schema. It just saves 100mb memory. https://mariadb.com/resources/blog/starting-mysql-on-low-memory-virtual-machines/

The problem is that my server had 1GB memory and everything was fine when I checked it via Mysql tuner. Physical Memory was 1GB, and Max MySQL memory was 800MB

And then I upgraded my server from 1GB memory to 2GB memory yesterday. Now, as you see the below, Mysqltuner recommends me to dedicate my server after upgrading. Why do those warnings appear?

root@WordPress:~# perl mysqltuner.pl --checkversion --updateversion
 >>  MySQLTuner 1.7.19 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering
[OK] You have the latest version of MySQLTuner(1.7.19)
[OK] Logged in using credentials from Debian maintenance account.
[OK] Currently running supported MySQL version 10.4.12-MariaDB-1:10.4.12+maria~bionic
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mysql/error.log exists
[--] Log file: /var/log/mysql/error.log(408B)
[OK] Log file /var/log/mysql/error.log is readable.
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[OK] /var/log/mysql/error.log doesn't contain any warning.
[!!] /var/log/mysql/error.log contains 4 error(s).
[--] 0 start(s) detected in /var/log/mysql/error.log
[--] 0 shutdown(s) detected in /var/log/mysql/error.log

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE 
[--] Data in InnoDB tables: 17.4M (Tables: 89)
[OK] Total fragmented tables: 0

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[--] There are 620 basic passwords in the list.

-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 16h 4m 42s (166K q [2.870 qps], 8K conn, TX: 170M, RX: 14M)
[--] Reads / Writes: 81% / 19%
[--] Binary logging is disabled
[--] Physical Memory     : 1.9G
[--] Max MySQL memory    : 3.3G
[--] Other process memory: 0B
[--] Total buffers: 432.0M global + 18.8M per thread (151 max threads)
[--] P_S Max memory usage: 104M
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 649.3M (32.58% of installed RAM)
[!!] Maximum possible memory usage: 3.3G (169.44% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/166K)
[OK] Highest usage of available connections: 3% (6/151)
[OK] Aborted connections: 0.00%  (0/8261)
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 8K sorts)
[OK] No joins without indexes
[OK] Temporary tables created on disk: 0% (838 on disk / 93K total)
[OK] Thread cache hit rate: 99% (6 created / 8K connections)
[OK] Table cache hit rate: 95% (139 open / 145 opened)
[OK] table_definition_cache(400) is upper than number of tables(258)
[OK] Open file limit used: 1% (52/4K)
[OK] Table locks acquired immediately: 100% (231 immediate / 231 locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 104.4M
[--] Sys schema is installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 1 thread(s).
[--] Using default value is good enough for your version (10.4.12-MariaDB-1:10.4.12+maria~bionic)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (3M used / 16M cache)
[!!] Cannot calculate MyISAM index size - re-run script as root user

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 256.0M/17.4M
[OK] Ratio InnoDB log file size / InnoDB Buffer pool size: 32.0M * 2/256.0M should be equal to 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 2 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 99.92% (2744805 hits/ 2747120 total)
[!!] InnoDB Write Log efficiency: 74.36% (25782 hits/ 34670 total)
[OK] InnoDB log waits: 0.00% (0 waits / 8888 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/320.0K
[!!] Aria pagecache hit rate: 93.4% (12K cached / 850 reads)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control error line(s) into /var/log/mysql/error.log file
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.

MariaDB version: 10.4 and Server configuration: LEMP stack

Here are my MariaDB settings:

query_cache_type = 0
query_cache_size = 0
performance_schema = ON
innodb_buffer_pool_size = 256M
innodb_log_file_size = 32M
skip-name-resolve=1
join_buffer_size=256K
innodb_stats_on_metadata = 0

I need your brilliant suggestions. Regards.

Was it helpful?

Solution

  • I used to use MySQL on a 256MB, non-dedicated, machine. But, thanks to OS bloat, more MySQL/MariaDB features, etc, 512MB may be the minimum these days.
  • If you set things too high in my.cnf, there will be swapping, which is terrible for performance.
  • When using a tiny VM, decrease, don't increase, things in my.cnf.
  • The main thing to decrease is innodb_buffer_pool_size. 128M is somewhere around the tipping point between "too small" (possibly crashing) and "too large" (possibly swapping).
  • Other things: max_connections=10, table_open_cache=50, query_cache_type=0, query_cache_size=0, performance_schema=OFF.
  • Specific workloads may need a few things increased in size, but do so carefully.
  • There is no valid "max memory" formula; don't take mysqltuner's value too seriously. It is both lower than the possible max and higher that you are likely to hit.
  • If you can affort to have some swap space, do so. It would be better to swap than crash (OOM).
  • Mysqltuner's Innodb data size can be useful: the buffer_pool does not need to be more than about twice that. However, there is 'no' limit on how much data can be handled by a small buffer_pool -- the tradeoff is more I/O.
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top