node.js performance with zeromq vs. Python vs. Java node.js performance with zeromq vs. Python vs. Java python python

node.js performance with zeromq vs. Python vs. Java


You're using a third party C++ binding. As far as I understand it, the crossover between v8's "js-land" and bindings to v8 written in "c++ land", is very expensive. If you notice, some popular database bindings for node are implemented entirely in JS (although, partly I'm sure, because people don't want to compile things, but also because it has the potential to be very fast).

If I remember correctly, when Ryan Dahl was writing the Buffer objects for node, he noticed that they were actually a lot faster if he implemented them mostly in JS as opposed to C++. He ended up writing what he had to in C++, and did everything else in pure javascript.

So, I'm guessing part of the performance issue here has to do with that particular module being a c++ binding.

Judging node's performance based on a third party module is not a good medium for determining its speed or quality. You would do a lot better to benchmark node's native TCP interface.


"can you try to simulate logic from your Python example (e.i send next message only after receiving previous)?" – Andrey Sidorov Jul 11 at 6:24

I think that's part of it:

var zeromq = require("zeromq");var counter = 0;var startTime = new Date();var maxnum = 100000;var socket = zeromq.createSocket('req');socket.connect("tcp://127.0.0.1:5502");console.log("Connected to port 5502.");socket.send('Hello');socket.on('message',          function(data)          {              if (counter % 1000 == 0)              {                  console.log(data.toString('utf8'), counter);              }              if (counter >= maxnum)              {                  var endTime = new Date();                  console.log("Time: ", startTime, endTime);                  console.log("ms  : ", endTime - startTime);                  socket.close(); // or the process.exit(0) won't work.                  process.exit(0);              }              //console.log("Received: " + data);              counter += 1;          socket.send('Hello');          }     );socket.on('error', function(error) {    console.log("Error: "+error);});

This version doesn't exhibit the same increasing slowness as the previous, probably because it's not throwing as many requests as possible at the server and only counting responses like the previous version. It's about 1.5 times as slow as Python/Java as opposed to 5-10 times slower in the previous version.

Still not a stunning commendation of node for this purpose, but certainly a lot better than "abysmal".


This was a problem with the zeroMQ bindings of node.I don't know since when, but it is fixed and you get the same results as with the other languages.