ALB + VPC 対応版 Lambdaのメモ

# はじめに
AWS re:Invent 2018 でALBのバックエンドにLambdaがつかえるようになったという発表があったので色々と試したメモ。
API Gatewayを使った場合との性能比較なんかは今回はしてません。

ALB + VPC対応版 Lambdaでアクセスの増加に対してかかる時間をメモしてみました。

Lambdaのコードや設定は[ここ](https://aws.amazon.com/jp/blogs/news/lambda-functions-as-targets-for-application-load-balancers/)を参考にしています。

# tl;dr
- ヘルスチェックをするとLambdaに定期的にアクセスがいくため、実行可能なコンテナが常にある状態になっている
- 接続数が増えるとLambdaのコンテナを増やすコストが発生しているようで処理時間が増える
- 同じ条件で複数回アクセスするとアクセスを裁く用意ができているようで処理時間は短縮される
- Lambdaの同時実行数を超えるアクセスをおこなうと502 Bad Gatewayになる
- API Gatewayのように30秒制限はないのでその気になればLambdaのタイムアウト時間15分まで接続しっぱなしってのも可能（API設計としてありえないけど15分Lambdaに処理させて同期で結果を返すという芸当も可能）

# ざっくり計測

## 前提
- ALB、Lambdaは東京リージョンに作成
- LambdaはPython3.6、メモリ128MB、東京リージョンのデフォルトVPCに構築 
- ALBのヘルスチェックとLambdaの同時実行数はデフォルトのまま

## 同時接続1 総リクエスト数1 一回目
```
$ ab -c 1 -n 1 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      1
Time taken for tests:   0.075 seconds
Complete requests:      1
Failed requests:        0
Total transferred:      430 bytes
HTML transferred:       274 bytes
Requests per second:    13.37 [#/sec] (mean)
Time per request:       74.796 [ms] (mean)
Time per request:       74.796 [ms] (mean, across all concurrent requests)
Transfer rate:          5.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       17   17   0.0     17      17
Processing:    58   58   0.0     58      58
Waiting:       58   58   0.0     58      58
Total:         75   75   0.0     75      75
```

## 同時接続10 総リクエスト数10 一回目
```
$ ab -c 10 -n 10 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      10
Time taken for tests:   9.962 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      4300 bytes
HTML transferred:       2740 bytes
Requests per second:    1.00 [#/sec] (mean)
Time per request:       9961.548 [ms] (mean)
Time per request:       996.155 [ms] (mean, across all concurrent requests)
Transfer rate:          0.42 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   17   1.3     16      18
Processing:    41 6893 4714.7   9811    9945
Waiting:       41 6893 4714.6   9811    9945
Total:         56 6910 4714.7   9826    9961

Percentage of the requests served within a certain time (ms)
  50%   9826
  66%   9857
  75%   9909
  80%   9919
  90%   9961
  95%   9961
  98%   9961
  99%   9961
 100%   9961 (longest request)

## 同時接続10 総リクエスト数10 二回目
$ ab -c 10 -n 10 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      10
Time taken for tests:   0.264 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      4300 bytes
HTML transferred:       2740 bytes
Requests per second:    37.88 [#/sec] (mean)
Time per request:       263.963 [ms] (mean)
Time per request:       26.396 [ms] (mean, across all concurrent requests)
Transfer rate:          15.91 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   16   1.1     15      19
Processing:    39   68  62.4     53     245
Waiting:       39   68  62.4     53     245
Total:         55   84  63.5     68     264

Percentage of the requests served within a certain time (ms)
  50%     68
  66%     68
  75%     71
  80%     72
  90%    264
  95%    264
  98%    264
  99%    264
 100%    264 (longest request)
```

## 同時接続100 総リクエスト数100 一回目
```
$ ab -c 100 -n 100 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   10.240 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      43000 bytes
HTML transferred:       27400 bytes
Requests per second:    9.77 [#/sec] (mean)
Time per request:       10239.684 [ms] (mean)
Time per request:       102.397 [ms] (mean, across all concurrent requests)
Transfer rate:          4.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       22   31   3.9     33      37
Processing:    60 4872 4441.7   2279   10187
Waiting:       60 4872 4441.8   2279   10187
Total:         82 4903 4443.9   2303   10221

Percentage of the requests served within a certain time (ms)
  50%   2303
  66%   9357
  75%   9533
  80%   9609
  90%   9923
  95%  10087
  98%  10190
  99%  10221
 100%  10221 (longest request)
```

## 同時接続100 総リクエスト数100 二回目
```
$ ab -c 100 -n 100 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   9.495 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      43000 bytes
HTML transferred:       27400 bytes
Requests per second:    10.53 [#/sec] (mean)
Time per request:       9494.665 [ms] (mean)
Time per request:       94.947 [ms] (mean, across all concurrent requests)
Transfer rate:          4.42 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   26   5.0     27      33
Processing:   375  549 916.2    421    9479
Waiting:      375  549 916.3    420    9479
Total:        406  575 914.9    447    9494

Percentage of the requests served within a certain time (ms)
  50%    447
  66%    454
  75%    459
  80%    472
  90%    482
  95%   1132
  98%   1238
  99%   9494
 100%   9494 (longest request)
```

## 同時接続100 総リクエスト数100 三回目
```
$ ab -c 100 -n 100 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   0.187 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      43000 bytes
HTML transferred:       27400 bytes
Requests per second:    535.31 [#/sec] (mean)
Time per request:       186.808 [ms] (mean)
Time per request:       1.868 [ms] (mean, across all concurrent requests)
Transfer rate:          224.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   30  10.6     33      45
Processing:    56  108  19.5    116     147
Waiting:       56  108  19.5    116     147
Total:         71  139  25.4    143     179

Percentage of the requests served within a certain time (ms)
  50%    143
  66%    154
  75%    160
  80%    162
  90%    167
  95%    171
  98%    176
  99%    179
 100%    179 (longest request)
```

## 同時接続100 総リクエスト数1000 一回目
```
$ ab -c 100 -n 1000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   1.157 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      430000 bytes
HTML transferred:       274000 bytes
Requests per second:    864.10 [#/sec] (mean)
Time per request:       115.727 [ms] (mean)
Time per request:       1.157 [ms] (mean, across all concurrent requests)
Transfer rate:          362.85 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   34   6.9     35      55
Processing:    26   74  22.8     69     229
Waiting:       26   66  23.4     60     220
Total:         64  108  22.6    104     263

Percentage of the requests served within a certain time (ms)
  50%    104
  66%    109
  75%    113
  80%    116
  90%    129
  95%    154
  98%    186
  99%    197
 100%    263 (longest request)
```

## 同時接続100 総リクエスト数1000 二回目
```
$ ab -c 100 -n 1000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   1.432 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      430000 bytes
HTML transferred:       274000 bytes
Requests per second:    698.54 [#/sec] (mean)
Time per request:       143.156 [ms] (mean)
Time per request:       1.432 [ms] (mean, across all concurrent requests)
Transfer rate:          293.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   44  22.4     39     144
Processing:    35   90  34.3     77     190
Waiting:       35   79  31.2     66     174
Total:         61  134  41.8    118     250

Percentage of the requests served within a certain time (ms)
  50%    118
  66%    140
  75%    158
  80%    178
  90%    202
  95%    214
  98%    225
  99%    236
 100%    250 (longest request)
```

## 同時接続100 総リクエスト数10000 一回目
```
$ ab -c 100 -n 10000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   11.897 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4300000 bytes
HTML transferred:       2740000 bytes
Requests per second:    840.54 [#/sec] (mean)
Time per request:       118.971 [ms] (mean)
Time per request:       1.190 [ms] (mean, across all concurrent requests)
Transfer rate:          352.96 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       14   41  27.3     35    1201
Processing:    34   77  33.0     67     323
Waiting:       33   66  27.1     59     295
Total:         51  118  47.1    105    1282

Percentage of the requests served within a certain time (ms)
  50%    105
  66%    115
  75%    126
  80%    134
  90%    174
  95%    212
  98%    279
  99%    295
```

## 同時接続100 総リクエスト数10000 二回目
```
$ ab -c 100 -n 10000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      100
Time taken for tests:   10.961 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      4300000 bytes
HTML transferred:       2740000 bytes
Requests per second:    912.31 [#/sec] (mean)
Time per request:       109.612 [ms] (mean)
Time per request:       1.096 [ms] (mean, across all concurrent requests)
Transfer rate:          383.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       14   38  17.2     34     290
Processing:    36   71  27.3     65     377
Waiting:       34   61  21.4     57     355
Total:         65  109  37.7    101     479

Percentage of the requests served within a certain time (ms)
  50%    101
  66%    109
  75%    115
  80%    121
  90%    137
  95%    166
  98%    201
  99%    332
 100%    479 (longest request)
```

## 同時接続10000 総リクエスト数10000
```
$ ab -c 10000 -n 10000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
apr_socket_recv: Connection refused (111)

## 同時接続1000 総リクエスト数1000
$ ab -c 1000 -n 1000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      1000
Time taken for tests:   1.442 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      430000 bytes
HTML transferred:       274000 bytes
Requests per second:    693.25 [#/sec] (mean)
Time per request:       1442.481 [ms] (mean)
Time per request:       1.442 [ms] (mean, across all concurrent requests)
Transfer rate:          291.11 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       61  184  82.7    185     332
Processing:   340  735 191.1    780    1088
Waiting:      328  733 193.6    778    1088
Total:        402  919 256.0    945    1407

Percentage of the requests served within a certain time (ms)
  50%    945
  66%    999
  75%   1076
  80%   1100
  90%   1278
  95%   1329
  98%   1396
  99%   1401
 100%   1407 (longest request)
```

## 同時接続2000 総リクエスト数2000
```
$ ab -c 2000 -n 2000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
apr_socket_recv: Connection refused (111)

## 段階的にリクエストを増やす
$ ab -c 110 -n 110 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient).....done


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      110
Time taken for tests:   0.104 seconds
Complete requests:      110
Failed requests:        0
Total transferred:      47300 bytes
HTML transferred:       30140 bytes
Requests per second:    1056.39 [#/sec] (mean)
Time per request:       104.128 [ms] (mean)
Time per request:       0.947 [ms] (mean, across all concurrent requests)
Transfer rate:          443.60 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       15   27   9.0     28      51
Processing:    35   52   5.8     52      80
Waiting:       35   50   6.0     51      79
Total:         66   79   7.4     78      97

Percentage of the requests served within a certain time (ms)
  50%     78
  66%     81
  75%     84
  80%     85
  90%     91
  95%     92
  98%     95
  99%     96
 100%     97 (longest request)
```

```
$ ab -c 1100 -n 1100 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 110 requests
Completed 220 requests
Completed 330 requests
Completed 440 requests
Completed 550 requests
Completed 660 requests
Completed 770 requests
Completed 880 requests
Completed 990 requests
Completed 1100 requests
Finished 1100 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      1100
Time taken for tests:   1.141 seconds
Complete requests:      1100
Failed requests:        0
Total transferred:      473000 bytes
HTML transferred:       301400 bytes
Requests per second:    964.03 [#/sec] (mean)
Time per request:       1141.044 [ms] (mean)
Time per request:       1.037 [ms] (mean, across all concurrent requests)
Transfer rate:          404.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       58  114  49.5    108     215
Processing:   229  484 207.8    385    1008
Waiting:      215  473 212.9    373    1008
Total:        295  597 227.0    525    1103

Percentage of the requests served within a certain time (ms)
  50%    525
  66%    598
  75%    730
  80%    867
  90%    996
  95%   1069
  98%   1086
  99%   1089
 100%   1103 (longest request)
```

```
$ ab -c 1500 -n 1500 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 150 requests
Completed 300 requests
Completed 450 requests
Completed 600 requests
Completed 750 requests
Completed 900 requests
Completed 1050 requests
Completed 1200 requests
Completed 1350 requests
Completed 1500 requests
Finished 1500 requests


Server Software:        awselb/2.0
Server Hostname:        xxxxx.ap-northeast-1.elb.amazonaws.com
Server Port:            80

Document Path:          /
Document Length:        274 bytes

Concurrency Level:      1500
Time taken for tests:   1.760 seconds
Complete requests:      1500
Failed requests:        0
Total transferred:      645000 bytes
HTML transferred:       411000 bytes
Requests per second:    852.43 [#/sec] (mean)
Time per request:       1759.684 [ms] (mean)
Time per request:       1.173 [ms] (mean, across all concurrent requests)
Transfer rate:          357.95 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       72  190  98.4    165     367
Processing:   434 1052 246.4   1115    1351
Waiting:      422 1037 242.8   1095    1331
Total:        531 1242 281.7   1314    1668

Percentage of the requests served within a certain time (ms)
  50%   1314
  66%   1377
  75%   1399
  80%   1421
  90%   1575
  95%   1635
  98%   1659
  99%   1661
 100%   1668 (longest request)
```

```
$ ab -c 2000 -n 2000 http://xxxxx.ap-northeast-1.elb.amazonaws.com/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxx.ap-northeast-1.elb.amazonaws.com (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
apr_socket_recv: Connection refused (111)
Total of 633 requests completed
```

## Lambdaの実行時間が長い場合

Lambdaの実行時間内であれば正常に応答返す
ALBのアイドルタイムアウトは関係ない模様

#### Lambdaの最大実行時間を15分にして15分sleepした場合
```
$ time curl -v http://txxxxx.ap-northeast-1.elb.amazonaws.com/  0.01s user 0.01s system 0% cpu 5.259 total
~❯ time curl -v http://xxxxx.ap-northeast-1.elb.amazonaws.com/
~❯ time curl -v http://xxxxx.ap-northeast-1.elb.amazonaws.com/
~❯ time curl -v http://xxxxx.ap-northeast-1.elb.amazonaws.com/
*   Trying 54.65.143.128...
* TCP_NODELAY set
* Connected to xxxxx.ap-northeast-1.elb.amazonaws.com (54.65.143.128) port 80 (#0)
> GET / HTTP/1.1
> Host: xxxxx.ap-northeast-1.elb.amazonaws.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 502 Bad Gateway
< Server: awselb/2.0
< Date: Wed, 05 Dec 2018 07:27:59 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
<
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>
* Connection #0 to host xxxxx.ap-northeast-1.elb.amazonaws.com left intact
curl -v http://xxxxx.ap-northeast-1.elb.amazonaws.com/  0.02s user 0.03s system 0% cpu 15:00.44 total
```

#### Lambdaの最大実行時間を15分にして14分50秒sleepした場合
```
$ time curl -v http://xxxxx.ap-northeast-1.elb.amazonaws.com
* Rebuilt URL to: http://xxxxx.ap-northeast-1.elb.amazonaws.com/
*   Trying 54.65.11.214...
* TCP_NODELAY set
* Connected to xxxxx.ap-northeast-1.elb.amazonaws.com (54.65.11.214) port 80 (#0)
> GET / HTTP/1.1
> Host: xxxxx.ap-northeast-1.elb.amazonaws.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: awselb/2.0
< Date: Wed, 05 Dec 2018 07:57:31 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 297
< Connection: keep-alive
< body: ok
<
<html>
    <head>
    <title>Hello World!</title>
    <style>
    html, body {
       margin: 0; padding: 0;
       font-family: arial; font-weight: 700; font-size: 3em;
       text-align: center;
    }
    </style>
    </head>
       <body>
          <p>Hello World!</p>
      </body>
* Connection #0 to host xxxxx.ap-northeast-1.elb.amazonaws.com left intact
    </html>curl -v http://xxxxx.ap-northeast-1.elb.amazonaws.com  0.02s user 0.03s system 0% cpu 14:50.26 total
````