Postgresql

如何確定我的應用程序的更好配置是什麼?

  • September 17, 2020

我目前在 AWS RDS 上使用 Postgres 12,並且正在使用他們的數據庫預設配置。

我使用了一個名為 PgHero 的 gem,它建議我使用 PGTune 來提高數據庫的效率。插入我的輸入後https://pgtune.leopard.in.ua/

# DB Version: 12
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 7 GB
# CPUs num: 2
# Data Storage: ssd

它為我提供了將數據庫配置更新為以下內容的建議:

max_connections = 200  # AWS has: LEAST({DBInstanceClassMemory/9531392},5000)
shared_buffers = 1792MB  # AWS has {DBInstanceClassMemory/32768}
effective_cache_size = 5376MB # AWS has {DBInstanceClassMemory/16384}
maintenance_work_mem = 448MB  # AWS has GREATEST({DBInstanceClassMemory*1024/63963136},65536)
checkpoint_completion_target = 0.7  # AWS has 0.9
wal_buffers = 16MB # AWS is not set
default_statistics_target = 100  # AWS is not set
random_page_cost = 1.1  # AWS is not set
effective_io_concurrency = 200 # AWS is not set
work_mem = 9175kB # AWS is not set
min_wal_size = 1GB  # AWS is 192MB
max_wal_size = 4GB  # AWS is 2048MB
max_worker_processes = 2 # AWS is 8
max_parallel_workers_per_gather = 1 # AWS is not set
max_parallel_workers = 2 # AWS is not set
max_parallel_maintenance_workers = 1 # AWS is not set

我不確定是使用 PGTune 還是只保留 RDS 預設值?通常如何確定是否有性能更新?我在我頭上嗎?

正確的配置取決於您的硬體、數據庫大小和工作負載,我們都不知道。

首先進行保守調整,根據數據庫大小和工作負載設置shared_buffers和到一些合理的值,並根據您的硬體設置、和 。最後,配置日誌記錄。work_mem``maintenance_work_mem``effective_cache_size``effective_io_concurrency``random_page_cost

根據實際負載測試的結果調整這些和其他參數。

引用自:https://dba.stackexchange.com/questions/275622