Caddy と nginx の性能軽くしらべてみた


Nginx から Caddy に変更という記事を見つけたので
https://coliss.com/articles/build-websites/operation/work/goodbye-nginx-hello-caddy.html

実際どうなのか軽く(10分程度)調べてみた。。この記事は個人環境で個人メモ用です。

環境

  • 12 コア OSX

  • Benchmark ツール側 1 コア, 250 コネクション

  • index.html 1190 bytes

caddy (58k / s) - CPU 全コア利用

  • version v2.2.1
  • caddy file-server -listen 127.0.0.1:8000 .
Running 10s test @ http://127.0.0.1:8000/
  1 threads and 250 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.65ms    1.29ms  19.97ms   82.94%
    Req/Sec    58.85k     3.32k   69.22k    70.00%
  Latency Distribution
     50%    2.28ms
     75%    2.96ms
     90%    4.34ms
     99%    7.41ms
  587734 requests in 10.05s, 789.75MB read
Requests/sec:  58510.01
Transfer/sec:     78.62MB
  • Go で書かれたから Go 的な速度です。

nginx (109k / s) - CPU 全コア利用

  • version nginx/1.19.2
Running 10s test @ http://127.0.0.1:8000/
  1 threads and 250 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.24ms  216.62us   6.19ms   88.34%
    Req/Sec   110.36k     6.79k  118.28k    89.00%
  Latency Distribution
     50%    2.20ms
     75%    2.29ms
     90%    2.44ms
     99%    3.05ms
  1096858 requests in 10.01s, 1.46GB read
Requests/sec: 109606.61
Transfer/sec:    149.37MB

おまけに自作サーバ (168k / s) - 1コア

Running 10s test @ http://127.0.0.1:8000/
  1 threads and 250 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   806.79us  123.52us   2.75ms   92.34%
    Req/Sec   169.68k     7.72k  176.36k    91.00%
  Latency Distribution
     50%  774.00us
     75%  817.00us
     90%    0.90ms
     99%    1.39ms
  1688150 requests in 10.01s, 2.23GB read
Requests/sec: 168675.49
Transfer/sec:    228.10MB
  • linux なら複数スレッドまたは複数プロセルで動かせば 1M / s 以上でるサーバなので比較対象じゃないが個人用のメモ

結論

  • Caddy は Go で書かれてるので Go の速度はでる
  • Nginx は設定次第でパフォマンスでる
  • 自作サーバ最高!