You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Wayne Izatt <wi...@yahoo.ca> on 2001/05/05 00:17:20 UTC
Apache::DBI + persistent connections
Hi all. I've ploughed through the documentation
regarding persistent db connections under mod_perl,
but I guess I'm not properly understanding just what
is meant by persistent connection.
The scenario I have is a simple CGI script running
under Apache::Registry. I added Apache::DBI to
httpd.conf to buy the app ssome persistent
connections. The app consists of a single script that
makes one connection to MySQL.
It is my understanding that when the app is running
and I look at the status under MySQL, that I should
see only one connection. However, what I see is plenty
of connections, as many as there were before I added
Apache::DBI to the mix.
Now, the script fetches and parses html docs and calls
itself for each image in the doc etc. What I'm seeing,
typically, is the same number of connections to MySQL
as there are images in the document.
Which leads me to think that "persistent" means that,
if a single script makes multiple connect requests
(with the same parameters), a single connection will
be utilized. But if multiple instances of the script
are active, each instance/process will be generating
connections.
Would this be correct?
Enlightenment much appreciated
wayne
_______________________________________________________
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca
Re: Apache::DBI + persistent connections
Posted by Jules <ha...@popmonkey.com>.
----- Original Message -----
From: "Wayne Izatt" <wi...@yahoo.ca>
To: <mo...@apache.org>
Sent: Friday, May 04, 2001 3:17 PM
Subject: Apache::DBI + persistent connections
> Which leads me to think that "persistent" means that,
> if a single script makes multiple connect requests
> (with the same parameters), a single connection will
> be utilized. But if multiple instances of the script
> are active, each instance/process will be generating
> connections.
correct.
Apache::DBI doesn't POOL connections, it merely keeps them open so that each
child doesn't keep reopening a new connection each time connect is called.
~j
Re: Apache::DBI + persistent connections
Posted by Andrew Ho <an...@tellme.com>.
Wayne,
WI>It is my understanding that when the app is running
WI>and I look at the status under MySQL, that I should
WI>see only one connection. However, what I see is plenty
WI>of connections, as many as there were before I added
WI>Apache::DBI to the mix.
Apache is a forking server. There are x forked child processes serving
requests, each of which has a full Perl interpreter in it. What you are
seeing is likely one database connection per server child. Use "ps" and
count the number of Apache processes (or check /server-status) and that
number should match the number of MySQL connections.
The difference by using Apache::DBI is that those connections will stick
around, rather than being created/destroyed per HTTP request per child.
The number extant at any given time may be more or less than before, the
important thing is that they are persistent, saving resources on both
sides for connection establishing.
Humbly,
Andrew
----------------------------------------------------------------------
Andrew Ho http://www.tellme.com/ andrew@tellme.com
Engineer info@tellme.com Voice 650-930-9062
Tellme Networks, Inc. 1-800-555-TELL Fax 650-930-9101
----------------------------------------------------------------------