Skip to content

Instantly share code, notes, and snippets.

@geta6
Last active January 2, 2016 12:19
Show Gist options
  • Save geta6/8302143 to your computer and use it in GitHub Desktop.
Save geta6/8302143 to your computer and use it in GitHub Desktop.
node.js waf performances

precondition

node

$ node -v
v0.11.9

curl

$ curl -LI localhost:3000

ab

$ ab -n 1000 -c 100 http://127.0.0.1:3000/
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 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /
Document Length:        11 bytes

http

code

#!/usr/bin/env node

var http = require('http');
http.createServer(function(req, res) {
  res.writeHead(200, {
    'content-type': 'text/plain; charset=utf-8',
    'content-length': 11
  });
  res.end('hello world');
}).listen(3000);

header

HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
content-length: 11
Date: Tue, 07 Jan 2014 17:28:09 GMT
Connection: keep-alive

bench

Concurrency Level:      100
Time taken for tests:   0.208 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       11000 bytes
Requests per second:    4801.46 [#/sec] (mean)
Time per request:       20.827 [ms] (mean)
Time per request:       0.208 [ms] (mean, across all concurrent requests)
Transfer rate:          689.27 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.9      0       3
Processing:     6   20   8.2     20      43
Waiting:        6   19   8.2     19      43
Total:          9   20   8.3     20      45
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%     20
  66%     23
  75%     25
  80%     26
  90%     31
  95%     39
  98%     43
  99%     44
 100%     45 (longest request)

express

code

#!/usr/bin/env node

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

app.disable('x-powered-by');
app.use(function(req, res) {
  res.writeHead(200, {
    'content-type': 'text/plain; charset=utf-8',
    'content-length': 11
  });
  res.end('hello world');
});

var http = require('http');
http.createServer(app).listen(3000);

header

HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
content-length: 11
Date: Tue, 07 Jan 2014 17:29:32 GMT
Connection: keep-alive

bench

Concurrency Level:      100
Time taken for tests:   0.369 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       11000 bytes
Requests per second:    2708.34 [#/sec] (mean)
Time per request:       36.923 [ms] (mean)
Time per request:       0.369 [ms] (mean, across all concurrent requests)
Transfer rate:          388.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    5   7.3      3      46
Processing:    10   28   9.6     27      58
Waiting:        9   27   9.4     26      58
Total:         16   34   9.6     31      58

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     35
  75%     38
  80%     43
  90%     48
  95%     53
  98%     56
  99%     57
 100%     58 (longest request)

koa

code

#!/usr/bin/env node --harmony

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

app.use(function *(){
  this.response.remove('x-powered-by');
  this.body = 'hello world';
});

app.listen(3000);

header

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 11
Date: Tue, 07 Jan 2014 17:31:58 GMT
Connection: keep-alive

bench

Concurrency Level:      100
Time taken for tests:   0.263 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       11000 bytes
Requests per second:    3799.96 [#/sec] (mean)
Time per request:       26.316 [ms] (mean)
Time per request:       0.263 [ms] (mean, across all concurrent requests)
Transfer rate:          545.50 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.8      0       3
Processing:    15   25   6.2     23      52
Waiting:       15   25   6.2     23      52
Total:         15   25   6.4     24      53

Percentage of the requests served within a certain time (ms)
  50%     24
  66%     26
  75%     29
  80%     32
  90%     35
  95%     37
  98%     41
  99%     45
 100%     53 (longest request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment