LoginSignup
20
19

More than 5 years have passed since last update.

nginx、apache のロードバランサ性能比較

Last updated at Posted at 2016-04-15

既に色々なところで書かれていますが、ロードバランサとしての性能について簡単な性能比較をしてみました。

apache と nginx の比較表とベンチマーク

下記の条件で比較を行いました。

  • ロードバランサ 1 台で バックエンドの web サーバ 2 台を負荷分散
  • web サーバは 2 台とも apache を使用
  • apache bench でそれぞれ10回計測し、その平均を算出。
  • テストに用いるページは Apache Test Page
  • Apache/2.2
  • nginx/1.8

Apache Benchでサクッと性能テスト

  1. apache
    apache

  2. nginx
    nginx

  3. ロードバランサなし(webサーバ直接)
    none

ベンチマーク

  • Requests per second [#/sec]
同時接続数 apache nginx web サーバ直接
100 2697.871 3463.774 4326.293
300 2485.409 3362.214 3002.440
500 2436.372 3286.834 1507.004
  • Time per request [ms]
同時接続数 apache nginx web サーバ直接
100 0.3734 0.2890 0.2326
300 0.4031 0.2978 0.3331
500 0.4107 0.3046 0.6636

機能的なこと

  • ディレクトリやファイルのパスでの振り分けは両方可能
  • オープンソースの WAF:ModSecurity を入れることも両方可能
  • SSL証明書の設定も両方可能
  • セッション維持(パーシステンス)をしたい場合、apache の場合はモジュール mod_proxy_balancer の stickysession、nginx の場合は標準で sticky が入っているようだが、サードパーティ製のモジュール nginx-sticky-module-ng を使用するという情報が多い。nginx の公式サイトに if is evil とあるので、if を使用するような設定には注意が必要

訂正:sticky が入っているのは商用版の nginx plus のようです。

NginxによるWebSocketの負荷分散
mod_proxy_balancerの設定、特にstickysessionについて
Module ngx_http_upstream_module
無料SSL/TLS証明書のLet's Encryptが正式版になったので自動更新を含めて試してみた
If Is Evil | NGINX

さいごに

  • 環境によって変わる可能性はあると思うが、やはり nginx の方が速そう。
  • 同時接続数が 100 ぐらいまでならロードバランサなしの方がよさそうだが、web サーバを隠蔽化するという目的もあるので入れておきたい。
  • if 非推奨も気になるが、使わなくても目的は達成できそう。
  • 機能的にはどちらも問題ない。
  • web サーバも nginx にすればもっと早くなりそう。

nginx、apache のロードバランサ性能比較
http://web.loft-net.co.jp/lofttecs/nginx_apache_load_balancer_performance/

20
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
19