<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Connection Management in ActiveRecord</title>
	<atom:link href="http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/</link>
	<description>The act of making love, tenderly.</description>
	<lastBuildDate>Mon, 21 May 2012 21:22:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Andreas</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-145666</link>
		<dc:creator>Andreas</dc:creator>
		<pubDate>Tue, 15 Nov 2011 16:29:55 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-145666</guid>
		<description>An immediate result thanks to your talk about this at rubyconf in Uruguay. http://t.co/llY4HVCQ</description>
		<content:encoded><![CDATA[<p>An immediate result thanks to your talk about this at rubyconf in Uruguay. <a href="http://t.co/llY4HVCQ" rel="nofollow">http://t.co/llY4HVCQ</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Our Geek Space &#187; Blog Archive &#187; It&#8217;s about timing baby!</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-145650</link>
		<dc:creator>Our Geek Space &#187; Blog Archive &#187; It&#8217;s about timing baby!</dc:creator>
		<pubDate>Tue, 15 Nov 2011 13:44:50 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-145650</guid>
		<description>[...] is no free connection it iterates over all the threads to take back the connections of dead threads(more info). See the correlation with the 5 seconds I talked about in the previous paragraph? We immediately [...]</description>
		<content:encoded><![CDATA[<p>[...] is no free connection it iterates over all the threads to take back the connections of dead threads(more info). See the correlation with the 5 seconds I talked about in the previous paragraph? We immediately [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Multi-threaded use of Rails ActiveRecord 3.0-3.1 &#124; Bibliographic Wilderness</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-145570</link>
		<dc:creator>Multi-threaded use of Rails ActiveRecord 3.0-3.1 &#124; Bibliographic Wilderness</dc:creator>
		<pubDate>Mon, 14 Nov 2011 19:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-145570</guid>
		<description>[...] When I say &#8220;old rails&#8221;  I mean Rails/Active Record 2.1, before the introduction of the ConnectionPool.  When I say &#8220;new&#8221; or &#8220;current&#8221; Rails, I mean Rails 3.0 or 3.1  In fact, the ConnectionPool was introduced in Rails 2.2, so the general principles may apply starting then, however there have been continual tweaks to ConnectionPool for bugs, robustness, and performance, so using Rails 3.0 or 3.1 is recommended.  Rails 3.2 does not yet exist at time of this writing, and may completely change the game yet again, if Aaron tenderlove goes forward with his ideas for a major refactor. [...]</description>
		<content:encoded><![CDATA[<p>[...] When I say &#8220;old rails&#8221;  I mean Rails/Active Record 2.1, before the introduction of the ConnectionPool.  When I say &#8220;new&#8221; or &#8220;current&#8221; Rails, I mean Rails 3.0 or 3.1  In fact, the ConnectionPool was introduced in Rails 2.2, so the general principles may apply starting then, however there have been continual tweaks to ConnectionPool for bugs, robustness, and performance, so using Rails 3.0 or 3.1 is recommended.  Rails 3.2 does not yet exist at time of this writing, and may completely change the game yet again, if Aaron tenderlove goes forward with his ideas for a major refactor. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seraf</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-144419</link>
		<dc:creator>Seraf</dc:creator>
		<pubDate>Fri, 04 Nov 2011 16:48:11 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-144419</guid>
		<description>Fuck you, with love.

Keep writing, I won&#039;t read you. :)</description>
		<content:encoded><![CDATA[<p>Fuck you, with love.</p>
<p>Keep writing, I won&#8217;t read you. <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: apneadiving</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-144200</link>
		<dc:creator>apneadiving</dc:creator>
		<pubDate>Wed, 02 Nov 2011 21:11:26 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-144200</guid>
		<description>Thanks for your job and your peculiar, yet lovely, weirdness ;)</description>
		<content:encoded><![CDATA[<p>Thanks for your job and your peculiar, yet lovely, weirdness <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jérémy Lecour</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-143684</link>
		<dc:creator>Jérémy Lecour</dc:creator>
		<pubDate>Fri, 28 Oct 2011 07:38:40 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-143684</guid>
		<description>Thanks Aaron for making this kind of deep analysis of non fancy parts of the framework.

I&#039;d really like to run into you in a coffee shop and hug you Swayze-style ;-)

BTW, this hug thing inspired me to offer some free pair-programming time to people who&#039;d like to have some kind of guidance. Thanks for that idea too.

&lt;3</description>
		<content:encoded><![CDATA[<p>Thanks Aaron for making this kind of deep analysis of non fancy parts of the framework.</p>
<p>I&#8217;d really like to run into you in a coffee shop and hug you Swayze-style <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>BTW, this hug thing inspired me to offer some free pair-programming time to people who&#8217;d like to have some kind of guidance. Thanks for that idea too.</p>
<p>&lt;3</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: This Week&#8217;s Top Ruby News: JRuby 1.6.5, A New Prag Prog Book, Fast Specs, Rails Style Guide and More</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-143622</link>
		<dc:creator>This Week&#8217;s Top Ruby News: JRuby 1.6.5, A New Prag Prog Book, Fast Specs, Rails Style Guide and More</dc:creator>
		<pubDate>Thu, 27 Oct 2011 16:30:19 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-143622</guid>
		<description>[...] Connection Management in ActiveRecord (and How To Improve It) Aaron &#039;tenderlove&#039; Patterson talks about database connection management in ActiveRecord, how he&#039;s not pleased with it, and how he wants to step towards fixing it to be more like File&#039;s API. [...]</description>
		<content:encoded><![CDATA[<p>[...] Connection Management in ActiveRecord (and How To Improve It) Aaron &#039;tenderlove&#039; Patterson talks about database connection management in ActiveRecord, how he&#039;s not pleased with it, and how he wants to step towards fixing it to be more like File&#039;s API. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TVD</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-143615</link>
		<dc:creator>TVD</dc:creator>
		<pubDate>Thu, 27 Oct 2011 14:44:55 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-143615</guid>
		<description>Quote:
&quot;[R]educe code complexity and at the same time increase the features available.&quot;

+1 if this is why you love Rails!

Go for it Aaron!</description>
		<content:encoded><![CDATA[<p>Quote:<br />
&#8220;[R]educe code complexity and at the same time increase the features available.&#8221;</p>
<p>+1 if this is why you love Rails!</p>
<p>Go for it Aaron!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Collins</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-143380</link>
		<dc:creator>Ken Collins</dc:creator>
		<pubDate>Tue, 25 Oct 2011 14:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-143380</guid>
		<description>Being an ActiveRecord adapter author, the connection pool is something that still boggles my mind every now and then. I&#039;ll point out a few oddities I have had and followup with a few questions that hopefully Aaron or someone can help me with.

First, you talked a bit about the #establish_connection method. One thing I was bitten by many years ago was using #establish_connection too much. I don&#039;t think that many people understand that if you have a base configuration and you call establish_connection(:legacy_db) in say 3 models, you end up with 3 distinct connection pools for those models. If you have callbacks that touch other models, bam, deadlock. The current practice that I do not see documented much and that I tell my adapter users to do is to make a model that champions the connection and subclass from that. Something like this: https://gist.github.com/1312844 This is a contrived example when your application needs to talk to 2 or more databases. 

So my first question what would the pattern look like in your solutions? Would #establish_connection work like I thought many years ago and not create a pool per class. Is #establish_connection the only time where classes end up with a connection pool? 

Second question is related to connection pool size. In my mind, a basic non thread-safe rails application would never end up with a connection pool larger than 1. I have found that in some cases in a large 5-year old rails application, that the pool grows and setting it to 1 would not allow the app to work. Why? Is this related to ActionPack or some other middleware checking things back in?

P.S., I love the config.i_suck_and_will_not_close_my_database_connections, reminds me of MiniTest&#039;s #i_suck_and_my_tests_are_order_dependent! :)</description>
		<content:encoded><![CDATA[<p>Being an ActiveRecord adapter author, the connection pool is something that still boggles my mind every now and then. I&#8217;ll point out a few oddities I have had and followup with a few questions that hopefully Aaron or someone can help me with.</p>
<p>First, you talked a bit about the #establish_connection method. One thing I was bitten by many years ago was using #establish_connection too much. I don&#8217;t think that many people understand that if you have a base configuration and you call establish_connection(:legacy_db) in say 3 models, you end up with 3 distinct connection pools for those models. If you have callbacks that touch other models, bam, deadlock. The current practice that I do not see documented much and that I tell my adapter users to do is to make a model that champions the connection and subclass from that. Something like this: <a href="https://gist.github.com/1312844" rel="nofollow">https://gist.github.com/1312844</a> This is a contrived example when your application needs to talk to 2 or more databases. </p>
<p>So my first question what would the pattern look like in your solutions? Would #establish_connection work like I thought many years ago and not create a pool per class. Is #establish_connection the only time where classes end up with a connection pool? </p>
<p>Second question is related to connection pool size. In my mind, a basic non thread-safe rails application would never end up with a connection pool larger than 1. I have found that in some cases in a large 5-year old rails application, that the pool grows and setting it to 1 would not allow the app to work. Why? Is this related to ActionPack or some other middleware checking things back in?</p>
<p>P.S., I love the config.i_suck_and_will_not_close_my_database_connections, reminds me of MiniTest&#8217;s #i_suck_and_my_tests_are_order_dependent! <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Sobrinho</title>
		<link>http://tenderlovemaking.com/2011/10/20/connection-management-in-activerecord/comment-page-1/#comment-143025</link>
		<dc:creator>Gabriel Sobrinho</dc:creator>
		<pubDate>Sat, 22 Oct 2011 13:08:36 +0000</pubDate>
		<guid isPermaLink="false">http://tenderlovemaking.com/?p=566#comment-143025</guid>
		<description>Aaron Patterson,

This sounds great!

I made a gem to handle multiple connections (I&#039;m dealing with an application where each customer have your own dedicated database) and I guess the code is so bad because I can&#039;t handle active record in a great way.

The only way I found is monkey patching 2 methods of active record, take a look: https://github.com/sobrinho/activerecord-connections/blob/master/lib/active_record/connections.rb

I guess your idea will handle this situation and the gem will not be necessary anymore, right?</description>
		<content:encoded><![CDATA[<p>Aaron Patterson,</p>
<p>This sounds great!</p>
<p>I made a gem to handle multiple connections (I&#8217;m dealing with an application where each customer have your own dedicated database) and I guess the code is so bad because I can&#8217;t handle active record in a great way.</p>
<p>The only way I found is monkey patching 2 methods of active record, take a look: <a href="https://github.com/sobrinho/activerecord-connections/blob/master/lib/active_record/connections.rb" rel="nofollow">https://github.com/sobrinho/activerecord-connections/blob/master/lib/active_record/connections.rb</a></p>
<p>I guess your idea will handle this situation and the gem will not be necessary anymore, right?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

