Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: forking w/ mod_perl and DBI

by andreychek (Parson)
on Oct 13, 2001 at 05:18 UTC ( #118615=note: print w/replies, xml ) Need Help??

in reply to forking w/ mod_perl and DBI

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:
my $r = shift; $r->register_cleanup(\&do_stuff); sub do_cleanup{ #some clean-up code here };
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.

Good luck!

Replies are listed 'Best First'.
Re: Re: forking w/ mod_perl and DBI
by perrin (Chancellor) on Oct 14, 2001 at 08:56 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://118615]
[stevieb]: I found that win10 broke a C# library I was using for one project while enhancing tests for a Perl dist, which breaks other Perl dists, and I'm about to throw my hands up on berrybrew. win2k12 broke one thing, win10 breaks something...
[stevieb]: ...unrelated which requires replacing a lot of code and a whole lib. I'm about to go nix only ffs
[shmem]: stevieb: what you're doing sounds afwully complex. Too much for me this evening to provide brighter insight ;-)
[stevieb]: I don't even own a Windows computer. Both my girl and I have a laptop each with Linux. I'm supporting Windows in some of my projects and I can't even guage whether it's worth it or not.
[stevieb]: shmem It's something I desired to have years ago, which is why I took over berrybrew. Cross-platform build/test automation locally, or over the network Test::BrewBuild
[shmem]: sounds good.
[shmem]: but I'm crumbling smaller stones. remember...
[stevieb]: I'm working on it to fatten it up and make it more reliant so I can finalize my Raspberry Pi automated build system for that software :) It's all well and fun, until I try to make it work with Windows lol
[shmem]: "debugging a program is more difficult than to write it in the first place. If you code your program as smart as you are, you are, by definition, too dumb to debug it."

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2017-03-28 22:07 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (342 votes). Check out past polls.