|There's more than one way to do things|
Re: forking w/ mod_perl and DBIby andreychek (Parson)
|on Oct 13, 2001 at 05:18 UTC||Need Help??|
There was an excellent article on this very subject in Apache Today titled Improving mod_perl Driven Site's Performance -- Part VI: Forking and Executing Subprocesses from mod_perl.
In the very first paragraph, they point out, using fairly strong language:
It's desirable to avoid forking under mod_perl. Since when you do, you are forking the entire Apache server, lock, stock and barrel. Not only is your Perl code and Perl interpreter being duplicated, but so is mod_ssl, mod_rewrite, mod_log, mod_proxy, mod_speling (it's not a typo!) or whatever modules you have used in your server, all the core routines, etc.
They also point out that forking a process might be trying to do the "wrong thing". In the case that you want to send information to the browser, and then do some processing afterwards (sort of sounds like your case), that there is a cleanup handler. You can do that with something like:
In this case, this Apache process isn't freed up to handle another request, but it also isn't causing you the overhead of another fork.
However, they do say that there are some cases where forking is necessary, and take you through proper steps to do so.