我有一个运行Postgres 9.3的AWS实例,带有4GB内存和2个vCPU。似乎有一个临界点,重负载测试导致postmaster进程开始消耗所有内存并最终消耗所有swap(1GB)。我认为postgresql.conf文件中的值看起来相当保守。
我甚至尝试将shared_buffers丢弃到2GB,将max_connections放到20 ......没有效果它只是继续吃内存和交换。
应该注意的是,我有100个架构。谁能发现我失踪的东西?
archive_command = 'cd .'
archive_mode = on
archive_timeout = 300
checkpoint_completion_target = 0.9
checkpoint_segments = 64
datestyle = 'iso, mdy'
default_statistics_target = 100
default_text_search_config = 'pg_catalog.english'
effective_cache_size = 3GB
hot_standby = on
lc_messages = 'en_US.UTF-8'
lc_monetary = 'en_US.UTF-8'
lc_numeric = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
listen_addresses = '*'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
logging_collector = on
log_rotation_age = 1d
log_rotation_size = 0
log_timezone = 'UTC'
log_truncate_on_rotation = on
maintenance_work_mem = 256MB
max_connections = 80
max_wal_senders = 10
password_encryption = on
shared_buffers = 1GB
shared_preload_libraries = 'repmgr_funcs'
timezone = 'UTC'
track_activities = on
track_counts = on
track_io_timing = on
wal_buffers = 16MB
wal_keep_segments = 288
wal_level = 'hot_standby'
max_locks_per_transaction=256
work_mem = 4MB
答案 0 :(得分:0)
我建议采用以下方法:
top
输出的快照。您想要找到具有最大postgresql
值RSS-SHR
进程
postgresql
进程的内存消耗。您可以关注PostgreSQL wiki和/或https://www.cybertec-postgresql.com/en/checking-per-memory-context-memory-consumption/