From b05ddbec8728870a954f2df61663a1d921d5abe5 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Tue, 21 Jul 2015 15:15:29 -0700 Subject: [PATCH] Tuning postgresql. --- config/postgresql.conf | 10 +++++----- fabfile.py | 7 +++++++ templates/maintenance_off.html | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/config/postgresql.conf b/config/postgresql.conf index 7bbe33ba1..ae3fb0b1f 100644 --- a/config/postgresql.conf +++ b/config/postgresql.conf @@ -106,7 +106,7 @@ ssl = false # (change requires restart) # - Memory - -shared_buffers = 512MB # min 128kB +shared_buffers = 16GB # min 128kB # (change requires restart) #temp_buffers = 8MB # min 800kB #max_prepared_transactions = 0 # zero disables the feature @@ -171,7 +171,7 @@ wal_buffers = 16MB # min 32kB # - Checkpoints - -checkpoint_segments = 10 # in logfile segments, min 1, 16MB each +checkpoint_segments = 40 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 5min # range 30s-1h #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 #checkpoint_warning = 30s # 0 disables @@ -195,7 +195,7 @@ wal_keep_segments = 320 # in logfile segments, 16MB each; 0 disables # - Standby Servers - -#hot_standby = off # "on" allows queries during recovery +hot_standby = on # "on" allows queries during recovery # (change requires restart) #max_standby_archive_delay = 30s # max delay before canceling queries # when reading WAL from archive; @@ -229,7 +229,7 @@ wal_keep_segments = 320 # in logfile segments, 16MB each; 0 disables #cpu_tuple_cost = 0.01 # same scale as above #cpu_index_tuple_cost = 0.005 # same scale as above #cpu_operator_cost = 0.0025 # same scale as above -effective_cache_size = 6GB +effective_cache_size = 32GB # - Genetic Query Optimizer - @@ -338,7 +338,7 @@ effective_cache_size = 6GB # fatal # panic (effectively off) -#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements +log_min_duration_statement = 5000 # -1 is disabled, 0 logs all statements # and their durations, > 0 logs only # statements running at least this number # of milliseconds diff --git a/fabfile.py b/fabfile.py index 24446dbff..aa74d8e85 100644 --- a/fabfile.py +++ b/fabfile.py @@ -870,6 +870,13 @@ def setup_postgres(standby=False): sudo('/etc/init.d/postgresql stop') sudo('/etc/init.d/postgresql start') +def config_postgres(standby=False): + put('config/postgresql%s.conf' % ( + ('_standby' if standby else ''), + ), '/etc/postgresql/9.4/main/postgresql.conf', use_sudo=True) + + sudo('/etc/init.d/postgresql reload 9.4') + def copy_postgres_to_standby(master='db01'): # http://www.rassoc.com/gregr/weblog/2013/02/16/zero-to-postgresql-streaming-replication-in-10-mins/ diff --git a/templates/maintenance_off.html b/templates/maintenance_off.html index c54c1d868..74b001e83 100644 --- a/templates/maintenance_off.html +++ b/templates/maintenance_off.html @@ -85,7 +85,7 @@

NewsBlur is in maintenance mode

-

Digital Ocean, NewsBlur's hosting provider, is undergoing maintenance and should be back within the next half hour. I'll keep you updated until then, but for now NewsBlur is taking a rest.

+

Tuning PostgreSQL requires a restart of the database. This should take no more than 2 minutes.

To pass the time, check out what's popular on MLKSHK.