开发者

How to increase max pool size in ActiveRecord?

I get the error:

Error "ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5 seconds.  The max pool size is currently 5; consider increasing it."

How do I increase the max pool size?

# DB CONNECTION
DB_CONN = ActiveRecord::Base.establish_connection(:adapter =&g开发者_如何学运维t; "sqlite3", :dbfile => DB_FILE)


config/database.yml
pool: 8 (default is 5)

Read more


A static number of connections can be specified, but ...

# config/database.yml
default: &default
  adapter: postgresql
  pool: 99 %>

.. but if the number of connections needed is proportional to the number of threads, it may be desirable to specify it dynamically. In this example, two connections per thread.

  pool: <%= 2 * (ENV.fetch("RAILS_MAX_THREADS") { 5 }) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜