Skip to content
Ivaylo Ivanov edited this page Dec 28, 2015 · 4 revisions

Everyone knows benchmarks are a specific measurement and don’t account for all cases, and often, they are irrelevant in the real world. In most cases, if the speed of Node is not good enough, this is not because of Node itself, but because of you. However, it's good to see where are we compared to other frameworks in terms of performance.


Notes

  • OS - Ubuntu 14.04
  • CPU - Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz / 8 cores
  • RAM - 8GB
  • Node - 5.0.0
  • Test with - ApacheBench - 2 000 000 requests, 500 concurrency

Native implementation

Code

In index.js

require('http').createServer((req, res) => {
  res.end('pong');
}).listen(3333);
$ node .
$ ab -n 2000000 -c 500 http://localhost:3333
Results
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 200000 requests
Completed 400000 requests
Completed 600000 requests
Completed 800000 requests
Completed 1000000 requests
Completed 1200000 requests
Completed 1400000 requests
Completed 1600000 requests
Completed 1800000 requests
Completed 2000000 requests
Finished 2000000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            3333

Document Path:          /
Document Length:        4 bytes

Concurrency Level:      500
Time taken for tests:   103.317 seconds
Complete requests:      2000000
Failed requests:        0
Total transferred:      158000000 bytes
HTML transferred:       8000000 bytes
Requests per second:    19357.82 [#/sec] (mean)
Time per request:       25.829 [ms] (mean)
Time per request:       0.052 [ms] (mean, across all concurrent requests)
Transfer rate:          1493.43 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   12 130.7      0   31064
Processing:     5   13   9.7     12    1812
Waiting:        5   13   9.7     12    1812
Total:          5   26 132.5     12   31081

Percentage of the requests served within a certain time (ms)
  50%     12
  66%     12
  75%     15
  80%     16
  90%     17
  95%     18
  98%     20
  99%   1009
 100%  31081 (longest request)
Memory
$ preg node
3500
$ ps -p 3500 -O rss | gawk '{ sum += $2 }; END {print "Total memory usage =", sum/1024, "MB" ;};'
Total memory usage = 69.0938 MB

Esrol

Code
$ npm init
$ npm install esrol
$ node app
$ ab -n 2000000 -c 500 http://localhost:3333/ping
Results
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 200000 requests
Completed 400000 requests
Completed 600000 requests
Completed 800000 requests
Completed 1000000 requests
Completed 1200000 requests
Completed 1400000 requests
Completed 1600000 requests
Completed 1800000 requests
Completed 2000000 requests
Finished 2000000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            3333

Document Path:          /ping
Document Length:        4 bytes

Concurrency Level:      500
Time taken for tests:   116.953 seconds
Complete requests:      2000000
Failed requests:        0
Total transferred:      158000000 bytes
HTML transferred:       8000000 bytes
Requests per second:    17100.92 [#/sec] (mean)
Time per request:       29.238 [ms] (mean)
Time per request:       0.058 [ms] (mean, across all concurrent requests)
Transfer rate:          1319.31 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   14 128.0      0    7013
Processing:     4   15  16.4     14    1612
Waiting:        4   15  16.4     14    1612
Total:          4   29 131.2     14    7222

Percentage of the requests served within a certain time (ms)
  50%     14
  66%     14
  75%     17
  80%     18
  90%     18
  95%     19
  98%     25
  99%   1012
 100%   7222 (longest request)
Memory
$ preg node
16627
 $ ps -p 16627 -O rss | gawk '{ sum += $2 }; END {print "Total memory usage =", sum/1024, "MB" ;};'
Total memory usage = 82.8633 MB

Express

Code
$ npm init
$ npm install express

Version 4.13.3

In index.js

var express = require('express');
var app = express();

app.get('/ping', function (req, res) {
  res.end('pong'); // using end instead of send for better performance in this case
});

var server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});
$ node .
$ ab -n 2000000 -c 500 http://localhost:3000/ping
Results
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 200000 requests
Completed 400000 requests
Completed 600000 requests
Completed 800000 requests
Completed 1000000 requests
Completed 1200000 requests
Completed 1400000 requests
Completed 1600000 requests
Completed 1800000 requests
Completed 2000000 requests
Finished 2000000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            3000

Document Path:          /ping
Document Length:        4 bytes

Concurrency Level:      500
Time taken for tests:   152.810 seconds
Complete requests:      2000000
Failed requests:        0
Total transferred:      204000000 bytes
HTML transferred:       8000000 bytes
Requests per second:    13088.13 [#/sec] (mean)
Time per request:       38.203 [ms] (mean)
Time per request:       0.076 [ms] (mean, across all concurrent requests)
Transfer rate:          1303.70 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   18 150.7      0    7016
Processing:     8   20  11.0     19    1847
Waiting:        8   20  11.0     19    1847
Total:          9   38 152.7     19    7035

Percentage of the requests served within a certain time (ms)
  50%     19
  66%     19
  75%     22
  80%     22
  90%     23
  95%     24
  98%     28
  99%   1017
 100%   7035 (longest request)
Memory
$ preg node
16499
 $ ps -p 16499 -O rss | gawk '{ sum += $2 }; END {print "Total memory usage =", sum/1024, "MB" ;};'
Total memory usage = 79.8438 MB

Loopback

Code

Unfortunately, this is a little longer

$ npm install -g strongloop
$ slc loopback
$ slc --version

strongloop v6.0.0 (node v5.0.0)
├── strong-arc@1.8.5 (d01942e)
├── strong-build@2.1.0 (47dd24a)
├── strong-deploy@3.1.2 (be6180a)
├── strong-mesh-models@8.1.0 (62e539b)
├── strong-pm@5.1.0 (eb2f788)
├── strong-registry@1.1.5 (f46e58f)
├── strong-start@1.3.2 (1327018)
├─┬ strong-supervisor@3.3.1 (1e39220)
│ └── strong-agent@2.0.2 (4ea7ee9)
├── generator-loopback@1.13.0 (a884c0b)
├── node-inspector@0.7.4
└── nodefly-register@0.3.3

In server/boot/routes.js

module.exports = function(app) {
  app.get('/ping', function(req, res) {
    res.end('pong'); // using end instead of send for better performance in this case
  });
}
$ cd loopback
$ node .
$ ab -n 2000000 -c 500 http://localhost:3000/ping
Results
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 200000 requests
Completed 400000 requests
Completed 600000 requests
Completed 800000 requests
Completed 1000000 requests
Completed 1200000 requests
Completed 1400000 requests
Completed 1600000 requests
Completed 1800000 requests
Completed 2000000 requests
Finished 2000000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            3000

Document Path:          /ping
Document Length:        4 bytes

Concurrency Level:      500
Time taken for tests:   229.602 seconds
Complete requests:      2000000
Failed requests:        0
Total transferred:      312000000 bytes
HTML transferred:       8000000 bytes
Requests per second:    8710.71 [#/sec] (mean)
Time per request:       57.401 [ms] (mean)
Time per request:       0.115 [ms] (mean, across all concurrent requests)
Transfer rate:          1327.02 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   27 191.0      0   15034
Processing:    12   30  11.7     27    1842
Waiting:       12   30  11.7     27    1842
Total:         12   57 193.1     27   15060

Percentage of the requests served within a certain time (ms)
  50%     27
  66%     32
  75%     33
  80%     33
  90%     35
  95%     41
  98%   1025
  99%   1030
 100%  15060 (longest request)
Memory
$ preg node
16084
 $ ps -p 16084 -O rss | gawk '{ sum += $2 }; END {print "Total memory usage =", sum/1024, "MB" ;};'
Total memory usage = 135.914 MB

Clone this wiki locally