title: what is the expected performance of ZeroMQ?
body: <p>I am dabbling with process-to-process communication; the aim is to have worker processes that perform some computations and pass back the result to a controlling process. I installed <a href="https://github.com/JustinTulloss/zeromq.node" rel="nofollow noreferrer">zeromq.node</a> and set up a simple requester and responder in coffeescript.</p>
  
  <p>the requester:</p>
  
  <pre><code># requester.coffee
  
  zmq                       = require 'zmq'
  context                   = new zmq.Context()
  socket                    = zmq.socket 'req'
  
  socket.bind 'tcp://127.0.0.1:5555', ( error ) =&gt;
    throw error if error?
    console.log 'Requesting writer bound to port 5555'
    setInterval ( -&gt; socket.send 'helo world' ), 1
  
  
  response_count  = 0
  t0              = new Date() / 1000
  
  socket.on 'message', ( message ) -&gt;
    response_count += 1
    # x = message.toString 'utf-8'
    if response_count % 1000 is 0
      t1              = new Date() / 1000
      console.log "received #{ parseInt response_count / ( t1 - t0 ) + 0.5 } messages per second"
      response_count  = 0
      t0 = new Date() / 1000
  </code></pre>
  
  <p>The responder:</p>
  
  <pre><code># responder.coffee
  
  zmq                       = require 'zmq'
  context                   = new zmq.Context()
  socket                    = zmq.socket 'rep'
  
  socket.connect 'tcp://127.0.0.1:5555'
  console.log 'Responder bound to port 5555'
  process.stdin.resume()
  
  request_count   = 0
  t0              = new Date() / 1000
  
  socket.on 'message', ( message ) -&gt;
    request_count += 1
    # message = message.toString 'utf-8'
    # console.log message
    socket.send 'helo back'
    if request_count % 1000 is 0
      t1              = new Date() / 1000
      console.log "received #{ parseInt request_count / ( t1 - t0 ) + 0.5 } messages per second"
      request_count  = 0
      t0 = new Date() / 1000
  </code></pre>
  
  <p>Now when I run them in separate terminal windows on my ubuntu (11.10, 8GB, Intel Duo Core 3GHz, NodeJS 0.8.6) machine, I get the following output:</p>
  
  <pre><code>received 135 messages per second
  received 6369 messages per second
  received 6849 messages per second
  received 6944 messages per second
  received 7042 messages per second
  received 7143 messages per second
  received 5952 messages per second
  received 2967 messages per second
  received 914 messages per second
  received 912 messages per second
  received 928 messages per second
  received 919 messages per second
  received 947 messages per second
  received 906 messages per second
  received 918 messages per second
  received 929 messages per second
  received 916 messages per second
  received 917 messages per second
  received 916 messages per second
  received 928 messages per second
  </code></pre>
  
  <p>which (1) looks a little like there is some kind of saturation in the transmission channel after a few seconds; (2) feels not fast enough. according to <a href="http://mikehadlow.blogspot.de/2011/04/message-queue-shootout.html" rel="nofollow noreferrer">this benchmark</a>, I should be in the hundreds of thousands – not thousands – of messages per seconds, which is corrobrated by <a href="https://stackoverflow.com/questions/7921324/performance-comparison-between-zeromq-rabbitmq-and-apache-qpid">this discussion</a> ("ZeroMQ: It takes about 15 milli seconds to receive 10,000 messages"). </p>
  
  <p>I have also tried to to use a responder written in python 3 and got the exact same numbers. what's more, I wrote an alternative pair of scripts, where the master process would spawn a child process and communicate with it over stdout/stdin; I obtained around 750 messages per second (I couldn't see much variance when I increased message length), which is in like the same ballpark as the zeromq experiment.</p>
  
  <p>Are these numbers to be expected? What is the limiting factor here?</p>