No matter how powerful your website's infrastructure is (even if you use a virtual server with a 100% NVMe disk), an unconfigured MySQL or MariaDB service will slow down your site. When MySQL is installed with default settings, it is generally optimized to consume very low resources. When your traffic increases, changing these settings is a must.
1. Editing the my.cnf (Configuration) File
The basic settings of your database server are kept in the my.cnf file (usually /etc/my.cnf or /etc/mysql/my.cnf). Open this file by connecting via SSH and proportionally increase the following values according to your server RAM capacity (e.g., 4GB):
The most critical setting is the innodb_buffer_pool_size option; setting this between 40% and 60% of the total RAM on your server allows the database to read data much faster from RAM instead of disk.
2. Using the MySQLTuner Script
If you do not know which setting to make how much, the Perl-based MySQLTuner tool offers you a prescription. Download it to your server and run it:
The script will analyze your database and tell you which my.cnf variables you need to change in the "Recommendations" section at the end.
3. Periodic Table Optimization
Data deleted or updated in your database leaves gaps (fragmentation) behind. You should optimize your tables periodically:
mysqlcheck -o --all-databases
You can review our high-performance Turkey VDS packages specially designed for e-commerce or news sites that have high traffic and want a strong database infrastructure, and make your site fly in search engines!