Undertowちょっと使いにくい&個人的にあんまりおもしろいと思えず、勉強する気力が沸かないので、やっぱりSashimiの実装はAkkaにしようかなと思い直し、改めてベンチをとってみる。
ベンチ
特定のURLでGETすると固定のレスポンスを返却するという処理で比較する。
ちなみに、同様の比較はTechEmpowerのサイトで見れるが、なんかこの結果が自分は信用ならないので自分でやってみる。ソースが公開されてるので調べればいいんだけど、そこまでやるなら自分でやる。みたいな。
マシンはRyzen 1700。JVMパラメータはデフォルトのまま。
Undertow 1.4.12.Final
Gatling 3.0.0-RC1で1000ユーザーが1000回リクエストした場合。Undertowのバージョンちょっと古いかも。
.setIoThreads(200) .setWorkerThreads(400)
という感じの設定をしてます。覚えてないけど私のマシンで一番パフォーマンスが出た設定だった気がする。
結果は。
================================================================================ ---- Global Information -------------------------------------------------------- > request count 1000000 (OK=1000000 KO=0 ) > min response time 0 (OK=0 KO=- ) > max response time 292 (OK=292 KO=- ) > mean response time 13 (OK=13 KO=- ) > std deviation 14 (OK=14 KO=- ) > response time 50th percentile 9 (OK=9 KO=- ) > response time 75th percentile 14 (OK=14 KO=- ) > response time 95th percentile 34 (OK=34 KO=- ) > response time 99th percentile 77 (OK=77 KO=- ) > mean requests/sec 71428.571 (OK=71428.571 KO=- ) ---- Response Time Distribution ------------------------------------------------ > t < 800 ms 1000000 (100%) > 800 ms < t < 1200 ms 0 ( 0%) > t > 1200 ms 0 ( 0%) > failed 0 ( 0%) ================================================================================
うーん、早い。
Akka HTTP
デフォルトの設定で同じ負荷をかけてみた。
================================================================================
---- Global Information --------------------------------------------------------
request count 100000 (OK=99926 KO=74 )
min response time 0 (OK=0 KO=10000 )
max response time 10075 (OK=8030 KO=10075 )
mean response time 56 (OK=48 KO=10035 )
std deviation 552 (OK=481 KO=29 )
response time 50th percentile 3 (OK=3 KO=10041 )
response time 75th percentile 11 (OK=11 KO=10064 )
response time 95th percentile 40 (OK=40 KO=10070 )
response time 99th percentile 265 (OK=106 KO=10074 )
mean requests/sec 9090.909 (OK=9084.182 KO=6.727 )
---- Response Time Distribution ------------------------------------------------
t < 800 ms 99107 ( 99%)
800 ms < t < 1200 ms 29 ( 0%)
t > 1200 ms 790 ( 1%)
failed 74 ( 0%)
---- Errors --------------------------------------------------------------------
i.n.c.ConnectTimeoutException: connection timed out: localhost 74 (100.0%)
/127.0.0.1:9001
タイムアウトしてる。ドキュメントを参考にスレッドプールのスレッド数を400に増やしてみた。
================================================================================ ---- Global Information -------------------------------------------------------- > request count 100000 (OK=100000 KO=0 ) > min response time 0 (OK=0 KO=- ) > max response time 440 (OK=440 KO=- ) > mean response time 42 (OK=42 KO=- ) > std deviation 33 (OK=33 KO=- ) > response time 50th percentile 34 (OK=34 KO=- ) > response time 75th percentile 52 (OK=52 KO=- ) > response time 95th percentile 100 (OK=100 KO=- ) > response time 99th percentile 158 (OK=158 KO=- ) > mean requests/sec 16666.667 (OK=16666.667 KO=- ) ---- Response Time Distribution ------------------------------------------------ > t < 800 ms 100000 (100%) > 800 ms < t < 1200 ms 0 ( 0%) > t > 1200 ms 0 ( 0%) > failed 0 ( 0%) ================================================================================
Undertowよりもパフォーマンスが出た。数値的に何かがサチってる気がする。最終的に50万回リクエストして以下の数値を得た。
================================================================================ ---- Global Information -------------------------------------------------------- > request count 500000 (OK=500000 KO=0 ) > min response time 0 (OK=0 KO=- ) > max response time 390 (OK=390 KO=- ) > mean response time 24 (OK=24 KO=- ) > std deviation 21 (OK=21 KO=- ) > response time 50th percentile 18 (OK=18 KO=- ) > response time 75th percentile 31 (OK=31 KO=- ) > response time 95th percentile 66 (OK=66 KO=- ) > response time 99th percentile 102 (OK=102 KO=- ) > mean requests/sec 35714.286 (OK=35714.286 KO=- ) ---- Response Time Distribution ------------------------------------------------ > t < 800 ms 500000 (100%) > 800 ms < t < 1200 ms 0 ( 0%) > t > 1200 ms 0 ( 0%) > failed 0 ( 0%) ================================================================================
Undertowの方がスループットは高いものの、負荷が高くなるとレスポンスタムにばらつきが出てくる。一方でAkka-HTTPの方はスループットはUndertowの半分くらいなものの、レスポンスタイムのばらつきが少ない。っぽい。
いずれにせよ、レスポンスタイムが13msecと20msecというレベルの差なので、どちらも十分に早いと言えるだろう。それに、Akka-httpもパフォーマンスチューニングの余地がありそうだ。ということで、UndertowをやめてAkkaで行ってみることとする。