node.jsとPHPのパフォーマンスの比較

提供: Node.js/JavaScript入門
2014年8月31日 (日) 02:35時点におけるDaemon (トーク | 投稿記録)による版 (ページの作成:「node.jsのHTTPサーバとPHP, Apache + PHPにおける単純なパフォーマンスの比較を行いました。 __TOC__ == 概要 == 以下のHTTPサーバで...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索
スポンサーリンク

node.jsのHTTPサーバとPHP, Apache + PHPにおける単純なパフォーマンスの比較を行いました。

概要

以下のHTTPサーバでテストを行いました。

  • node.js http サーバ
  • PHP 単体のHTTP サーバ
  • Apache 2.4 + PHP (mod_php)

実行環境は、以下の通りです。

  • FreeBSD 10.0
  • VM 環境

測定に使ったコマンドは、Apache Bench (ab) です。

なお、並列数を200にすると ab が apr_socket_connect(): Connection reset by peer (54) となったので、100より先は、やってません。

ベンチマークの結果

ベンチマークの結果は、以下の通りです。

秒間のリクエスト数
並列 node.js php apache+php
10 2636 7080 4639
100 2463 7325 2978

以下 ab の実行結果

node.js

$ ab -n 100000 -c 10 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:
Server Hostname:        localhost
Server Port:            8080
 
Document Path:          /
Document Length:        12 bytes
 
Concurrency Level:      10
Time taken for tests:   37.936 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      11300000 bytes
HTML transferred:       1200000 bytes
Requests per second:    2636.01 [#/sec] (mean)
Time per request:       3.794 [ms] (mean)
Time per request:       0.379 [ms] (mean, across all concurrent requests)
Transfer rate:          290.89 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0      14
Processing:     0    4   1.9      4      85
Waiting:        0    4   1.9      4      85
Total:          1    4   2.0      4      86
 
Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      4
  80%      4
  90%      5
  95%      5
  98%      7
  99%     11
 100%     86 (longest request)

php

$ ab -n 100000 -c 10 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:
Server Hostname:        localhost
Server Port:            8080
 
Document Path:          /
Document Length:        12 bytes
 
Concurrency Level:      10
Time taken for tests:   14.124 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      12400000 bytes
HTML transferred:       1200000 bytes
Requests per second:    7079.97 [#/sec] (mean)
Time per request:       1.412 [ms] (mean)
Time per request:       0.141 [ms] (mean, across all concurrent requests)
Transfer rate:          857.34 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       5
Processing:     0    1   0.5      1      12
Waiting:        0    1   0.5      1      12
Total:          0    1   0.5      1      12
 
Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      2
  95%      3
  98%      3
  99%      4
 100%     12 (longest request)

apache 2.4 + php

$ ab -n 100000 -c 10 http://localhost/t/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:        Apache/2.4.9
Server Hostname:        localhost
Server Port:            80
 
Document Path:          /t/
Document Length:        12 bytes
 
Concurrency Level:      10
Time taken for tests:   21.556 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      22500000 bytes
HTML transferred:       1200000 bytes
Requests per second:    4639.06 [#/sec] (mean)
Time per request:       2.156 [ms] (mean)
Time per request:       0.216 [ms] (mean, across all concurrent requests)
Transfer rate:          1019.33 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0      26
Processing:     0    2   2.8      2     205
Waiting:        0    2   2.7      1     204
Total:          0    2   2.9      2     205
 
Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      2
  80%      2
  90%      3
  95%      4
  98%      5
  99%      6
 100%    205 (longest request)

node

$ ab -n 100000 -c 100 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:
Server Hostname:        localhost
Server Port:            8080
 
Document Path:          /
Document Length:        12 bytes
 
Concurrency Level:      100
Time taken for tests:   40.603 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      11300000 bytes
HTML transferred:       1200000 bytes
Requests per second:    2462.88 [#/sec] (mean)
Time per request:       40.603 [ms] (mean)
Time per request:       0.406 [ms] (mean, across all concurrent requests)
Transfer rate:          271.78 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0      30
Processing:    12   40   7.1     40     110
Waiting:       12   40   7.0     39     110
Total:         13   40   7.1     40     110
 
Percentage of the requests served within a certain time (ms)
  50%     40
  66%     41
  75%     41
  80%     43
  90%     48
  95%     53
  98%     58
  99%     63
 100%    110 (longest request)

php

$ ab -n 100000 -c 100 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:
Server Hostname:        localhost
Server Port:            8080
 
Document Path:          /
Document Length:        12 bytes
 
Concurrency Level:      100
Time taken for tests:   13.652 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      12400000 bytes
HTML transferred:       1200000 bytes
Requests per second:    7325.00 [#/sec] (mean)
Time per request:       13.652 [ms] (mean)
Time per request:       0.137 [ms] (mean, across all concurrent requests)
Transfer rate:          887.01 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0      13
Processing:     7   14   2.5     13      37
Waiting:        6   13   2.4     13      36
Total:         11   14   2.5     13      37
 
Percentage of the requests served within a certain time (ms)
  50%     13
  66%     13
  75%     13
  80%     13
  90%     14
  95%     18
  98%     22
  99%     28
 100%     37 (longest request)

apache 2.4 + php

$ ab -n 100000 -c 100 http://localhost/t/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
 
 
Server Software:        Apache/2.4.9
Server Hostname:        localhost
Server Port:            80
 
Document Path:          /t/
Document Length:        12 bytes
 
Concurrency Level:      100
Time taken for tests:   33.570 seconds
Complete requests:      100000
Failed requests:        0
Total transferred:      22500000 bytes
HTML transferred:       1200000 bytes
Requests per second:    2978.84 [#/sec] (mean)
Time per request:       33.570 [ms] (mean)
Time per request:       0.336 [ms] (mean, across all concurrent requests)
Transfer rate:          654.53 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   7.4      0     704
Processing:     6   33  36.9     30     830
Waiting:        2   30  31.7     29     829
Total:         10   33  37.8     30     830
 
Percentage of the requests served within a certain time (ms)
  50%     30
  66%     32
  75%     34
  80%     35
  90%     42
  95%     47
  98%     61
  99%     82
 100%    830 (longest request)

関連項目

テンプレート:nodejs




スポンサーリンク