Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Structure (timer) calling a method regularly in case of inactivity

by Joost (Canon)
on Jul 27, 2007 at 23:03 UTC ( [id://629222]=note: print w/replies, xml ) Need Help??


in reply to Structure (timer) calling a method regularly in case of inactivity

Just how many servers (switches) are we talking about?

If it's a fairly small number and/or your program is reasonably memory efficient, you could fork a separate process for each server. That would probably simplify the timeout issues, since you only need to deal with one connection and timer per process.

If you have many servers and you can't afford to fork a process for each, my approach would be to use IO::Select with non-blocking IO. It's low-level but very efficient if done right. On the other hand, it's not a very easy technique if you're not familiar with select() and/or perl.

Perl threads are IMHO completely useless for this kind of thing, since you can probably not share enough data to make it significantly more efficient than just fork()ing more processes.

  • Comment on Re: Structure (timer) calling a method regularly in case of inactivity

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2025-03-25 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (65 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.