【发布时间】:2017-10-02 07:56:16
【问题描述】:
我托管了一个使用 Postgres 作为数据存储的 Ruby on rail 应用程序 (Mastodon)。
我收到了很多请求,这引发了有关池的问题,导致应用程序需要等待在 Postgres 发言。
我在这个配置下使用 Pgbouncer:
max_client_conn = 2000
default_pool_size = 50
我已经像这样调整了 Postgres:
max_connections = 500
shared_buffers = 512MB
effective_cache_size = 1536MB
work_mem = 1048kB
maintenance_work_mem = 128MB
min_wal_size = 1GB
max_wal_size = 2GB
checkpoint_completion_target = 0.7
wal_buffers = 16MB
default_statistics_target = 100
数据库服务器位于具有 2G 内存的专用 VPS 上。
我在铁路方面遇到的那种错误:
a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use
有时会出现关于请求超时的错误(请求运行时间超过 90000 毫秒)。
我的 Rail 应用程序使用此配置生成工人:
- WEB_CONCURRENCY=4
- MAX_THREADS=10
- DB_POOL=20
任何想法如何停止这个繁忙的 Postgres 池问题? 可能是配置问题。
任何其他的处理方式是让 Postgres slave 进行读取?
我的请求数量有点超出了..
【问题讨论】:
标签: ruby-on-rails ruby postgresql