in reply to prevelance of mod_perl

perrin has already mentioned FastCGI, so I'd just like to elaborate a bit on that option, as it might be an alternative to mod_perl, in case your application is essentially written like a regular CGI program, i.e. if it does not rely on specific mod_perl-only features. Performance-wise, FastCGI is comparable to mod_perl, as it's also running your program persistently (thus avoiding the overhead of loading the interpreter, modules, etc. on every request).

The main difference is that with FastCGI separate processes are being forked, which are communicating with the Apache process via sockets (both TCP and unix domain sockets are configurable). Due to this, FastCGI does not have any of mod_perl's powerful facilities to control virtually any aspect of the request cycle and Apache itself. In other words, it's responsible for content generation only — just like regular CGI.

This relative lack of power can be an advantage in this case, however, because mod_perl's power, with all its security implications, is essentially the justification for admins/providers to not support it, in particular in "old-style" shared hosting environments (i.e. those without a dedicated virtual machine for every client).

On the Apache side, you'd need one of the modules mod_fastcgi or mod_fcgi, and on the CGI script side, you can choose between various Perl modules, e.g. CGI::Fast, or FCGI (the latter is pretty old, but I've personally been happy with it so far). You'd use those Perl modules to put a thin wrapper around your CGI program, in order to have it run persistently, and to connect its I/O to the Apache process handling the request.

(In case you have many individual CGI scripts, it's probably a good idea to design things according to the "frontend controller pattern" (as Java/JSF people would say), i.e. one main FCGI process receiving all (or a group of) requests and delegating them to the appropriate handler routines. Otherwise, you may end up with quite a lot of persistently running processes — at least one for every separate CGI program...)

FastCGI may also be configured to work with Apache's suEXEC facilities, which - when done properly - is about as secure as regular CGI can get in a shared hosting environment (with users (ideally) not being able to mess with other user's processes and data).