Question

Update 1: @BagosGiAr tests with a quite similar configuration shows the cluster always should perform better. That is, there is some problem with my configuration, and I'm asking you to help me find out what could be.

Update 2: I'd like to go in deep of this problem. I've tested on a LiveCD* (Xubuntu 13.04), same node version. First thing is that, with Linux, performances are way better than Windows: -n 100000 -c 1000 gives me 6409.85 reqs/sec without cluster, 7215.74 reqs/sec with clustering. Windows build has definitely a lot of problems. Still I want to investigate why this is happening only to me, given that some people with a similar configuration perform better (and clustering performs well too).

*It should be noted that LiveCD uses a RAM filesystem, while in Windows I was using a fast SSD.

How this is possible? Shouldn't result be better with cluster module? Specs: Windows 7 x64, Dual Core P8700 2.53Ghz, 4GB RAM, Node.js 0.10.5, ab 2.3. Test command line is ab -n 10000 -c 1000 http://127.0.0.1:8080/.

var http = require('http');

http.createServer(function (req, res) {
    res.end('Hello World');
}).listen(8080);

Benchmark result ~ 2840.75 reqs/second:

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      1000
Time taken for tests:   3.520 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      870000 bytes
HTML transferred:       120000 bytes
Requests per second:    2840.75 [#/sec] (mean)
Time per request:       352.020 [ms] (mean)
Time per request:       0.352 [ms] (mean, across all concurrent requests)
Transfer rate:          241.35 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   7.1      0     505
Processing:    61  296 215.9    245    1262
Waiting:       31  217 216.7    174    1224
Total:         61  297 216.1    245    1262

Percentage of the requests served within a certain time (ms)
  50%    245
  66%    253
  75%    257
  80%    265
  90%    281
  95%    772
  98%   1245
  99%   1252
 100%   1262 (longest request)

With cluster module:

var cluster = require('cluster'),
    http = require('http'),
    numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
    // Fork workers
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }

    cluster.on('exit', function (worker, code, signal) {
        console.log('worker ' + worder.process.pid + ' died');
    });
} else {
    http.createServer(function (req, res) {
        res.end('Hello World');
    }).listen(8080);
}

... and with the same benchmark, result is worst: 849.64 reqs/sec:

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      1000
Time taken for tests:   11.770 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      870000 bytes
HTML transferred:       120000 bytes
Requests per second:    849.64 [#/sec] (mean)
Time per request:       1176.967 [ms] (mean)
Time per request:       1.177 [ms] (mean, across all concurrent requests)
Transfer rate:          72.19 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  21.3      0     509
Processing:    42 1085 362.4   1243    2274
Waiting:       27  685 409.8    673    1734
Total:         42 1086 362.7   1243    2275

Percentage of the requests served within a certain time (ms)
  50%   1243
  66%   1275
  75%   1286
  80%   1290
  90%   1334
  95%   1759
  98%   1772
  99%   1787
 100%   2275 (longest request)
Was it helpful?

Solution

You are not giving port number 8080 in your url address.

By default 80 is used when no port given.(8080 is default port used for Apache Tomcat). Maybe another server is listening on port 80 on your machine.

Update

Machine Specs : Intel(R) Xeon(R) CPU X5650 @ 2.67GHz, 64GB RAM,CentOS Linux release 6.0 (Final), node -v 0.8.8, ab -V 2.3

I think the problem in your case is that either Windows is not efficiently using the resources or CPU or RAM is being saturated when you run the benchmark.

Without cluster (used the same script)

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.232.5.169 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:
Server Hostname:        10.232.5.169
Server Port:            8000

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      1000
Time taken for tests:   3.196 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      860000 bytes
HTML transferred:       110000 bytes
Requests per second:    3129.14 [#/sec] (mean)
Time per request:       319.577 [ms] (mean)
Time per request:       0.320 [ms] (mean, across all concurrent requests)
Transfer rate:          262.80 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3  43.0      0    2999
Processing:     1   81  39.9     81     201
Waiting:        1   81  39.9     81     201
Total:         12   84  57.8     82    3000

Percentage of the requests served within a certain time (ms)
  50%     82
  66%    103
  75%    114
  80%    120
  90%    140
  95%    143
  98%    170
  99%    183
 100%   3000 (longest request)

With cluster (used your cluster script)

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.232.5.169 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:
Server Hostname:        10.232.5.169
Server Port:            8000

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      1000
Time taken for tests:   1.056 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      924672 bytes
HTML transferred:       118272 bytes
Requests per second:    9467.95 [#/sec] (mean)
Time per request:       105.620 [ms] (mean)
Time per request:       0.106 [ms] (mean, across all concurrent requests)
Transfer rate:          854.96 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       22   47  13.6     46      78
Processing:    23   52  13.8     52     102
Waiting:        5   22  17.6     17      83
Total:         77   99   5.8    100     142

Percentage of the requests served within a certain time (ms)
  50%    100
  66%    101
  75%    102
  80%    102
  90%    104
  95%    105
  98%    110
  99%    117
 100%    142 (longest request)

OTHER TIPS

I assume this is a result for not using the concurrent option of ApacheBench. as a default ab makes one request at the time, so the each request (in the cluster test) is served by one node and the rest of them stay idle. If you use the -c option you will benchmark the cluster mode of nodejs. eg
ab -n 10000 -c 4 -t 25 http://127.0.0.1:8083/
My result are:
Without cluster ab -n 10000 -t 25 http://127.0.0.1:8083/:

Server Software:
Server Hostname:        127.0.0.1
Server Port:            8083

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      1
Time taken for tests:   16.503 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      4300000 bytes
HTML transferred:       550000 bytes
Requests per second:    3029.66 [#/sec] (mean)
Time per request:       0.330 [ms] (mean)
Time per request:       0.330 [ms] (mean, across all concurrent requests)
Transfer rate:          254.44 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:     0    0   0.4      0      13
Waiting:        0    0   0.4      0      11
Total:          0    0   0.5      0      13

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      1
  80%      1
  90%      1
  95%      1
  98%      1
  99%      1
 100%     13 (longest request)

With cluster ab -n 10000 -c 4 -t 25 http://127.0.0.1:8083/:

Server Software:
Server Hostname:        127.0.0.1
Server Port:            8083

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      4
Time taken for tests:   8.935 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      4300000 bytes
HTML transferred:       550000 bytes
Requests per second:    5595.99 [#/sec] (mean)
Time per request:       0.715 [ms] (mean)
Time per request:       0.179 [ms] (mean, across all concurrent requests)
Transfer rate:          469.98 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:     0    1   0.6      1      17
Waiting:        0    0   0.6      0      17
Total:          0    1   0.6      1      18

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      1
  98%      1
  99%      1
 100%     18 (longest request)

Cheers!

EDIT I forgot my specifications; Windows 8x64, intel core i5-2430M @ 2.4GHz, 6GB RAM

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top