For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > February 2005 > Re: Mod_perl: can I share a database connection by putting it in









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Mod_perl: can I share a database connection by putting it in
Brian McCauley

2005-02-14, 4:00 pm



Oliver Green wrote:

> I'm using Apache::Registry to speed up my cgi scripts. So far I've not
> modified the scripts themselves apart from moving most of the common
> "use <Module>" to the startup-script so apache caches them.
>
> As all scripts connect to a database (using DBI), I might as well move
> the connect statement to the startup-script. This works, and apparently
> the connection is now shared by all the children that apache forks.
>
> However, I have a hard time telling if it will work correctly under
> load.


It will not.

> I suspect that by re-using the same connection over and over I
> might get some concurrency issues, or inconsistency errors.


You will.

> How would I setup a test on my (modest) development system simulating
> high usage?


Don't bother.

> And I would love to hear from someone that actually knows if this
> connection sharing is at all advisable.


It is not.

In mod_perl2 with the next generation of Apache::DBI connection sharing
(or rather pooling) will be apparently supported eventually by some DBDs
- but it will be manged transparently by Apache::DBI.

Brian McCauley

2005-02-15, 4:02 pm



Keith Keller wrote:
> On 2005-02-14, Brian McCauley <nobull@mail.com> wrote:
>
>
>
> In mod_perl1, Apache::DBI can be configured so that each httpd process
> opens its own connection to databases that is shared across scripts
> hitting that httpd.


When you say 'can be configured' this implies that it is not the default
behaviour of Apache::DBI, but AFIAK this is the default behaviour of
Apache::DBI, indeed what else doe Apache::DBI do?

> 1) Install Apache::DBI for your version of mod_perl,


Oooh, is Apache::DBI for mod_perl2 available? I must go get it.

Oliver Green

2005-02-17, 4:03 pm

Keith Keller wrote:
> 1) Install Apache::DBI for your version of mod_perl, and carefully read
> its documentation.


Thank you all for responding. I've installed Apache::DBI and
performance is sufficient for now. I'll rewrite parts of the
application to make better use of mod_perl, but as said, it
works for now.

Oliver
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com