From 6534413cf3940c6f2c7585cc66d4febe7d65b575 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras <evangelos@foutrelis.com> Date: Wed, 18 Aug 2021 19:56:50 +0300 Subject: [PATCH] mariadb: Tweak query cache settings We used to set query_cache_type to 0 in the default settings but we were also setting query_cache_size to a non-zero/non-default value, which was in turn re-enabling the query cache. Update the configuration to reflect the actual cache state and make sure query_cache_size is set to zero for the "query_cache_type = 0" case. Now that the setting controls the real state of the query cache, disable it for bbs.archlinux.org; its hit rate is small compared to insert rate. --- playbooks/bbs.archlinux.org.yml | 2 +- roles/mariadb/defaults/main.yml | 2 +- roles/mariadb/templates/server.cnf.j2 | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/playbooks/bbs.archlinux.org.yml b/playbooks/bbs.archlinux.org.yml index c345169e0..a3a24a95c 100644 --- a/playbooks/bbs.archlinux.org.yml +++ b/playbooks/bbs.archlinux.org.yml @@ -10,7 +10,7 @@ - { role: root_ssh } - { role: certbot } - { role: nginx } - - { role: mariadb } + - { role: mariadb, mariadb_query_cache_type: '0' } - { role: sudo } - { role: php_fpm, php_extensions: ['apcu', 'iconv', 'intl', 'mysqli'], zend_extensions: ['opcache'] } - { role: fluxbb } diff --git a/roles/mariadb/defaults/main.yml b/roles/mariadb/defaults/main.yml index 2568778d9..d21707802 100644 --- a/roles/mariadb/defaults/main.yml +++ b/roles/mariadb/defaults/main.yml @@ -9,7 +9,7 @@ mariadb_net_buffer_length: '8K' mariadb_read_buffer_size: '256K' mariadb_read_rnd_buffer_size: '512K' mariadb_myisam_sort_buffer_size: '8M' -mariadb_query_cache_type: '0' +mariadb_query_cache_type: '1' mariadb_query_cache_limit: '16M' mariadb_query_cache_size: '32M' mariadb_max_connections: '400' diff --git a/roles/mariadb/templates/server.cnf.j2 b/roles/mariadb/templates/server.cnf.j2 index e2c71188c..1d5bf186e 100644 --- a/roles/mariadb/templates/server.cnf.j2 +++ b/roles/mariadb/templates/server.cnf.j2 @@ -23,13 +23,19 @@ net_buffer_length = {{ mariadb_net_buffer_length }} read_buffer_size = {{ mariadb_read_buffer_size }} read_rnd_buffer_size = {{ mariadb_read_rnd_buffer_size }} myisam_sort_buffer_size = {{ mariadb_myisam_sort_buffer_size }} -query_cache_type = {{ mariadb_query_cache_type }} -query_cache_limit = {{ mariadb_query_cache_limit }} -query_cache_size = {{ mariadb_query_cache_size }} max_connections = {{ mariadb_max_connections }} thread_cache_size = {{ mariadb_thread_cache_size }} userstat = 1 +# Query cache settings +query_cache_type = {{ mariadb_query_cache_type }} +query_cache_limit = {{ mariadb_query_cache_limit }} +{% if mariadb_query_cache_type == '0' %} +query_cache_size = 0 +{% else %} +query_cache_size = {{ mariadb_query_cache_size }} +{% endif %} + # Single server setup server-id = 1 -- GitLab