nginxとApacheの性能比較

当ページのリンクには広告が含まれています。

スポンサーリンク

Linuxサーバー、ここではVPS(Virtual Private Server)上に構築したnginxとApacheの性能比較を実施したので、レポートします。

性能比較方法

abコマンド(Apache Bench)を利用して、nginxとApacheの性能比較を行いました。Macのターミナルから下記abコマンド(aaa.bbb.ccc.dddはIPアドレス)を実行し、ネットワークを介してVPSに100リクエスト(10の同時接続を10回)送り、その処理能力を比較しました。

$ ab -c 100 -n 10 http://aaa.bbb.ccc.ddd/

性能比較したVPS環境

ServersMan@VPSの最安プラン“Entry”
・CentOS 6.3 64bit
・nginx 1.2.7
・Apache 2.2.15
nginx、Apacheともにyumで初期インストールした状態です(設定ファイル等は何もいじっていません)。

» nginxをCentOSにインストールする方法はこちら

nginxとApacheの性能比較した結果

1秒間に何回のリクエストを処理したか(Requests per second:)を比較するとnginx:24.07に対し、Apache:16.34でした。単純に考察するとApacheよりもnginxの方が1.47倍処理能力が高い結果になりました。

nginx・Apacheともに設定等をいじることでリクエスト処理能力が変わってくるとは思いますが、デフォルト(初期インストール状態)ではnginxのほうが処理能力が高いようですね。噂通りの速さですね。

ネットワークを介して性能比較を実施したので、ネットワークの状況に依るのではないか?と思い、何度か同じようにコマンドを実行しましたが、リクエスト処理能力は同程度でした。

nginxの全結果

nginxに対して実行したabコマンドの全結果です。

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

Benchmarking aaa.bbb.ccc.ddd (be patient).....done


Server Software:        nginx/1.2.7
Server Hostname:        aaa.bbb.ccc.ddd
Server Port:            80

Document Path:          /
Document Length:        612 bytes

Concurrency Level:      10
Time taken for tests:   4.155 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      82200 bytes
HTML transferred:       61200 bytes
Requests per second:    24.07 [#/sec] (mean)
Time per request:       415.518 [ms] (mean)
Time per request:       41.552 [ms] (mean, across all concurrent requests)
Transfer rate:          19.32 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       36  366 240.7    395    1599
Processing:     0    7  15.3      0      50
Waiting:        0    5  14.6      0      50
Total:         72  372 236.1    395    1599

Percentage of the requests served within a certain time (ms)
  50%    395
  66%    446
  75%    483
  80%    498
  90%    589
  95%    660
  98%   1339
  99%   1599
 100%   1599 (longest request)

Apacheの結果

Apacheに対して実行したabコマンドの全結果です。

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

Benchmarking aaa.bbb.ccc.ddd (be patient).....done


Server Software:        Apache/2.2.15
Server Hostname:        aaa.bbb.ccc.ddd
Server Port:            80

Document Path:          /
Document Length:        5039 bytes

Concurrency Level:      10
Time taken for tests:   6.122 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      102
Total transferred:      531709 bytes
HTML transferred:       511513 bytes
Requests per second:    16.34 [#/sec] (mean)
Time per request:       612.171 [ms] (mean)
Time per request:       61.217 [ms] (mean, across all concurrent requests)
Transfer rate:          84.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       38  356 368.0    329    2825
Processing:     0  236 789.2      0    2899
Waiting:        0  207 742.4      0    2898
Total:        102  592 780.1    343    2937

Percentage of the requests served within a certain time (ms)
  50%    343
  66%    373
  75%    382
  80%    402
  90%   2697
  95%   2936
  98%   2937
  99%   2937
 100%   2937 (longest request)

以上で、nginxとApacheの性能比較は終了です。

nginx の人気記事

  1. sudoユーザーを追加する方法
  2. Linux設定マニュアル
  3. Windows10上でLinuxを実行(Linux用Windowsサブシステム)
  4. Windows10にLinux(Ubuntu)をインストール

関連記事(一部広告含む)