Node.js Server Cluster test Benchmark using AB(Apache Banchmark)
server code(no cluster)var http = require("http"); http.createServer(function(request, response) { var s = 64*1024; var buf = new Buffer(s); for(var i=0;i<buf.length;i++){ buf[i]=100; } //console.log("Request for: " + request.url); response.writeHead(200); response.end(buf); }).listen(3000);output
==========================================
==========================================
ab result
Server Software: | |||
---|---|---|---|
Server Hostname: | localhost | ||
Server Port: | 3000 | ||
Document Path: | / | ||
Document Length: | 65536 bytes | ||
Concurrency Level: | 200 | ||
Time taken for tests: | 17.481 seconds | ||
Complete requests: | 10000 | ||
Failed requests: | 0 | ||
Total transferred: | 656110000 bytes | ||
HTML transferred: | 655360000 bytes | ||
Requests per second: | 572058.72 | ||
Transfer rate: | 37533344.59 kb/s received | ||
Connnection Times (ms) | |||
min | avg | max | |
Connect: | 0 | 0 | 15 |
Processing: | 40 | 346 | 826 |
Total: | 40 | 346 | 841 |
server code(cluster)
var cluster = require("cluster"); var http = require("http"); var numCPUs = require("os").cpus().length; if (cluster.isMaster) { for (var i = 0; i < numCPUs; i++) { cluster.fork(); } } else { var s = 64*1024; var buf = new Buffer(s); for(var i=0;i<buf.length;i++){ buf[i]=100; } http.createServer(function(request, response) { //console.log("Request for: " + request.url); response.writeHead(200); response.end(buf); }).listen(3000); }
output
======================================
======================================
ab result
Server Software: | |||
---|---|---|---|
Server Hostname: | localhost | ||
Server Port: | 3000 | ||
Document Path: | / | ||
Document Length: | 65536 bytes | ||
Concurrency Level: | 200 | ||
Time taken for tests: | 19.403 seconds | ||
Complete requests: | 10000 | ||
Failed requests: | 0 | ||
Total transferred: | 656110000 bytes | ||
HTML transferred: | 655360000 bytes | ||
Requests per second: | 515385.73 | ||
Transfer rate: | 33814973.33 kb/s received | ||
Connnection Times (ms) | |||
min | avg | max | |
Connect: | 0 | 0 | 13 |
Processing: | 70 | 385 | 809 |
Total: | 70 | 385 | 822 |