Move promscale tuning to role and tune WAL sizes
authorTom Hughes <tom@compton.nu>
Wed, 10 Feb 2021 22:35:17 +0000 (22:35 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 10 Feb 2021 22:42:01 +0000 (22:42 +0000)
cookbooks/timescaledb/recipes/default.rb
roles/prometheus.rb

index 776cab65534782ed50de637ad37205ee595fbed7..a9878595a429a556b38f35679c2c0e84fed366ef 100644 (file)
@@ -26,31 +26,11 @@ package %W[
   timescaledb-2-postgresql-#{database_version}
 ]
 
-memory_gb = (node[:memory][:total].to_f / 1024 / 1024).ceil
-
 node.default_unless[:postgresql][:versions] = []
 node.default[:postgresql][:versions] |= [database_version]
 node.default[:postgresql][:monitor_tables] = false
-node.default[:postgresql][:settings][database_version][:max_connections] = 500
-node.default[:postgresql][:settings][database_version][:shared_buffers] = "#{memory_gb / 4}GB"
-node.default[:postgresql][:settings][database_version][:work_mem] = "#{memory_gb * 128 / 50 / node[:cpu][:total]}MB"
-node.default[:postgresql][:settings][database_version][:maintenance_work_mem] = "2GB"
-node.default[:postgresql][:settings][database_version][:effective_io_concurrency] = "200"
-node.default[:postgresql][:settings][database_version][:max_worker_processes] = node[:cpu][:total] + node[:timescaledb][:max_background_workers] + 3
-node.default[:postgresql][:settings][database_version][:max_parallel_workers_per_gather] = node[:cpu][:total] / 2
-node.default[:postgresql][:settings][database_version][:max_parallel_workers] = node[:cpu][:total]
-node.default[:postgresql][:settings][database_version][:wal_buffers] = "16MB"
-node.default[:postgresql][:settings][database_version][:max_wal_size] = "1GB"
-node.default[:postgresql][:settings][database_version][:min_wal_size] = "512MB"
-node.default[:postgresql][:settings][database_version][:checkpoint_completion_target] = "0.9"
-node.default[:postgresql][:settings][database_version][:random_page_cost] = "1.1"
-node.default[:postgresql][:settings][database_version][:effective_cache_size] = "#{memory_gb * 3 / 4}GB"
-node.default[:postgresql][:settings][database_version][:default_statistics_target] = "500"
-node.default[:postgresql][:settings][database_version][:autovacuum_max_workers] = "10"
-node.default[:postgresql][:settings][database_version][:autovacuum_naptime] = "10"
 node.default_unless[:postgresql][:settings][database_version][:shared_preload_libraries] = []
 node.default[:postgresql][:settings][database_version][:shared_preload_libraries] |= ["timescaledb"]
-node.default[:postgresql][:settings][database_version][:max_locks_per_transaction] = "512"
 node.default_unless[:postgresql][:settings][database_version][:customized_options] = {}
 node.default[:postgresql][:settings][database_version][:customized_options]["timescaledb.max_background_workers"] = node[:timescaledb][:max_background_workers]
 
index 1b97fdb72306015dea887af9ad078e34d4dc91bf..0016c6c0fef33d6018252652d750daa56f471d36 100644 (file)
@@ -1,6 +1,33 @@
 name "prometheus"
 description "Role applied to all prometheus servers"
 
+default_attributes(
+  :postgresql => {
+    :settings => {
+      :defaults => {
+        :max_connections => "500",
+        :shared_buffers => "48GB",
+        :work_mem => "8MB",
+        :maintenance_work_mem => "2GB",
+        :effective_io_concurrency => "200",
+        :max_worker_processes => "67",
+        :max_parallel_workers_per_gather => "28",
+        :max_parallel_workers => "56",
+        :wal_buffers => "16MB",
+        :max_wal_size => "32GB",
+        :min_wal_size => "4GB",
+        :checkpoint_completion_target => "0.9",
+        :random_page_cost => "1.1",
+        :effective_cache_size => "144GB",
+        :default_statistics_target => "500",
+        :autovacuum_max_workers => "10",
+        :autovacuum_naptime => "10",
+        :max_locks_per_transaction => "512"
+      }
+    }
+  }
+)
+
 run_list(
   "recipe[prometheus::server]"
 )