OllieJones / index-wp-mysql-for-speed

A plugin to add useful indexes to your WordPress installation's MySQL database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mariadb 10.7 server config optimization

ufo56 opened this issue · comments

commented

Hi

Have anyone some suggestions how can i optimize more Mariadb server config? At moment config looks like this, i have tuned settings that i know. Woocommerce + WPML, about 100k products. 16 core server, 32gb ram, nvme ssd.
Asking because using this plugin tips/tricks query performance did not improve.

skip-name-resolve = 1
performance_schema = ON

thread_cache_size = 64
table_open_cache = 4096

table_definition_cache = 16384

thread_handling = pool-of-threads

query_cache_size = 120M

sort_buffer_size = 8M
innodb = force
innodb_buffer_pool_size = 8G #512M
innodb_log_file_size = 512M
innodb_stats_on_metadata = OFF
innodb_buffer_pool_instances = 8
innodb_log_buffer_size = 64M
innodb_flush_log_at_trx_commit = 2
innodb_thread_concurrency = 0 #6
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_io_capacity = 5000



innodb_flush_method	= fsync
innodb_change_buffer_max_size = 10
innodb_lru_scan_depth = 256
innodb_compression_algorithm = lz4
innodb_ft_cache_size = 24M
innodb_open_files = 4096
innodb_max_dirty_pages_pct = 50
innodb_online_alter_log_max_size = 256M
innodb_sort_buffer_size = 12M
innodb_sync_array_size = 2
innodb_sync_spin_loops = 15
innodb_thread_sleep_delay = 0
innodb_adaptive_max_sleep_delay = 0


aria_pagecache_buffer_size = 512M
aria_sort_buffer_size = 512M

join_buffer_size = 16M
tmp_table_size = 128M
key_buffer_size = 16M
expire_logs_days = 3
max_allowed_packet = 64M
max_heap_table_size = 128M

read_rnd_buffer_size = 16M
read_buffer_size = 2M

bulk_insert_buffer_size = 64M
max_connections = 128
myisam_sort_buffer_size = 128M
explicit_defaults_for_timestamp = 1
open_files_limit = 65535
log_bin_trust_function_creators = 1
disable_log_bin

If you don't have a persistent object cache (Redis / memcached) you should get one. It dramatically reduces MariaDB query traffic.

Your server hardware is adequately provisioned and may be overprovisioned for 100K products. Bigger servers rarely increase individual DBMS query performance. They can help with concurrency.

You could try increasing your innodb_buffer_pool_size to approx. 70% of your server's RAM, if the server machine is dedicated to the DBMS. If it's shared with your php / web servers it's harder to guess how much RAM to put in the pool without seeing memory utilization.

You could explore using a cloud server solution like SkyCloud (from MariaDB AB) or a DBMS offering from one of the cloud providers. They'll provide replication and parallel servers, for a significant price.

If you have time you could try using this plugin's Monitor feature to monitor a few minutes of operations and upload the monitor. We can take a look at what's slow on your system. Please also upload your metadata from the About tab on the Tools / Index MySQL. We can examine your situation.

  • innodb_buffer_pool_size is the most important value to tune. Also, a default installation of the database is not likely to set it well. My usual answer is "set it to 70% of available RAM". But that is too high for tiny machines (under 4GB). Also, it is hard to predict how much RAM will be consumed by non-DB apps such as the web server, WP, and various plugins. I recommend you start with the 70%, but lower the amount if any swapping occurs. Your example has a setting of 8G on a 32GB server; there is probably free space available to allow raising the setting. However, increasing the setting much higher than the total amount of disk space used by database provides no further benefit.
  • HDD vs SSD -- io_capacity=5000 is much too big for an old spinning drive; 2000 is typical for SSD.
  • The Query Cache is an old feature that has not been renovated to handle bigger memories or clustered configurations. It has been removed from MySQL 8 and must be turned off in clustered environments. Meanwhile, query_cache_size = 120M is too big. Either turn it completely off or lower the value to 50M. The QC is rarely beneficial since all entries for a given table are purged from it when any change is made to the table. For example, the QC is essentially useless for any query involving wp_posts and wp_postmeta.
  • tmp_table_size = 128M -- That's fine for a 32GB server. For others reading this, note that the setting should be no more than 1% of RAM.
  • innodb_ft_cache_size, innodb_max_dirty_pages_pct, innodb_online_alter_log_max_size, and some of the others -- I rarely see anyone changing these settings away from their defaults. I would be happy to discuss the details with the person who decided to make the changes.

The values I have recommended above are not precise. Slight changes are not likely to show any measurable improvement or harm.

As you probably noticed -- Most of these settings don't really matter. Phrased another way "You can't [usually] tune your way out of performance problems.

With rare exceptions, my comments apply equally well to all versions of MySQL and MariaDB.

For a more thorough analysis of your settings, follow the instructions here: http://mysql.rjweb.org/doc.php/mysql_analysis#tuning (Be sure the server has been running at least 24 hours.) I could also analyze your "slow" queries: (http://mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog)

We haven't heard back from you. If you still need help, please don't hesitate to open a new issue.