去年は散々nodejsでコード書いてたわりにサーバーにデプロイしたことなかったのである。(分けあって開発してる時間が無くなったので)
ということで...このブログエンジンGhostはnodejsだからabコマンドでいじめてみることにした。

使ってる感じとしては非常に軽快に動いてる感じがする。が、計測してみるとどーんなもんなんだろう?

まずは、100同時接続...

$ ab -n 100 -c 100 http://192.168.x.x:x/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.x.x (be patient).....done


Server Software:        nginx/1.6.2
Server Hostname:        192.168.x.x
Server Port:            8011

Document Path:          /
Document Length:        15784 bytes

Concurrency Level:      100
Time taken for tests:   1.796 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      1606200 bytes
HTML transferred:       1578400 bytes
Requests per second:    55.67 [#/sec] (mean)
Time per request:       1796.404 [ms] (mean)
Time per request:       17.964 [ms] (mean, across all concurrent requests)
Transfer rate:          873.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    2   0.5      2       3
Processing:   736 1309 303.2   1343    1792
Waiting:      736 1309 303.2   1343    1792
Total:        738 1311 303.4   1345    1794

Percentage of the requests served within a certain time (ms)
  50%   1345
  66%   1491
  75%   1571
  80%   1618
  90%   1711
  95%   1754
  98%   1788
  99%   1794
 100%   1794 (longest request)

100同時接続ぐらいなら余裕な感じですな。

390同時接続あたりでもう限界...ただソケットとかnginxのワーカーとかチューニングすればもう少しいけそうな気もする。

$ ab -n 1000 -c 390 http://192.168.X.x:x/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.x.x (be patient)
apr_socket_recv: Connection reset by peer (104)

385同時接続はどうにかこうにか...

$ ab -n 1000 -c 385 http://192.168.x.x:x/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.x.x (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:        nginx/1.6.2
Server Hostname:        192.168.x.x
Server Port:            8011

Document Path:          /
Document Length:        15784 bytes

Concurrency Level:      385
Time taken for tests:   18.443 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      16062000 bytes
HTML transferred:       15784000 bytes
Requests per second:    54.22 [#/sec] (mean)
Time per request:       7100.516 [ms] (mean)
Time per request:       18.443 [ms] (mean, across all concurrent requests)
Transfer rate:          850.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   77 262.7      0    1000
Processing:  2770 6147 1190.3   6709    7552
Waiting:     2770 6147 1190.3   6709    7552
Total:       2778 6224 1273.9   6764    8551

Percentage of the requests served within a certain time (ms)
  50%   6764
  66%   7110
  75%   7137
  80%   7208
  90%   7351
  95%   7936
  98%   8319
  99%   8436
 100%   8551 (longest request)

さすがにCPU振り切るも、LoadAverageはさほどでもない。
Requests per second 的には約50リクエスト/秒の処理はできんのかな。

レンダリングしてるページも処理自体大したことはやっていないので、一概にnodejsは早いとはいえないんだろうけれど、遅いとは感じない結果ですね。

参考までにサーバーのスペック

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Duo CPU     E4500  @ 2.20GHz
stepping        : 13
microcode       : 0xa1
cpu MHz         : 1200.000
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm
bogomips        : 4388.98
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Duo CPU     E4500  @ 2.20GHz
stepping        : 13
microcode       : 0xa1
cpu MHz         : 1200.000
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm
bogomips        : 4388.98
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management: