Back to all guides
Databases

Optimizing MariaDB Performance

4 read2026-04-09

Out of the box, MariaDB is configured for maximum compatibility and tiny memory footprints, not necessarily for high performance. If your server has RAM to spare, optimizing your configuration is essential.

1. The Configuration File Location

For the latest MariaDB versions on Debian/Ubuntu, the primary user-modifiable settings should be placed in a dedicated file inside the database configuration directory. Usually, this is /etc/mysql/mariadb.conf.d/50-server.cnf or /etc/mysql/my.cnf.

We recommend creating or editing the 50-server.cnf file under the [mysqld] section.

2. InnoDB Buffer Pool Size

This is the single most important setting for MariaDB. It defines how much memory InnoDB is allowed to use for caching data and indexes in memory.

  • Default: 128M
  • Recommended: 50% to 70% of your server's total RAM (only if it is a dedicated database server). E.g., if you have 8GB RAM, set it to 4G.
ini
[mysqld]
innodb_buffer_pool_size = 4G

3. InnoDB Log File Size

A bigger log file size allows transactions to run faster with fewer disk flushes, but recovery after a crash takes longer.

  • Recommended: About 25% of your innodb_buffer_pool_size.
ini
innodb_log_file_size = 1G

4. Max Connections

This setting dictates how many simultaneous connections the database can accept. Increasing this is crucial if you have a high-traffic web server or multiple apps connecting.

  • Default: 151
  • Recommended: Depending on traffic, 300 to 500 is a good safely optimized starting point.
ini
max_connections = 400

5. Query Cache (Deprecation Notice)

If you are using MariaDB 10.3 or higher, the query cache is mostly deprecated or disabled by default because it struggles with multi-core scalability under heavy write loads. It is almost always better to rely on the InnoDB Buffer Pool and application-level caching (like Redis).

ini
query_cache_type = 0
query_cache_size = 0

6. Applying Changes

After making any optimizations, you must restart the MariaDB service.

bash
sudo systemctl restart mariadb

Always monitor your server's memory closely after changing the buffer pool size using bpytop. If the process is killed by the OOM (Out Of Memory) killer, lower the buffer pool size.

KVM Linux VPS

Looking for the right Linux VPS?

Put your project into practice right away: Our KVM VPS provide full root access, lightning-fast NVMe storage, and reliable KVM isolation. Flexible prepaid billing with no subscription and personal Discord support.

Full Root Access (SSH)
Datacenter NVMe SSD
4+ Tbps DDoS Protection
100% Prepaid (No Subscription)