Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Non-linear sub-routine launching

by tachyon (Chancellor)
on Apr 04, 2002 at 02:14 UTC ( [id://156541]=note: print w/replies, xml ) Need Help??


in reply to Non-linear sub-routine launching

You need fork or perhaps Parallel::ForkManager. If you go to Super Search and do a search for "fork" in the text you should find a few good examples. Here are some that I answered (I posted the code you want in one so it look at it as a treasure hunt!) One word of warning - spawning too many children too fast can saturate your network so don't write a Denial of Service hack on your own servers! A brief sleep before forking off each child is sound if you need to check a large network. Time::HiRes lets you sleep for a few tens of miliseconds:

my children are driving me crazy
FTP in background
PING taking too long
Forked off!
Parallel::ForkManager vs global variables
Help with waitpid and forking ?
Forked up

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
(MeowChow) Re2: Non-linear sub-routine launching
by MeowChow (Vicar) on Apr 04, 2002 at 03:24 UTC
      
    One word of warning - spawning too many children too fast can saturate your network so don't write a Denial of Service hack on your own servers!

    Are you sure? I seriously doubt that a server could fork off processes at a rate fast enough to saturate a decent network, assuming that all each process does is send normal pings once every few seconds.
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

      As you correctly note with a ping of 512 bits (32 bytes each way) I agree it would seem very unlikely that you could spawn processes fast enough to cause problems (even on a narrow 10Mbps network you expect a good 3Mbps before you get collision problems so you would need to spawn over 6,000 processes in a second if they all made a single ping). However once someone discovers the awesome power of fork() it is necessary to consider the potential problems. For instance if you used the default 4 x 32 byte ping instead of a single ping you only need 1,250 odd processes.... I have some vague recollection of bringing a network to a standstill with an ill considered forking script - admittedly each process was sending more data than a simple ping. Another consideration is how many processes you spawn. You certainly can potentially spawn enough to bring a server to a grinding halt.

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 15:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found