After load testing my app, it started getting errors at 6 concurrent
users on a not-at-all heavy SQL operation page and I want to know how
to reduce these. I’ve read up about Connection Pooling but the
information out there is scarce. I’d like to increase my pool limit to
about 25-40 but what are the possible negative repercussions?
The API docs say I must also return the connections to the pool after
they’re done being used with:
ActiveRecord::Base.clear_active_connections!
However, where does this line of code go? And what line of code goes
into database.yml to increase the pool size?
Thanks
On Feb 21, 8:16am, simpleton [email protected] wrote:
However, where does this line of code go? And what line of code goes
into database.yml to increase the pool size?
Add
pool: 10
for example amongst the settings for each environment. In a ‘normal’
rails app where you aren’t creating threads yourself connections
should be returned to the pool for you. If you are creating threads,
then you should close the connection at the end of the thread’s
execution e.g.
Thread.new do
begin
…
ensure
ActiveRecord::Base.connection.close
end
end
In terms of the downsides i think it’s just that the database has
potentially more connections to handle.
Fred
Certainly not using Thread.new yet.
Thanks Fred.