- 追加された行はこの色です。
- 削除された行はこの色です。
[[AWSメモ]] > AWS LambdaでRDS接続時のパフォーマンス調査
* AWS LambdaでRDS接続時のパフォーマンス調査 [#a4462386]
#setlinebreak(on);
#contents
-- 関連
--- [[AWSメモ]]
--- [[AWS EC2上で Spring Bootアプリ起動]]
--- [[AWS LambdaからRDSに接続する]]
Aurora は MySQLベースらしいので、接続負荷もたいした事はないと踏んでいたが、やはりある程度は遅くなる事がわかった。
※現時点(2017/10時点)では。
ただ、この結果を「全然使えない」と考えるか、「この程度であれば許容範囲」と考えるのかは要件しだいだと思う。
※DBがOracle だった場合、この程度の差ではすまない。
以下の記事で作成した Lambda関数と、コネクションプール有りの Spring Boot で検証した結果では 2〜4倍近く(※)の差が出たが、
ケースによってはもっと差が出るかもしれないし、出ないかもしれない。
-- [[Spring BootでWebAPI作成]]
-- [[AWS EC2上で Spring Bootアプリ起動]]
-- [[AWS LambdaからRDSに接続する]]
** 環境など [#c494a339]
・Lambda側のメモリは 128M、タイムアウトは1分に設定。
・EC2のインスタンスタイプは micro。
・リクエストは ローカル端末の Apache Bench で発行。
・Spring Boot 側のコネクションプール数は MAX:10、Initial:5 とした。
・計測前に何回かのリクエストを発行してウォームーアップを実施。(特に Lambda は Warm start できるように)
・それぞれの処理は テーブルから 数件のデータを読み出して返却するだけ。(Lambda側は3件、spring側は4件にした)
** 結果 [#tf225928]
特に Lambda は結果にバラつきが目立ったが、平均値で見ると Lambda と Spring Boot(EC2) では 約2-4倍の差が出た。
#html(<div style="width:40%;display:inline-block">)
◆lambda に 10ユーザが1回ずつアクセス
#myterm(){{
Document Path: /example/lambda-rds-access1
Document Length: 731 bytes
Concurrency Level: 10
Time taken for tests: 0.410 seconds
Complete requests: 10
Failed requests: 0
Total transferred: 11750 bytes
HTML transferred: 7310 bytes
Requests per second: 24.36 [#/sec] (mean)
Time per request: 410.499 [ms] (mean)
Time per request: 41.050 [ms] (mean, across all concurrent requests)
Transfer rate: 27.95 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 144 163 18.1 169 190
Processing: 74 117 49.9 105 241
Waiting: 74 117 49.9 105 241
Total: 219 280 55.9 279 410
Percentage of the requests served within a certain time (ms)
50% 279
66% 296
75% 297
80% 319
90% 410
95% 410
98% 410
99% 410
100% 410 (longest request)
}}
#html(</div>)
#html(<div style="width:5%;display:inline-block">)
#html(</div>)
#html(<div style="width:40%;display:inline-block">)
◆spring に 10ユーザが1回ずつアクセス
#myterm(){{
Document Path: /api/books
Document Length: 585 bytes
Concurrency Level: 10
Time taken for tests: 0.181 seconds
Complete requests: 10
Failed requests: 0
Total transferred: 7040 bytes
HTML transferred: 5850 bytes
Requests per second: 55.14 [#/sec] (mean)
Time per request: 181.346 [ms] (mean)
Time per request: 18.135 [ms] (mean, across all concurrent requests)
Transfer rate: 37.91 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 93 102 3.4 103 104
Processing: 58 73 6.0 75 77
Waiting: 57 71 5.8 75 77
Total: 150 176 9.2 179 181
Percentage of the requests served within a certain time (ms)
50% 179
66% 179
75% 181
80% 181
90% 181
95% 181
98% 181
99% 181
100% 181 (longest request)
}}
#html(</div>)
#html(<div style="width:40%;display:inline-block">)
◆lambda に 10ユーザが10回ずつアクセス
#myterm(){{
Document Path: /example/lambda-rds-access1
Document Length: 569 bytes
Concurrency Level: 10
Time taken for tests: 3.743 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 101300 bytes
HTML transferred: 56900 bytes
Requests per second: 26.72 [#/sec] (mean)
Time per request: 374.308 [ms] (mean)
Time per request: 37.431 [ms] (mean, across all concurrent requests)
Transfer rate: 26.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 130 173 43.6 158 322
Processing: 71 185 117.1 149 563
Waiting: 71 185 117.1 148 563
Total: 224 359 154.7 312 839
Percentage of the requests served within a certain time (ms)
50% 312
66% 335
75% 359
80% 377
90% 788
95% 790
98% 807
99% 839
100% 839 (longest request)
}}
#html(</div>)
#html(<div style="width:5%;display:inline-block">)
#html(</div>)
#html(<div style="width:40%;display:inline-block">)
◆spring に 10ユーザが10回ずつアクセス
#myterm(){{
Document Path: /api/books
Document Length: 585 bytes
Concurrency Level: 10
Time taken for tests: 1.324 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 70400 bytes
HTML transferred: 58500 bytes
Requests per second: 75.54 [#/sec] (mean)
Time per request: 132.383 [ms] (mean)
Time per request: 13.238 [ms] (mean, across all concurrent requests)
Transfer rate: 51.93 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 29 56 26.6 48 135
Processing: 38 70 18.7 68 112
Waiting: 37 68 18.1 67 105
Total: 79 126 38.3 116 241
Percentage of the requests served within a certain time (ms)
50% 116
66% 124
75% 136
80% 142
90% 166
95% 230
98% 241
99% 241
100% 241 (longest request)
}}
#html(</div>)
#html(<div style="width:40%;display:inline-block">)
◆lambda に 100ユーザが10回ずつアクセス
#myterm(){{
Document Path: /example/lambda-rds-access1
Document Length: 731 bytes
Concurrency Level: 100
Time taken for tests: 14.781 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 1175000 bytes
HTML transferred: 731000 bytes
Requests per second: 67.65 [#/sec] (mean)
Time per request: 1478.142 [ms] (mean)
Time per request: 14.781 [ms] (mean, across all concurrent requests)
Transfer rate: 77.63 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 210 986 555.2 920 5907
Processing: 88 390 173.9 364 2383
Waiting: 87 380 171.0 357 2375
Total: 408 1376 585.8 1329 6320
Percentage of the requests served within a certain time (ms)
50% 1329
66% 1420
75% 1461
80% 1496
90% 2000
95% 2535
98% 3300
99% 3979
100% 6320 (longest request)
}}
#html(</div>)
#html(<div style="width:5%;display:inline-block">)
#html(</div>)
#html(<div style="width:40%;display:inline-block">)
◆spring に 100ユーザが10回ずつアクセス
#myterm(){{
Document Path: /api/books
Document Length: 585 bytes
Concurrency Level: 100
Time taken for tests: 7.620 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 704000 bytes
HTML transferred: 585000 bytes
Requests per second: 131.24 [#/sec] (mean)
Time per request: 761.955 [ms] (mean)
Time per request: 7.620 [ms] (mean, across all concurrent requests)
Transfer rate: 90.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 37 317 78.6 327 526
Processing: 86 395 213.3 353 1904
Waiting: 86 393 213.6 351 1902
Total: 127 712 233.3 690 2223
Percentage of the requests served within a certain time (ms)
50% 690
66% 729
75% 753
80% 761
90% 805
95% 1248
98% 1518
99% 1684
100% 2223 (longest request)
}}
#html(</div>)