LoginSignup
12
2

More than 1 year has passed since last update.

NGINXがさばける秒間あたりのリクエスト数を計測してみた

Last updated at Posted at 2022-12-05

はじめに

NGINXのリクエスト処理性能が一定条件下でApacheを超えたとの検証結果を目にするようになりました。
NGINXが実際秒間どれぐらいリクエストを処理可能か、自分の貧弱な仮想環境で計測してみました。

関連用語のおさらい

NGINX(エンジンエックス)とは

Wikipediaから抜粋

  • フリーかつオープンソースなWebサーバである
  • 処理性能・高い並行性・メモリ使用量の小ささに焦点を当てて開発されている
  • HTTP, HTTPS, SMTP, POP3, IMAPのリバースプロキシの機能を持つ
  • ロードバランサ、HTTPキャッシュなどの機能も持つ

RPS(Requests per second) for HTTP Requests

1秒間に処理可能なHTTPリクエスト数を表します。
Webサーバーの処理能力を評価する指標として使用されます。

NGINXパフォーマンスのベンチマーク情報

NGINXの公式サイトに、2017年のブログ記事で若干古いですが、検証結果が記載されていました。

各種CPUコア数とリクエストサイズ(KB)による、RPS値が記載されていました。
CPUコアが1つのみで、リクエストサイズが10KBのケースを見ると、なんと54684を達成できています。

image.png

image.png

本当にここまでパフォーマンス出せるの?
と、少し半信半疑だったので、自分の仮想環境でも計測してみることに。

NGINXのリクエスト処理性能を計測してみました

検証環境

  • NGINX導入サーバー
    • Hyper-Vの仮想マシン
      • CPU: 2コア
      • メモリ: 2GB
  • OS
    • AlmaLinux 8.6
  • NGINX
    • Version: 1.22.0
    • NGINXの設定: デフォルトのまま(チューニング未実施の状態)

検証内容

  • ベンチマークツールを使用
    • wrk2を使用し負荷テスト
      • スレッド数: 2
      • 接続数: 10
  • HTTPリクエスト
    • HTTPS POSTを大量発行
    • ペイロードのサイズは2KB

計測結果

結論から、秒間3万~4万のリクエストさばけました。
仮想環境でここまでパフォーマンス出せるのはすごい!

wrk2を使って3回計測した結果を共有します。

  • 一回目
$ wrk2/wrk -s ./test.lua -t2 -c10 -d10s -R50000 https://NGINXサーバーのIPアドレス/index.htm
l
Running 10s test @ https://wrk2実行サーバーのIPアドレス/index.html
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   559.56ms  372.83ms   1.27s    57.32%
    Req/Sec       -nan      -nan   0.00      0.00%
  437416 requests in 10.00s, 770.06MB read
Requests/sec:  43742.32
Transfer/sec:     77.01MB
  • 二回目
$ wrk2/wrk -s ./test.lua -t2 -c10 -d10s -R50000 https://NGINXサーバーのIPアドレス/index.html
Running 10s test @ https://wrk2実行サーバーのIPアドレス/index.html
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.29s   859.93ms   3.01s    58.13%
    Req/Sec       -nan      -nan   0.00      0.00%
  353727 requests in 10.00s, 622.73MB read
Requests/sec:  35373.34
Transfer/sec:     62.27MB
  • 三回目
$ wrk2/wrk -s ./test.lua -t2 -c10 -d10s -R50000 https://NGINXサーバーのIPアドレス/index.html
Running 10s test @ https://wrk2実行サーバーのIPアドレス/index.html
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.57s     1.12s    4.09s    62.77%
    Req/Sec       -nan      -nan   0.00      0.00%
  296447 requests in 10.00s, 521.89MB read
Requests/sec:  29644.94
Transfer/sec:     52.19MB

おわりに

NGINXのリクエスト処理性能を計測してみました。
自分の貧弱な仮想環境でも、予想を上回るパフォーマンスを出せました。

12
2
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
12
2