Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: spawning Perl scripts

by abell (Chaplain)
on Mar 28, 2003 at 17:29 UTC ( [id://246516]=note: print w/replies, xml ) Need Help??


in reply to spawning Perl scripts

To add a little side-note to the other Venerable Monks' comments, beware that if you fork a perl program executed by mod_perl, you are forking all of the apache process.

If you use exec, the process is substituted by the new perl interpreter, so it doesn't really matter, but should you be tempted to just do the new script, you have to take into consideration the cost of the apache+mod_perl process, which will be kept alive until the new script exits.

Cheers

Antonio

The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket

Replies are listed 'Best First'.
Re: Re: spawning Perl scripts
by jasonk (Parson) on Mar 28, 2003 at 17:58 UTC

    On a decent OS, fork doesn't actually copy the entire process, it creates a new process table entry, with process id and all the associated information, but the actual memory pages that contain the memory contents of the two processes are shared until one of the processes attempts to change that memory (a procedure known as copy-on-write). So the actual overhead of forking is minimal, and you won't get multiple copies of even a small portion of the entire apache process, unless one of the processes manages to make a change to it's memory in that tiny amount of time between the fork() and exec() calls, and even then you will only get short-lived copies of the memory pages that actually changed, not the entire process.


    We're not surrounded, we're in a target-rich environment!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246516]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found