List Info

Thread: patch to cache DBI connections by process ID




patch to cache DBI connections by process ID
user name
2007-03-30 12:40:18
 

I suggest this be included in the current release once
people are able
to test it out thoroughly - basically, it forces caching of
the DBI
connections by Apache Process ID, so that each process gets
it's own DBI
connection - prevents problems when forking(), etc... Might
even improve
performance if the DBI caching algorithm blocks until a
cached
connection that is in use by one process is released before
returning a
handle to it... not sure if that's the case.

 

I can't imagine how this patch would break anything - the
only side
effect is that more connections are established to the
database
initially - one per Apache child process when Apache starts
- but since
each request is handled in a round-robin fashion by Apache's
child
processes, and new processes are not typically started
unless deemed
necessary, it's really only a handful of increased
connections... it's
probably a good thing to have a few more connections sitting
around for
handling Bric requests.

 

Index: Bric/Util/DBI.pm

============================================================
=======

--- Bric/Util/DBI.pm     (revision 187)

+++ Bric/Util/DBI.pm     (working copy)

 -1745,6
+1745,7 

 

 sub _connect {

     my $dbh = eval {

+       $ATTR-> = $$;

         my $d = DBI->connect_cached(join(':', 'DBI',
DBD_TYPE,
DSN_STRING),

                                     CONNECT_USER,
CONNECT_PASS, $ATTR);

         # Make sure we're consistent about what we think
the
transaction

 

 

 

 

 

 

------------------------------------------------------------
------------
-----------

Dave Beaudet

d-beaudetnga.gov

(202) 312-2755

------------------------------------------------------------
------------
-----------

"Computers are useless.  They can only give you
answers." 

    - Pablo Picasso 

 

 

Re: patch to cache DBI connections by process ID
user name
2007-03-30 13:47:13
On Mar 30, 2007, at 10:40, Beaudet, David P. wrote:

> I suggest this be included in the current release once
people are able
> to test it out thoroughly - basically, it forces
caching of the DBI
> connections by Apache Process ID, so that each process
gets it's  
> own DBI
> connection - prevents problems when forking(), etc...
Might even  
> improve
> performance if the DBI caching algorithm blocks until a
cached
> connection that is in use by one process is released
before  
> returning a
> handle to it... not sure if that's the case.
>
>
>
> I can't imagine how this patch would break anything -
the only side
> effect is that more connections are established to the
database
> initially - one per Apache child process when Apache
starts - but  
> since
> each request is handled in a round-robin fashion by
Apache's child
> processes, and new processes are not typically started
unless deemed
> necessary, it's really only a handful of increased
connections... it's
> probably a good thing to have a few more connections
sitting around  
> for
> handling Bric requests.

Good idea. Applied in r7913.

David

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )