mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: add connection pool drainer to keep connection counts down
This commit is contained in:
parent
f8528b12d3
commit
9ceb0556bc
13
config/initializers/99-drain_pool.rb
Normal file
13
config/initializers/99-drain_pool.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# pg performs inconsistently with large amounts of connections
|
||||||
|
# this helps keep connection counts in check
|
||||||
|
Thread.new do
|
||||||
|
while true
|
||||||
|
sleep 30
|
||||||
|
pools = []
|
||||||
|
ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::ConnectionPool){|pool| pools << pool}
|
||||||
|
|
||||||
|
pools.each do |pool|
|
||||||
|
pool.drain(30.seconds)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user