perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Schindl" <tomAtLi...@gmx.at>
Subject Re: Persistent DB Connection problem
Date Wed, 14 Dec 2005 15:43:25 GMT
Hi,

you are right Jonathan at the moment there's no real DB-Pool implementation
available like one knows it e.g. from Java.

a. Connection-Pool(Connection1, Connection2)
b. Apache-Child-1 "Request-Starts":
   -> Connection1 = Pool->fetchConnection();
   -> Connection1->executeQuery("SELECT * FROM bla")
   -> Pool->returnConnection(Connection1);

c. Apache-Child-2 "Request-Starts":
   -> Connection1 = Pool->fetchConnection();   
   -> Connection1->executeQuery("SELECT * FROM bla");
   -> ... Start working

d. Apache-Child-1 "Request ends":
   -> Connection2 = Pool->fetchConnection();   
   -> Connection2->executeQuery("SELECT * FROM bla");
   -> Pool->returnConnection(Connection2);

e. Apache-Child-2 "Request ends":
   -> Pool->returnConnection(Connection2);      
   
I brought about a few days ago a discussion about mod_dbd (available with
Apache-2.2 ) which exactly acts like I think connection-pooling should work
in Apache.

I've now taken a closer look into the whole thing and at the moment
it seems to possible to use mod_dbd to provide the physical connection on
C-level to DBD::mysql. I've already contacted the maintainer of DBD::mysql
and I hope until next year i get something going.

Tom

> --- Urspr├╝ngliche Nachricht ---
> Von: Jonathan Vanasco <modperl-list@2xlp.com>
> An: Albert Vila <avp@imente.com>
> Kopie: modperl@perl.apache.org
> Betreff: Re: Persistent DB Connection problem
> Datum: Tue, 13 Dec 2005 13:26:18 -0500
> 
> 
> On Dec 13, 2005, at 12:59 PM, Albert Vila wrote:
> 
> > I thought the persistent connection was only one for all childs.
> >
> > What happens then if I have 1000 childs each one with 1 db  
> > connection? This means 1000 database connections. How do you setup  
> > apache + mod_perl in this environment?
> >
> > Albert
> 
> you want  to set it up exactly like that - with 1000 db connections.
> 
> if you have 1 db connection that everyone shares, then your  
> connection ties up and each child has to wait for all the others to  
> finish.  not good.
> 
> if you have 1000 children, i'd be amazed at your setup.  maybe i'm  
> just too green at this, but i've never had enough resources to go  
> above 300 , even using a stripped down setup and preloading just  
> about everything into shared space.
> 
> anways:
> 	mysql and postgres, by default, support ~250 concurrent connections  
> out of the  config file just fine.  you can tweak stuff in the  
> settings to get more.  there's a maxclient setting (or something like  
> that).
> 
> if you wanted to do something with 1000 children and 100 db handles,  
> you could probably do some sort of pooling scheme with a singleton or  
> something where a child 'checks out' a db connection for a request,  
> then checks it back in after its done.  i thought about that once.   
> it gave me a headache.  i brought it up here and with friends and  
> everyone said "why?" - because you should be fine just adding more  
> sql clients.
> 
> if you're looking at 1000 children though, you would almost  
> definitely want to look into a clustered db setup - probably  
> something with reads from 2+ machines that are replicated from a  
> master that handles writes.
> 
> thats my .02¢
> 
> 
> 

-- 
GMX DSL-Flatrate 1 Jahr kostenlos* + WLAN-Router ab 0,- Euro*
Bis 31.12.2005 einsteigen! Infos unter: http://www.gmx.net/de/go/dsl

Mime
View raw message