Reputation: 1424
I'm experimenting with node.js and facing a strange issue with throughput. Basically, I have this code to create a simple HTTP server (on a VM with 4GB RAM and 4 vCPUs, running Ubuntu 16.04 and node.js v6.3.1):
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello');
}).listen(8888);
I'm running it with node server.js
to start the HTTP server, and then I'm trying to load-test it from a different machine using Apache Bench:
ab -l -r -n 100 -c 50 -k http://server-ip:8888/
However, no matter what the number & concurrency of requests (n/c values) I test with, the benchmark results always show the 'requests per second' to be under 5/sec, which is too low for a scalable framework like node.js and a simple HTTP server as above.
So I'm assuming that it's something to do with configuration, settings etc. Anyone has any ideas on how to increase the throughput in this case?!
Update: I've come across people who are getting high-throughput with near-identical base code running on cloud VMs:
http://zgadzaj.com/benchmarking-nodejs-basic-performance-tests-against-apache-php
https://www.jayway.com/2015/04/13/600k-concurrent-websocket-connections-on-aws-using-node-js/
http://blog.yld.io/2016/02/08/squeeze-the-juice-out-of-node/
http://blog.caustik.com/2012/08/19/node-js-w1m-concurrent-connections/
Upvotes: 0
Views: 887
Reputation: 350
Always try to confirm that the error is not caused by external variables, always go from the furthest to the closest. And take care that you cannot run a benchmark in the same machine as the server tested, because your benchmark tool resources will sum with the tested server if not in software, at least sure in hardware. Even with virtualization.
Good luck with NodeJS!
Upvotes: 0
Reputation: 1424
The problem was Windows 8.1 (load-test machine I first tried) limiting the tcp connections, hence affecting Apache Bench (ab) concurrency. On a different Ubuntu machine, it works fine and the throughput results are much better.
Upvotes: 1