Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

synchronous or asynchronus, that is the question

by mraful (Initiate)
on Aug 05, 2008 at 20:20 UTC ( [id://702479]=perlquestion: print w/replies, xml ) Need Help??

mraful has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I have been using Perl's SNMP interface into Net-SNMP for some time. But now, I wonder if I would gain any speed rewriting scripts that use SNMP asynchronously. Any thoughts?
  • Comment on synchronous or asynchronus, that is the question

Replies are listed 'Best First'.
Re: synchronous or asynchronus, that is the question
by pc88mxer (Vicar) on Aug 05, 2008 at 21:47 UTC
    Here's a simple way to tell... presumably you are sequentially querying some number of devices through SNMP and you are wondering if parallelizing the task would result in a speedup. Just divide up the list of devices into N groups and run N copies of your program (one for each group) at the same time to see if it has any effect on the total running time.

    Another metric you can look at is the wall-clock time versus the cpu-time of your program. If there is a large discrepancy, presumably it is due to waiting for replies from the devices you are querying.

Re: synchronous or asynchronus, that is the question
by rob_au (Abbot) on Aug 05, 2008 at 22:41 UTC
    The other thing that you should consider when seeking to improve timing on SNMP interactions is the manner of data that you are polling:

    • Are you unnecessarily iterating through SNMP tables or unwanted OIDs?
    • Does the device that you are monitoring supply the requisite information in separate, discrete OIDs?
    • Does the device that you are polling support SNMPv2 and in turn, GET-BULK, which is far more efficient for large set retrieval? (See RFC 1187 for details)

    These are questions that perhaps might be worth considering before making changes to your processes.


    perl -le "print unpack'N', pack'B32', '00000000000000000000001000000000'"

Re: synchronous or asynchronus, that is the question
by spivey49 (Monk) on Aug 05, 2008 at 21:34 UTC

    My opinion would be an ambiguous "that depends..". If you have a number of operations going on aside from the SNMP operations that do not depend on the SNMP operations I would imagine asynchronicity might give you some performance improvements, assuming of course you have available resources.

    Of course there are things to consider before going down this road, the scope of variables, file handles, etc come to mind. The Async or Proc::Fork documentation might give you an idea of what problems you may encounter.

    It might help to be a little more specific about what you are doing now and what you would like to accomplish

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://702479]
Approved by cormanaz
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-23 22:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found