KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've written a simple echo request/reply test for zeromq using node.js, Python, and Java. The code runs a loop of 100K requests. The platform is a 5yo MacBook Pro with 2 cores and 3G of RAM running Snow Leopard. node.js is consistently an order of magnitude slower than the other two platforms. Java: real 0m18.823s user 0m2.735s sys 0m6.042s Python: real 0m18.600s user 0m2.656s sys 0m5.857s node.js: real 3m19.034s user 2m43.460s sys 0m24.668s Interestingly, with Python and Java the client and server processes both use about half of a CPU. The client for node.js uses just about a full CPU and the server uses about 30% of a CPU. The client process also has an enormous number of page faults leading me to believe this is a memory issue. Also, at 10K requests node is only 3 times slower; it definitely slows down more the longer it runs. Here's the client code (note that the process.exit() line doesn't work, either, which is why I included an internal timer in addition to using the time command): var zeromq = require("zeromq"); var counter = 0; var startTime = new Date(); var maxnum = 10000; var socket = zeromq.createSocket('req'); socket.connect("tcp://127.0.0.1:5502"); console.log("Connected to port 5502."); function moo() { process.nextTick(function(){ socket.send('Hello'); if (counter < maxnum) { moo(); } }); } moo(); 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); process.exit(0);
Tags (comma-separated)
Save Edits
Cancel