On Wed, Nov 14, 2001 at 10:39:36AM -0500, Perrin Harkins wrote:
> > its definitely running under mod_perl. But imho the time it takes to
> > create a new cgi-object should not depend too much wheter its running
> > under mod_perl or not, cause the CGI-module is loaded before. (In fact
> > I load in httpd.conf using PerlModule-Directive)
> 
> If it was running under CGI, it would be compiling CGI.pm on each request,
> which I've seen take .3 seconds.  Taking that long just to create the new
> CGI instance seems unusual.  How did you time it?  Are you using
> Apache::DProf?
>

Wouldnt it be compiled at the use-statement ? I timed it using
module-internal loggingfunction which use time::hires.
 
> > This makes very much sense. Apache::DBI does not limit the number of
> > persistent connections. It just keeps all the connections open per
> > apache-process.
> 
> That should mean one connection per process if you're connecting with the
> same parameters every time.
> 

in my case it means up to 4 connections per process, cause in fact it
is not one module but 2 (input and output) and each needs to handle 2 different
connections.

> >  if (exists($ptr->{global}->{dbhandles}->{_some_id_string}))
> 
> You know that this is only for one process, right?  If you limit this cache
> to 20 connections, you may get hundreds of connections.
> 

yes, thats why I limit it to 1 or even 0.

> > I would prefer to handle this in a special pooling-module
> > like Apache::DBI is, but where one can specify a maximum number of
> > open connections and a timeout per connection (connection will be
> > terminated after it was not used a specified amount of time).
> 
> You can just set a timeout in your database server.  If a connection times
> out and then needs to be used, the ping will fail and Apache::DBI will
> re-connect.

thats an interesting idea. I experienced crashes on ping to dead
connections under DBD::Pg but this is worth to check.

> 
> > As soon
> > as I get IPC::Sharable to work I'll consider writing such a thingy.
> 
> You can't share database handles over IPC::Shareable, but you could share a
> global number tracking how many total database handles exist.  However, I
> think you'd be better off using Apache::DBI and limiting the number of
> Apache children to the number of connections your database can deal with.
> 

I hope to share databasehandles via IPC. One has to avoid that only
one process writes to a handle at the same time !! (hope I'm right
here) This would offer possibilities to create a pool of handles with
limited max. number and clientsided timeouts. If a process requests a
handle and there is one cached in the pool it will give this handle
back. Otherwise it will create a new handle or - if max. number is
reached - return 0. The calling application can then decide to print
an excuse due to the user 'cause we are so popular we cant server you
:)' or create and destroy a temporary handle to process the request.

This would be something I would actually prefer to Apache::DBI, but I
dont know if its possible, but I'll try.  Such a thing would be very
important, especially on slow servers with less ram, where Apache::DBI
opens to many connections in peak-times and leaves the system in a bad
condition ('to many open filehandles')

peter

ps: just if one is interested: today I was very happy to wear a helmet
when I crashed with my bike ;) At least I can write this lines after
my head touched the road. (well : it hurts in the arms when writing
fast ;)


-- 
mag. peter pilsl

phone: +43 676 3574035
fax  : +43 676 3546512
email: [EMAIL PROTECTED]
sms  : [EMAIL PROTECTED]

pgp-key available

Reply via email to