You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Eric Cholet <ch...@logilune.com> on 2000/03/03 15:45:27 UTC
RE: mod_perl/apache::DBI Database Persistent Connection question
> I have question concerning the number of persistent database connections
> per database handle maintained by the "mod_perl/DBI/Apache::DBI"
> combination.
>
> Prior to installing the Apache::DBI module, I rewrote my perl cgi
> scripts so that they would work with my newly installed mod_perl module.
> All of my scripts worked fine after modification. I made sure that all
> database handles were disconnected after use in each script, and checked
> my PostgreSQL postmaster to verify that only a single instance was
> running after I ran each cgi script many, many times.
>
> After installing the Apache::DBI module, it maintained persistent
> database connections to my PostgreSQL database, but it seems to have
> maintained 8 persistent connections to one database which I was
> accessing from one cgi script.
>
> The cgi script contained one database handle at the start, three
> statement handles each of which was prepared, executed & finished within
> its own subroutine using the single database handle declared at the
> beginning, and a final database disconnect statement at the scripts end.
> All the variable assignments were local to the subroutines ["my"] with
> the exception of the database handle & subroutine names which were
> declared ["my"] at the start of the cgi script. I works really, really,
> really, fast!
>
> How many persistent database handles does the Apache::DBI make? I
> thought that it would make one persistent connection per database
> handle, but in my case it made 8 persistent connections for one database
> handle.
It makes one persistent connection per Apache process. You probably had
8 Apache child processes running, hence the 8 persistent db connections.
>
> What concerned me was the manner by which the persistent count
> increased. Upon the initial test that I ran on the PC that contained the
> web server & database, I had 4 persistent database connections. After
> firing up another workstation, accessing the cgi scripts left me with 8
> persistent database connections. I was really nervous at this point -4
> persistent connections per client? So, I crossed my fingers & fired up a
> third client. Still had 8 persistent database connections. I was
> somewhat relieved.
>
> Can anyone shed some light on this? Is this the way it is supposed to
> work? Am I doing something wrong, or should I just leave it to the
> Apache::DBI module to manage the connections?
>
> Thanks!
>
--
Eric