[Catalyst] How to share a database connection across multiple Catalyst apps?

Tomas Doran bobtfish at bobtfish.net
Thu Sep 9 01:16:10 GMT 2010


On 8 Sep 2010, at 19:17, Javier Arturo Rodriguez wrote:

> On 9/8/10 4:54 PM, Simon Miner wrote:
>> The parameters defining the connection have to be exactly the same,  
>> including the connect attributes! If there      is no appropriate  
>> database handle or if the ping method fails, a new connection is  
>> established and the handle is stored for later re-use.
> I agree that this is not early optimization -- just good  
> housekeeping. Oracle SQL Net connections are indeed expensive to set  
> up but tend to consume near-zero resources when idle, so I would not  
> worry too much about connection reuse among apps just yet - in my  
> book this is more of a sysadmin issue.

I'm entirely unsure which side you're arguing for here.

Oracle connections are expensive _to make_, but given you spend one  
per process per app (and your app serves just the dynamic content),  
who cares?

I'd consider being able to treat my applications as entirely disparate  
disconnected entities as a good feature (especially as one app is able  
to say things which affect the DB connection wide - if connections  
were shared between apps this could be more than a single app issue)...

So, in summary - yes, reconnecting per request bad, but you're using  
DBIC anyway - so that's not what's happening.. Reconnecting once for  
each app per process, fine - stop stressing about it..

Cheers
t0m




More information about the Catalyst mailing list