low nodejs benchmarking with a simple server

27 views
Skip to first unread message

anymcoder

unread,
Aug 28, 2015, 10:42:42 PM8/28/15
to nodejs
Hi,
Just tried to benchmark a simple dns lookup server with NodeJS and the results turned me down. 
I've heard NodeJS is good when dealing with heavy IO bound application, but my server only serves 20 request/second. 
var express = require('express');
var dns = require('dns');
var app = express();
var PORT = process.env.PORT || 3000;

app.get('/', function(req, res) {
  var endpoint = "cloudflare.com";
  dns.resolve(endpoint, function(err, ips) {
    if (err) {
      res.send(JSON.stringify(err));
    } else {
      res.send(JSON.stringify(ips));
    }
  })
});

app.listen(PORT);

Benchmark result: (with NODE_ENV set to production, but that doesn't improve anything)

ab -n 1000 -c 300 http://slave:4000/

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 slave (be patient)
Completed 100 requests
Completed 200 requests
^[[C^[[ACompleted 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:        slave
Server Port:            4000

Document Path:          /
Document Length:        35 bytes

Concurrency Level:      300
Time taken for tests:   61.889 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      230000 bytes
HTML transferred:       35000 bytes
Requests per second:    16.16 [#/sec] (mean)
Time per request:       18566.552 [ms] (mean)
Time per request:       61.889 [ms] (mean, across all concurrent requests)
Transfer rate:          3.63 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      121  176 109.1    148    1226
Processing:   124 12160 14851.2   5131   61682
Waiting:      123 12160 14851.3   5131   61682
Total:        247 12337 14852.1   5309   61886

Percentage of the requests served within a certain time (ms)
  50%   5309
  66%  15018
  75%  18214
  80%  21360
  90%  38872
  95%  44911
  98%  54477
  99%  56875
 100%  61886 (longest request)

Ryan Schmidt

unread,
Aug 28, 2015, 11:57:45 PM8/28/15
to nod...@googlegroups.com

On Aug 27, 2015, at 3:09 AM, anymcoder wrote:

> Just tried to benchmark a simple dns lookup server with NodeJS and the results turned me down.
> I've heard NodeJS is good when dealing with heavy IO bound application, but my server only serves 20 request/second.

Are you simply starting that node program with "node program.js" (or whatever you called the file)? If so, you're only starting one process. If your computer has more than one CPU core, you can improve performance by starting additional processes, one per CPU core. Look up the built-in cluster module, which does this for you.

Also, note that you're not only testing DNS lookup here. You're also testing Express's web server performance. If you're interested in testing only DNS resolution speed, write a program that does only that, and does not use Express.


Reply all
Reply to author
Forward
0 new messages