[afnog] Scalable, Performance-Critical Web Application Architecture

Begumisa Gerald M beg_g at eahd.or.ug
Thu Sep 2 15:06:04 EAT 2004

    > If your daemon has any chance of blocking for a long period when
    > handling an individual request, then it will need to be either
    > forking or multithreaded, both of which add significant complexity,
    > especially if you want to have a 'pool' of available connections to
    > the Mysql database.

Yeah, locks and stuff I presume.

    > Option C: use 'fastcgi': see http://www.fastcgi.com/, and Apache
    > mod_fastcgi.

Not sure why I didn't take a closer look at this.

    > This gives you the best of both worlds. mod_fastcgi starts one or
    > more copies of your application (it can be dynamic or fixed). Each
    > CGI request is passed down a socket to one instance of your
    > application, which handles it and sends back the response. But
    > unlike CGI, your application is persistent; it has a central main
    > loop which handles one request, sends one reply, then goes back to
    > wait for another request. (A CGI would terminate after handling one
    > request). So, before the main loop, it can open one database
    > connection, and use it to handle each request.


    > #!/usr/local/bin/ruby require 'fcgi'
    > FCGI.each_cgi do |cgi|
    >   # Now we have a cgi object which we handle just like a normal CGI
    >   name = cgi.params['whoami'][0]
    >   if name
    >     puts cgi.header
    >     puts "<html>Hello, #{CGI.escapeHTML(name)}!</html>"
    >   else
    >     puts cgi.header
    >     puts "<html>Enter your name: <form method='POST'><input type='text' name='whoami'></form></html>"
    >   end
    > end
    > You can run this from the command-line for testing, as a standalone
    > CGI, or under mod_fastcgi, with no changes.

Thanks for the extensive help on this, as well as the installation
guidelines & examples.  Will keep you posted if I follow through an open
source framework for writing apps (in C/C++) with option B (multithreaded
daemon + connection pooling), not sure if any already exists though apart
from the one already integrated with SqWebmail...


More information about the afnog mailing list