node.js(+express)とClozureCL(+hunchentoot)の速度を比較してみた。

node.jsの環境
$ node -v
v0.2.4

node.jsのプログラム(関係する部分だけ)

app.get('/hello', function(req, res){
res.render('hello.ejs');
    });

単にファイルからデータを返すだけ。abの結果:

This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 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:            8765

Document Path:          /hello
Document Length:        50 bytes

Concurrency Level:      100
Time taken for tests:   15.646 seconds
Complete requests:      10000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      1710000 bytes
HTML transferred:       500000 bytes
Requests per second:    639.14 [#/sec] (mean)
Time per request:       156.46 [ms] (mean)
Time per request:       1.56 [ms] (mean, across all concurrent requests)
Transfer rate:          109.29 [Kbytes/sec] received

Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0     1    3.7      0    47
Processing:    23   151   41.2    144   421
Waiting:        3   151   41.2    144   420
Total:         23   152   40.7    144   421

Percentage of the requests served within a certain time (ms)
  50%    144
  66%    155
  75%    167
  80%    173
  90%    188
  95%    217
  98%    281
  99%    311
 100%    421 (last request)

hunchentootの環境は、Clozure CL+QuickLisp
$ ./sx86cl -V
Version 1.6-RC1-r14393  (SolarisX8632)
なぜかOpenSolarisで実行。上記のnode.jsとマシンは同じ。HTML-TEMPLATEを使って、node.jsの場合と同じような結果を返す。
abの結果:
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)

                                                                           
Server Software:        Hunchentoot
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /top
Document Length:        49 bytes

Concurrency Level:      100
Time taken for tests:   58.857 seconds
Complete requests:      10000
Failed requests:        0
Broken pipe errors:     0
Total transferred:      2160648 bytes
HTML transferred:       490147 bytes
Requests per second:    169.90 [#/sec] (mean)
Time per request:       588.57 [ms] (mean)
Time per request:       5.89 [ms] (mean, across all concurrent requests)
Transfer rate:          36.71 [Kbytes/sec] received

Connnection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   470 1838.8      0 23744
Processing:     2    36   22.7     31   248
Waiting:        0    36   22.7     31   248
Total:          2   506 1842.0     32 23783

Percentage of the requests served within a certain time (ms)
  50%     32
  66%     37
  75%     54
  80%     66
  90%    157
  95%   3419
  98%   3517
  99%  10173
 100%  23783 (last request)

データサイズは1バイト違うが、結果としてはnode.jsが約639req/secに対し、hunchentootが約170req/sec。この違いが大きいと見るかどうか。また、Percentage of the requests served within a certain timeの所を見ると、hunchentootの方が大部分のリクエストは早く処理しているようだ。ただし、異常に長くかかる場合があるので結果として遅い。接続時間の中央値を見てみると、node.jsが144msに対してhunchentootは32msと4倍以上高速だった。

感想としては、ClozureCLが想像以上に高速だった。大部分の場合においてnode.jsより速い。ただしGCの問題なのか、node.jsはリクエスト処理時間がほとんど一定しているが、hunchentootは相当なばらつきがある。このあたりが使用上問題になるとしたら、さらなる調査が必要と思われる。

Comments