Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^6: How to do parallel processing within mod_perl

by erroneousBollock (Curate)
on Nov 15, 2007 at 14:13 UTC ( [id://650978]=note: print w/replies, xml ) Need Help??


in reply to Re^5: How to do parallel processing within mod_perl
in thread How to do parallel processing within mod_perl

it doesn't seem to be easy to share a variable between parent and kids. I need this because the whole point is to collect search results from the children and I don't know how to get them back to the parent
Sounds like you want threads.

-David

Replies are listed 'Best First'.
Re^7: How to do parallel processing within mod_perl
by perrin (Chancellor) on Nov 15, 2007 at 14:57 UTC
    Threads are generally not advisable in situations like mod_perl or FastCGI with Perl, because they take up a lot more memory than a prefork approach. They can be useful for short-lived things, but usually forking is less resource-intensive due to the non-shared nature of Perl threads and copy-on-write savings for forking.
      Threads are generally not advisable in situations like mod_perl or FastCGI with Perl, because they take up a lot more memory than a prefork approach.
      It really depends how you use them.

      You can pre-thread just as easily as pre-fork. The threads needn't have anything you don't want loaded/cloned into them.

      If you maintain a pool of threads for this kind of task, simply feed them using Thread::Queue.

      They can be useful for short-lived things, but usually forking is less resource-intensive due to the non-shared nature of Perl threads and copy-on-write savings for forking.
      I think the benefits of COW for the Perl 5 interpreter are vastly overstated by most people. Ask BrowserUK what he thinks of the situation.

      -David

        I don't see how you could avoid having a lot loaded in a web situation. You can delay loading your own libraries, but things needed just to handle the persistent daemon itself (mod_perl in this case) have to be loaded.

        It's easy to see the benefits of COW for yourself. Move the libraries you use into a mod_perl startup phase and watch the free memory on your machine go up. It works.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-29 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found