From c4993f9110e0c0323c9e63eeed1c2a51919e38ec Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Mon, 22 Apr 2019 02:01:36 -0500 Subject: [PATCH 1/5] Database tweaks for performance --- config/my.cnf | 81 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/config/my.cnf b/config/my.cnf index 62fa8cbe3f..d1e9558ea1 100644 --- a/config/my.cnf +++ b/config/my.cnf @@ -1,42 +1,39 @@ -[mysqld] -skip-host-cache -skip-name-resolve -datadir = /var/lib/mysql - -# Plots specific -# To avoid single large file -innodb_file_per_table = 1 -# Replication -#server-id=2 -#log_bin = /var/lib/mysql/log/mysql-bin.log -#binlog_do_db = publiclab_production -# Persist socket -socket = /var/lib/mysql/mysqld.sock -pid-file = /var/lib/mysql/mysqld - -# master-host=172.17.0.1 -#replicate-do-db=publiclab_production -#relay-log=publiclab-relay-bin -#relay-log-index=publiclab-relay-bin.index - -# -# * Fine Tuning -# -key_buffer = 16M -max_allowed_packet = 16M -thread_stack = 192K -thread_cache_size = 8 -max_connections = 50 -wait_timeout = 60 -# -# * Query Cache Configuration -# -query_cache_limit = 1M -query_cache_size = 16M - -# Here you can see queries with especially long duration -slow-query-log = 1 -slow-query-log-file = /var/lib/mysql/log/mysql-slow.log -long_query_time = 5 - -!includedir /etc/mysql/conf.d/ +[mysqld] +skip-host-cache +skip-name-resolve +datadir = /var/lib/mysql + +# To avoid single large file +innodb_file_per_table = 1 + +socket = /var/lib/mysql/mysqld.sock +pid-file = /var/lib/mysql/mysqld + +# +# * Fine Tuning +# +key_buffer = 16M +max_allowed_packet = 16M +thread_stack = 192K +thread_cache_size = 8 +max_connections = 100 +wait_timeout = 60 +innodb_buffer_pool_size = 7200M +innodb_log_file_size = 1800M +innodb_read_io_threads = 64 +innodb_write_io_threads = 64 +innodb_io_capacity = 224 +join_buffer_size = 1M + +# +# * Query Cache Configuration +# +query_cache_limit = 1M +query_cache_size = 80M + +# Here you can see queries with especially long duration +slow-query-log = 1 +slow-query-log-file = /var/lib/mysql/log/mysql-slow.log +long_query_time = 5 + +!includedir /etc/mysql/conf.d/ From 1fdd71e97629d8b0dce187c5f07481022e3a44e2 Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Mon, 22 Apr 2019 02:34:15 -0500 Subject: [PATCH 2/5] Reduce innodb buffer pool size because of low memory --- config/my.cnf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/my.cnf b/config/my.cnf index d1e9558ea1..788119399f 100644 --- a/config/my.cnf +++ b/config/my.cnf @@ -16,10 +16,10 @@ key_buffer = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 -max_connections = 100 +max_connections = 80 wait_timeout = 60 -innodb_buffer_pool_size = 7200M -innodb_log_file_size = 1800M +innodb_buffer_pool_size = 5600M +innodb_log_file_size = 1400M innodb_read_io_threads = 64 innodb_write_io_threads = 64 innodb_io_capacity = 224 From c5579100512d83767fea12c5aa9decf5ff9d4ebb Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Mon, 22 Apr 2019 03:13:30 -0500 Subject: [PATCH 3/5] Reduce RAM burden --- config/my.cnf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/my.cnf b/config/my.cnf index 788119399f..0697580b40 100644 --- a/config/my.cnf +++ b/config/my.cnf @@ -18,18 +18,18 @@ thread_stack = 192K thread_cache_size = 8 max_connections = 80 wait_timeout = 60 -innodb_buffer_pool_size = 5600M -innodb_log_file_size = 1400M -innodb_read_io_threads = 64 -innodb_write_io_threads = 64 -innodb_io_capacity = 224 +innodb_buffer_pool_size = 2400M +innodb_log_file_size = 600M join_buffer_size = 1M # # * Query Cache Configuration # -query_cache_limit = 1M -query_cache_size = 80M +#query_cache_limit = 1M +#query_cache_size = 80M +query_cache_limit = 0 +query_cache_size = 0 +# Disabled to reduce RAM overhead - we have rails cache # Here you can see queries with especially long duration slow-query-log = 1 From 34d0bb3451e5ef2de07be3ba999536d95a7d9336 Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Thu, 25 Apr 2019 00:06:28 -0500 Subject: [PATCH 4/5] Reduce memory consumption following mysqltuner advice. --- config/my.cnf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/my.cnf b/config/my.cnf index 0697580b40..01b7215ece 100644 --- a/config/my.cnf +++ b/config/my.cnf @@ -16,11 +16,12 @@ key_buffer = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 -max_connections = 80 +max_connections = 20 wait_timeout = 60 -innodb_buffer_pool_size = 2400M -innodb_log_file_size = 600M -join_buffer_size = 1M +innodb_buffer_pool_size = 1200M +innodb_log_file_size = 300M +innodb_buffer_pool_instances = 3 +join_buffer_size = 2M # # * Query Cache Configuration From f6a212bd960521ad6092a3e75446a7f98e1b5890 Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Thu, 25 Apr 2019 22:39:36 -0500 Subject: [PATCH 5/5] Even more conservative limits for RAM --- config/my.cnf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/my.cnf b/config/my.cnf index 01b7215ece..7d61efdea9 100644 --- a/config/my.cnf +++ b/config/my.cnf @@ -18,9 +18,8 @@ thread_stack = 192K thread_cache_size = 8 max_connections = 20 wait_timeout = 60 -innodb_buffer_pool_size = 1200M -innodb_log_file_size = 300M -innodb_buffer_pool_instances = 3 +innodb_buffer_pool_size = 600M +innodb_log_file_size = 150M join_buffer_size = 2M #