[ Replies trimmed to just include groups. Don't want to spam Tim, Tom, or
Randal unnecessarily. ]

Max Calvo wrote:
> 
>    ***  From dbi-users - To unsubscribe, see the end of this message.  ***
>    *** DBI Home Page - http://www.symbolstone.org/technology/perl/DBI/ ***
> 
> Gentlemen;
> 
> I will be developing a web interface using MySQL or PostgreSQL. I have not
> decided on the database.
> 
> I need your experts opinions and advices on the platform to use. I have read
> a lot about Apache::Registry and CGI.pm. What is the best platform for
> performance?? I need fast look ups to the database and fast responces to the
> clients.

   Depending on your requirements both could work. When you say CGI daemon I
assume you mean FastCGI or something similar.

> It is my understanding that Apache::Registry allows me to run CGI scripts
> with out any modifications. Using this approach, Apache will load the script
> into memory at startup. Whenever there is a request for that script, it is
> already loaded and is executed on the fly with out the need to compile the
> code. Great!

   Is this a requirement? If so then Apache::Registry does let you do run
CGI scripts as-is, but beware that they must have been written using more
strict coding practices than is typical in CGI scripts--i.e. do a 'use
strict',
don't reference variables not passed into a subroutine, etc. FastCGI lets
you wrap a CGI script inside a while loop, essentially, so as long as you
don't allocate huge amounts of memory each loop this is also a reasonably
simple solution. 

> Is it also my understanding that a CGI script can be run as a deamon. Also,
> the script is loaded into memory and, if a request comes in, there is not
> need to compile the code since the script is already running.

   Yes. 

> Then, what is the best performance overall? Both approaches look very very
> similar.
> 
> Thank you very much
> 
> Max Calvo

   The two approaches are a little different. With mod_perl you end up with
a database connection for every child httpd process since db connections
can't be shared across processes. The FastCGI approach has you write code
like:

<connect to db>

while (FCGI::accept() >= 0) {
   <access db and produce html>
}

and have it run one interation of the loop per request. You can either start
up a fixed number of copies or have the number grow and shrink dynamically,
similar to the model that Apache itself uses. When I'm trying to decide which
technology to use considerations might be:

- Do I need to get inside the Apache process and install handlers, etc 
  (I'd lean towards mod_perl)
- Do I just need to do a simple database access that needs to be super fast
  and handle many hits per second (I'd lean towards fast_cgi)
- Is the number of simultaneous database connections an issue, say, for 
  licensing or anything (I'd lean towards fast_cgi)

   Anyway, there are lots more of these, and YMMV. I think that both
technologies
can complement each other...

- Bill

Reply via email to