We use Rails 2.3.5, MySQL, and WEBrick.

ActiveRecord call ConnectionPool#checkout and create new connection to
MySQL when receive a first HTTP request.
At this time, register to connection pool its connection in
ConnectionPool#checkout_new_connection.
# 
http://github.com/rails/rails/blob/v2.3.5/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L181
# 
http://github.com/rails/rails/blob/v2.3.5/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L246

but, Rack::Handler::WEBrick#service call body.close in ensure section
when return the HTTP response.
It call another method. after some call, it call
ConnectionPool#clear_reloadable_connections and clear its connection
pool.
# 
http://github.com/rails/rails/blob/v2.3.5/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L145

As a result, the connection was created by every request and spend
time for connection.

How to use connection pool?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to