Quick benchmark checkpoint on Java and NodeJS

Java (my nodejs-inspired NIO/Netty based HTTP server):

Server server = Http.createServer();
server.setRequestListener(new RequestListener() {
    @Override
    public void service(ServerRequest request, ServerResponse response) {
        HashMap<String, String> headers = new HashMap<String, String>();
        headers.put("Content-Type", "text/html; charset=utf-8");
        headers.put("Content-Length", "47");
        response.writeHeader(200, headers);
        response.end("<html><body><h1>hüllo world</h1></body></html>");
    }
});
server.listen(8080);

Javascript:

http.createServer(function(req, res) {
    res.writeHead(200, {"Content-Length": "47",
                        "Content-Type": "text/html; charset=utf-8"});
    res.write("<html><body><h1>hüllo world</h1></body></html>");
    res.end();
}).listen(8080);

My quick “smoke” benchmark results using ab (MBA, 2 cores, 10.6.6, 4 GB, 2.13 GHz). First Java:

$ ab -k -n 2000 -c 200  http://localhost:8080/
Time taken for tests:   0.127 seconds
Complete requests:      2000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    2000
Total transferred:      305850 bytes
HTML transferred:       95833 bytes
Requests per second:    15693.29 [#/sec] (mean)
Time per request:       12.744 [ms] (mean)
Time per request:       0.064 [ms] (mean, across all concurrent requests)
Transfer rate:          2343.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.6      0      10
Processing:     1    5   2.9      5      16
Waiting:        1    5   2.9      5      16
Total:          1    6   3.4      5      19

and then nodejs (kriszyp/multi-node using node 0.2.5 on 2 nodes):

$ ab -k -n 2000 -c 200 http://127.0.0.1:8080/
Time taken for tests:   0.225 seconds
Complete requests:      2000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    2000
Total transferred:      300150 bytes
HTML transferred:       94047 bytes
Requests per second:    8876.38 [#/sec] (mean)
Time per request:       22.532 [ms] (mean)
Time per request:       0.113 [ms] (mean, across all concurrent requests)
Transfer rate:          1300.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.9      0      11
Processing:     0   18   3.7     18      28
Waiting:        0   18   3.7     18      28
Total:          0   18   4.5     18      39

So far, so good. I can now start adding Rhino.

2 Comments

  • Domenico Renna
    May 18, 2012 - 10:49 am | Permalink

    Can you repat this banchmark using siege instead of ab, I’m intresting to the difference

  • Simon
    June 23, 2012 - 2:51 am | Permalink

    Hmm, you don’t appear to have posted sufficient info to make a fair comparison with other technologies. Did you run other servers and if so with what tuning conditions for things like thread count?

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>