From da2574c492f6c1c3e9bd8f62f1e525e475c35e2e Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 19 Jan 2022 23:34:15 +0100 Subject: [PATCH] disable RECOVERY mode, enable uwsgi threads, tune postgres conf --- app/settings.py | 2 +- app/wsgi.ini | 3 ++- etc/postgresql.conf | 28 ++++++++++++++-------------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/settings.py b/app/settings.py index 0a34e1a4..7df91150 100644 --- a/app/settings.py +++ b/app/settings.py @@ -14,7 +14,7 @@ DEBUG_ENV = os.environ.get('DEBUG') == 'True' DEBUG = DEBUG_ENV TEMPLATE_DEBUG = DEBUG -RECOVERY = True +RECOVERY = False # disable to debug websocket and improve performance DEBUG_TOOLBAR = False diff --git a/app/wsgi.ini b/app/wsgi.ini index 1f18bf1d..1ada757e 100644 --- a/app/wsgi.ini +++ b/app/wsgi.ini @@ -11,7 +11,7 @@ gid = www-data strict = true master = true -enable-threads = false +enable-threads = true vacuum = true ; Delete sockets during shutdown single-interpreter = true die-on-term = true ; Shutdown when receiving SIGTERM (default is respawn) @@ -31,6 +31,7 @@ worker-reload-mercy = 300 ; How long to wait before forcefully killin cheaper-algo = busyness processes = 64 ; Maximum number of workers allowed +threads = 30 cheaper = 24 ; Minimum number of workers allowed cheaper-initial = 24 ; Workers created at startup cheaper-overload = 1 ; Length of a cycle in seconds diff --git a/etc/postgresql.conf b/etc/postgresql.conf index 72618547..7063ed23 100644 --- a/etc/postgresql.conf +++ b/etc/postgresql.conf @@ -61,7 +61,7 @@ listen_addresses = '*' # defaults to 'localhost'; use '*' for all # (change requires restart) #port = 5432 # (change requires restart) -max_connections = 100 # (change requires restart) +max_connections = 2000 # (change requires restart) #superuser_reserved_connections = 3 # (change requires restart) #unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories # (change requires restart) @@ -118,7 +118,7 @@ max_connections = 100 # (change requires restart) # - Memory - -shared_buffers = 8GB # min 128kB +shared_buffers = 24GB # min 128kB # (change requires restart) #huge_pages = try # on, off, or try # (change requires restart) @@ -127,9 +127,9 @@ shared_buffers = 8GB # min 128kB # (change requires restart) # Caution: it is not advisable to set max_prepared_transactions nonzero unless # you actively intend to use prepared transactions. -work_mem = 20971kB # min 64kB +work_mem = 8MB # min 64kB #hash_mem_multiplier = 1.0 # 1-1000.0 multiplier on hash table work_mem -maintenance_work_mem = 2GB # min 1MB +#maintenance_work_mem = 64MB # min 1MB #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem #logical_decoding_work_mem = 64MB # min 64kB #max_stack_depth = 2MB # min 100kB @@ -174,13 +174,13 @@ dynamic_shared_memory_type = posix # the default is the first option # - Asynchronous Behavior - -effective_io_concurrency = 512 # 1-1000; 0 disables prefetching +effective_io_concurrency = 200 # 1-1000; 0 disables prefetching #maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching -max_worker_processes = 32 # (change requires restart) -max_parallel_maintenance_workers = 4 # taken from max_parallel_workers -max_parallel_workers_per_gather = 4 # taken from max_parallel_workers +#max_worker_processes = 8 # (change requires restart) +#max_parallel_maintenance_workers = 2 # taken from max_parallel_workers +#max_parallel_workers_per_gather = 2 # taken from max_parallel_workers #parallel_leader_participation = on -max_parallel_workers = 32 # maximum number of max_worker_processes that +#max_parallel_workers = 8 # maximum number of max_worker_processes that # can be used in parallel operations #old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate # (change requires restart) @@ -213,7 +213,7 @@ max_parallel_workers = 32 # maximum number of max_worker_processes that # (change requires restart) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files -wal_buffers = 16MB # min 32kB, -1 sets based on shared_buffers +#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers # (change requires restart) #wal_writer_delay = 200ms # 1-10000 milliseconds #wal_writer_flush_after = 1MB # measured in pages, 0 disables @@ -227,7 +227,7 @@ wal_buffers = 16MB # min 32kB, -1 sets based on shared_buffers #checkpoint_timeout = 5min # range 30s-1d max_wal_size = 4GB min_wal_size = 1GB -checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0 +#checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 #checkpoint_flush_after = 256kB # measured in pages, 0 disables #checkpoint_warning = 30s # 0 disables @@ -372,7 +372,7 @@ checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0 # - Planner Cost Constants - #seq_page_cost = 1.0 # measured on an arbitrary scale -random_page_cost = 1.1 # same scale as above +#random_page_cost = 4.0 # same scale as above #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 @@ -390,7 +390,7 @@ random_page_cost = 1.1 # same scale as above #min_parallel_table_scan_size = 8MB #min_parallel_index_scan_size = 512kB -effective_cache_size = 24GB +#effective_cache_size = 4GB # - Genetic Query Optimizer - @@ -404,7 +404,7 @@ effective_cache_size = 24GB # - Other Planner Options - -default_statistics_target = 100 # range 1-10000 +#default_statistics_target = 100 # range 1-10000 #constraint_exclusion = partition # on, off, or partition #cursor_tuple_fraction = 0.1 # range 0.0-1.0 #from_collapse_limit = 8 -- 2.39.5