情報ソース: Amazon EC2 Auto Scaling
情報ソース: 起動設定
ひとまず基本的な Auto Scaling の設定をしてみる
- 成功 Launching a new EC2 instance: i-....... 2018 April 7 17:11:31 UTC+9 2018 April 7 17:12:04 UTC+9 説明:Launching a new EC2 instance: i-....... 原因:At 2018-04-07T08:11:29Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 1 to 2.
成功 Launching a new EC2 instance: i-.......... 2018 April 8 14:53:49 UTC+9 2018 April 8 14:54:23 UTC+9 説明:Launching a new EC2 instance: i-.......... 原因:At 2018-04-08T05:53:47Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 1 to 2.
- 成功 Terminating EC2 instance: i-........ 2018 April 8 14:39:24 UTC+9 2018 April 8 14:45:09 UTC+9 説明:Terminating EC2 instance: i-........ 原因:At 2018-04-08T05:39:24Z an instance was taken out of service in response to a ELB system health check failure. - 成功 Launching a new EC2 instance: i-........ 2018 April 8 14:39:58 UTC+9 2018 April 8 14:40:31 UTC+9 説明:Launching a new EC2 instance: i-........ 原因:At 2018-04-08T05:39:55Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 1 to 2.
yes >> /dev/null &
で CPU をガシガシ使うとスケールアウトしてくれて楽しいyes
を kill
して放置しておくとスケールインしてくれる様子が観察できる。- 成功 Launching a new EC2 instance: i-...... 2018 April 8 17:38:12 UTC+9 2018 April 8 17:43:45 UTC+9 説明:Launching a new EC2 instance: i-...... 原因:At 2018-04-08T08:37:37Z a monitor alarm TargetTracking-autoscaling-tutorial-group-AlarmHigh-284de7cd-eac1-4e75-a633-a2564cbdd6af in state ALARM triggered policy ScaleGroupSize changing the desired capacity from 2 to 3. At 2018-04-08T08:38:10Z an instance was star - 成功 Launching a new EC2 instance: i-...... 2018 April 8 17:46:57 UTC+9 2018 April 8 17:52:29 UTC+9 説明:Launching a new EC2 instance: i-...... 原因:At 2018-04-06T08:46:37Z a monitor alarm TargetTracking-autoscaling-tutorial-group-AlarmHigh-284de7cd-eac1-4e75-a633-a2564cbdd6af in state ALARM triggered policy ScaleGroupSize changing the desired capacity from 3 to 4. At 2018-04-08T08:46:55Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 3 to 4. - 成功 Terminating EC2 instance: i-...... 2018 April 8 18:05:54 UTC+9 2018 April 8 18:06:58 UTC+9 説明:Terminating EC2 instance: i-...... 原因:At 2018-04-08T09:05:25Z a monitor alarm TargetTracking-autoscaling-tutorial-group-AlarmLow-a1ff97f7-3f2e-477f-aae3-f23b558d5c6a in state ALARM triggered policy ScaleGroupSize changing the desired capacity from 4 to 3. At 2018-04-06T09:05:54Z an instance was taken out of service in response to a difference between desired and actual capacity, shrinking the capacity from 4 to 3. At 2018-04-08T09:05:54Z instance i-......... was selected for termination. - 成功 Terminating EC2 instance: i-...... 2018 April 8 18:06:25 UTC+9 2018 April 8 18:07:09 UTC+9 説明:Terminating EC2 instance: i-...... 原因:At 2018-04-08T09:06:24Z a monitor alarm TargetTracking-autoscaling-tutorial-group-AlarmLow-58c580d7-6a4b-44c0-805d-1c2b23f0580c in state ALARM triggered policy ScaleGroupSize changing the desired capacity from 3 to 2. At 2018-04-06T09:06:25Z an instance was taken out of service in response to a difference between desired and actual capacity, shrinking the capacity from 3 to 2. At 2018-04-08T09:06:25Z instance i-......... was selected for termination.
ちなみに Auto Scaling 設定値の各種上限は以下のような感じ #
ALB を利用しているときの各インスタンス配下の Apache の実際のアクセスログ一例は以下のようなもの
[maintainer@gomi-web01 ~]$ curl checkip.amazonaws.com 160.16.144.83 [maintainer@gomi-web01 ~]$ curl elb-autoscaling-example-1773061858.ap-northeast-1.elb.amazonaws.com -I HTTP/1.1 200 OK Date: Sun, 08 Apr 2018 06:31:13 GMT Content-Type: text/html; charset=UTF-8 Content-Length: 166 Connection: keep-alive Server: Apache/2.2.34 (Amazon) Last-Modified: Thu, 05 Apr 2018 02:32:11 GMT ETag: "605df-a6-56910bf30abcd" Accept-Ranges: bytes # 出力されたログ 172.31.33.34 - - [08/Apr/2018:06:31:13 +0000] "HEAD / HTTP/1.1" 200 - "-" "curl/7.29.0"
ALB 自体のアクセスログも出力可能だが、追加で設定は必要 #
時刻は +0000 で出力されている
sudo yum install httpd
で入れてなんの設定もしてない状態ELB のヘルスチェックログがたくさん出力されるので邪魔だったら適宜フィルタする
ウェブ界隈でエンジニアとして労働活動に励んでいる @gomi_ningen 個人のブログです