[awsマイスターシリーズ]amazon elastic load balancing (elb)

55
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc. AWSマイスターシリーズ Elastic Load Balancing 2013.6.12 アマゾンデータサービスジャパン株式会社 ソリューション アーキテクト 舟崎 健治 平山 毅 安川 健太

Upload: amazon-web-services-japan

Post on 01-Dec-2014

25.972 views

Category:

Business


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

AWSマイスターシリーズ Elastic Load Balancing

2013.6.12

アマゾンデータサービスジャパン株式会社

ソリューション アーキテクト

舟崎 健治 平山 毅 安川 健太

Page 2: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

2

Agenda

2. ELB各種機能詳細とTips

5. まとめ

1. ELB基本編

3. ELBと各種サービスの連携

4. ELB負荷試験時のTips

Page 3: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

3

1. ELB基本編

Page 4: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

4

ELB: Elastic Load Balancingとは?

AWSクラウド上のロードバランシングサービス

ELBの特徴 負荷分散 : リクエストを複数のバックエンドのサーバーに分散

スケーラブル: ELB自体が負荷に応じてキャパシティを増減

高い可用性: 複数のAvailability Zoneに跨がるトラフィック分配

ヘルスチェック機能: 健全なEC2にのみトラフィックを分配

安価な従量課金: 従量課金で利用可能

AWS Management Console、API、コマンドラインツール、SDKでコントロール可

Page 5: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

5

ELBの概念図

AZ a AZ b

ELB

ユーザー

クライアント

Web コンソール

開発者

HTTP / HTTPS / TCP / SSL

HTTP / HTTPS / TCP / SSL

EC2 EC2

Page 6: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

6

ELBによる負荷分散

バックエンドのEC2インスタンスのリクエスト数や コネクション数を基に負荷分散

コネクション数・リクエスト数が均等になるよう割り振る

サポートしているプロトコル (L7)HTTP, HTTPS (L4)TCP, SSL

Page 7: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

7

ELBのスケーリング

ELBは負荷の増減に応じて自動でスケール (キャパシティを自動で増加する)

注:ELBがスケールするときには、IPアドレスが変化

• ELBへアクセスするときには必ずDNS名で!

• 独自ドメインに割り当てる際はCNAMEにて

Page 8: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

8

複数AZ利用による高い可用性

AZ A

AZ B ELB エンド ポイント

DNS ラウンド ロビン ELBによる

負荷分散

ELBによる 負荷分散

AZ配下の EC2台数はAZ間で均等化を

推奨

2段階で負荷分散 • DNSラウンドロビンによるAZ間振り分け

• AZ内ではコネクション数などを見ながら負荷分散

Internet Internet Gateway

Page 9: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

9

バックエンドのヘルスチェック

ELBは指定した設定に基づき、バックエンドのインスタンスのヘルスチェックを行う • Pingプロトコル:例:HTTP • Pingポート:例 80番 • Pingパス(HTTP利用時) :例 /index.html • ヘルスチェック間隔:例 12分

健全/不健全を判定するまでの ヘルスチェックの成功・失敗回数 は指定可能 ヘルスチェックを意図的に失敗させることで特定のインスタンスへのリクエスト振り分けを止めることも可

Page 10: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

10

使いやすくて安価な従量課金

時間当たりの利用料は、複数AZ配置構成でも同一

ELBにリザーブドプランはなし

処理量は右図の通り

2013年6月12日現在

50K

⇒100K

50K

50K 50K

Page 11: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

11

2. ELBの各種機能詳細とTips

Page 12: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

12

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 13: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

13

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 14: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

14

ELBとアベイラビリティゾーン(AZ)と リージョン

リージョン内の複数のAZに負荷分散可能

• リージョンを越えたトラフィック分散は行わない

規模を問わず複数AZの利用を推奨

Availability Zone Availability Zone

myLB-xxx.elb.amazonaws.com

Page 15: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

15

ELBとAZ内キャパシティの関係

ELBで有効になっているAZ間で均等に負荷分散される

Availability Zone

Availability Zone

10

2

Availability Zone

Availability Zone

6

6

myLB-xxx.elb.amazonaws.com

myLB-xxx.elb.amazonaws.com

良くない例:AZ間でキャパシティが不均等 良い例:AZ間でキャパシティが均等

Page 16: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

16

独自ドメインの利用

CNAMEを利用

• ドメインのDNSサーバに設定を投入すれば完了

• Zone Apexの場合

• 通常のDNSサーバではCNAME設定不可 Route 53のエイリアスレコードを使うことで対応可能

www.foo.example.com CNAME myLB-xxxx.ap-northeast-1.elb.amazonaws.com

Page 17: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

17

クライアントのIPアドレス取得

バックエンドサーバのアクセスログにはELBのIPアドレスのみが含まれる

• クライアントELB, ELBバックエンドのコネクションはそれぞれ独立しているため

HTTPならX-Forwarded-Forリクエストヘッダで参照可

• 例:

X-Forwarded-For: 203.0.113.7, 10.12.33.44, 10.12.23.88

Client IP address

送信元 経由するルート

Page 18: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

18

ELBとTCPコネクション

クライアント ELB のコネクション • アイドル状態が60秒続くとそのコネクションを切断する

ELB バックエンドインスタンスのコネクション • Keepaliveの設定を推奨

• コネクションタイムアウト値を60秒以上に設定することを推奨

• 60秒以下の場合、ELBがそのEC2インスタンスを不健全と判定し、トラフィックを送らなくなることがあるので注意

Page 19: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

19

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 20: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

20

SSL Termination

ELBでSSL Terminationも可能

1. ELBでSSL Terminationし、バックエンドとはSSLなし

2. ELBでSSL Terminationし、バックエンドと別途SSL

3. SSLをバイパスしてバックエンドにTCPで送信

• 1, 2の場合、SSL証明書をELBで一元管理可能

• Cipherの選択も可能

HTTP or HTTPS HTTP or HTTPS

Page 21: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

21

SSL Termination時のサーバ証明書

ELBにSSL証明書をアップロード

• バックエンドとの通信にSSLを用いないなら証明書の管理が容易 • マネージメントコンソール or IAM APIで設定

SSL証明書

(*)証明書のライセンスに関しては、ドメイン単位/サーバ単位で発行などそれぞれ異なるので発行元に問い合わせの事

Page 22: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

ELBでのSSL証明書の管理

SSLを用いる場合、ウィザードの中で

SSLの選択/インポート画面が出てくる

ELBへのSSL証明書の設定

Page 23: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

23

ELBへのSSL証明書の設定 ~API編~

IAMのAPIを利用

http://docs.aws.amazon.com/IAM/latest/UserGuide/InstallCert.html

iam-servercertupload -b public_key_certificate_file -c certificate_chain_file -k privatekey.pem -s certificate_object_name

Page 24: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

24

バックエンドインスタンスの認証

ELBとバックエンドインスタンス間でHTTPS/SSL使用時に、オプションでバックエンドの認証を利用可能

Page 25: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

25

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 26: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

26

VPC内での利用

AZ : a

AZ : b

Subnet : a1 Subnet : a2

Subnet : b1

ELB エンド ポイント

DNS ラウンド ロビン

ELBによる 負荷分散

ELBによる 負荷分散

AZ配下の EC2台数はAZ間で均等化を

推奨

VPCとELBは同一Region内にAZを超えて作成

(※SubnetはAZをまたいだ構成ができない)

VPC by default後、ELBはVPC内に配置が基本

Internet

Internet Gateway

Page 27: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

27

VPC対応概要

ELB inside VPCの機能

ELBのトラフィックをサブネッ

トをまたいで分散も可能

ELBにセキュリティグループが

設定可能

ELB inside VPCの制約 (2013年6月時点)

IPv6サポート現状なし

Dedicatedインスタンスは

サポートせず

/27 CIDRブロック以上の

Subnetが必要

Page 28: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

28

VPC内のELB配置設定方法

作成済のVPC一覧が表示されるため、ELBを配置するVPCを選択

Public Subnet(Internet GatewayがアタッチされたSubnet)を作成(アタッチされていないとエラー)

Page 29: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

29

ELBを配置するVPC内Subnetの指定

EC2-Classicの場合と違いVPC内に配置する場合は ELBを配置するVPC Subnetを明示的に各AZにつき1つ指定

ELBを配置するSubnetを指定

複数AZ構成の場合各AZに1つSubnetを指定

(注意)/27より小さな

Subnetを選択するとエラー

Page 30: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

30

Internal ELB

プライベートIPアドレスのみを持つELB

グローバルIPアドレスを持たないこと以外は“VPC内ELBと同機能”

VPC内のみで利用可

(EC2-Classicでは不可)

Internet Gatewayが

アタッチされていないVPCにも配置可

Internal ELBの制約

VPC外では作成不可

VPC内ELBと同様

Page 31: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

31

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 32: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

32

ELBのSecurity Group

バックエンドはELBからのみリクエストを受け付ける設定を推奨

443 80

80

80

80

22

EC2-ClassicではELBは全て“amazon-elb/amazon-elb-sg”

に属する

Page 33: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

33

ELBのSecurity Group

VPCではELBに任意のSecurity Groupを設定可能 • VPC Security Groupとして編集可

• Outbound設定についてはELB自身が能動的に外部と通信を確立することはないため特に設定不要

既存のVPC内のセキュリティグループの選択も可能

新規作成も可能 (この際はInboundのみ) sg-ELB

443: 0.0.0.0/0

sg-EC2 80:sg-ELB

22:10.0.0.0/24

443 80

80

80

80

CIDR : 10.0.0.0/24

22

Page 34: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

34

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 35: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

35

ELBのスケーリング詳細

ELBは負荷に応じてスケールする

但し、以下のような場合にELBがHTTP 503を返す

• ELBへの接続・リクエストが瞬間的に急増したために、ELBのスケーリングが間に合わない場合

• TVやメディアによるサービス紹介、等

回避方法

• 事前にELBをスケールさせておく

• 負荷をかける

• Pre-Warming(暖気運転)の申請を行う

Page 36: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

36

ELBの暖気運転(Pre-Warming)

Business/Enterpriseサポートに加入者様向けにELBを事前にスケールさせておく操作

急激なトラフィックの増加が予想される場合に有効

• メディアで自社サイトが紹介される、等

ELBの負荷テストで、段階的にスケールさせることが出来ない場合にも有効

Page 37: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

37

ELBの各種機能詳細とTips

ELB利用時のTips

• AZとバックエンドキャパシティの関係

• 独自ドメインでの利用

• クライアントのIPアドレス取得

• ELBとバックエンドのコネクション

SSLサポート

VPCでの利用

ELBとSecurity Group

ELBのスケーリング

Stickyセッション

Page 38: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

38

Stickyセッション

Stickyセッションを使うと、同じユーザから来たリクエストを全て同じインスタンスに送信可能

Stickyセッションの種類は以下2パターン

• Application Genereated Cookie Stickiness

• Load Balancer Generated Cookie Stickiness

ELBがどのくらいの期間同じインスタンスにルーティングし続けさせるかを決めることが重要

Page 39: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

39

Application Generated Cookie Stickiness

アプリケーション固有のセッション維持を行う

アプリケーションに独自のセッションCookieがある場合等に利用

例:Webサービスへのユーザーログイン時にCookieを生成。ログアウト時にCookie削除

Page 40: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

40

Load Balancer Generated Cookie Stickiness

期間ベースのセッション維持を行う

アプリケーションに独自のセッションCookieがない場合、ELB側でセッション維持を管理したい場合に利用

ELB側で期限付きCookieを生成

Page 41: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

41

3. ELBと各種サービスの連携

Page 42: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

42

CloudWatchとの連携

CloudWatchによりELBの以下を監視可能

• 遅延時間

• リクエスト数

• 健全なホスト数

• 不健全なホスト数

• バックエンドの2xx-5xxレスポンス数

• ELBの4xxと5xxのレスポンス数

監視

Page 43: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

43

Auto Scalingとの連携

Auto Scalingによるインスタンス増減時にELBへのアタッチ・デタッチが可能

ELBのヘルスチェックの結果をAuto Scalingに反映可能

利用例:

• 一定間隔でレスポンスをチェックし、遅延が増加したらインスタンスを自動追加

• ELBのヘルスチェックが成功したEC2インスタンスを常にX台以上

Auto scaling Group

増減

Page 44: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

44

Route53 DNSフェイルオーバ対応

Route53のヘルスチェック機能と連携 • 例:アプリケーション障害時にSorryページヘ誘導

正常時 フェイルオーバ時

S3 Bucket

1. DBに問題発生

2. AppサーバのELBヘルスチェック失敗

3. ELB可に健全なインスタンスなし

4. フェイルオーバ

5. Sorryページ

Page 45: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

45

Route53 DNSフェイルオーバ対応

設定方法

• Alias Target にELBを指定し、Routing Policyに「Failover」を選択

Evaluate Target Health:

[Yes]

「Associate with Health Check」: 既存のヘルスチェックとの関連付け。 「ELB」の場合は原則「No」を選択

Page 46: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

46

User AWS Management Console

スタック

Load Balancerレイヤー

App Serverレイヤー

Databaseレイヤー

レシピ

レシピ

レシピ DB

Web /App

Web /App

LB

①スタックの作成

②レイヤーの作成

③レシピの作成・設定 (ビルトイン レシピ利用可)

④レイヤーにインスタ ンス追加・起動

⑤レシピによって パッケージインス トール、設定

LBとしてELBが選択可能に

OpsWorksでELBをLBレイヤーに利用可能に

OpsWorksのELB対応

Page 47: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

47

4ELB負荷テストに関するTips

Page 48: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

48

ELBを負荷テストする必要性について

ELBのいくつかの特長がテストシナリオに影響を与える可能性がある。

• ELBのスケーリング

• ELBの初期キャパシティ

• アイドルコネクションタイムアウト

• バックエンドインスタンスのヘルスチェック

• Stickyセッション、等

ご利用内容に合わせたシナリオでテストが必要

Page 49: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

49

ELBの負荷テスト方法の種類

シングルクライアントテスト • 例:Apache Bench(ab)

マルチクライアントテスト • 例:curl-loader

(都度DNS解決を行うツールが望ましい)

分散テスト • 例:Fabricフレームワーク、

BeesWithMachineGuns

※いずれのテストにおいても、クライアントの負荷が足りない場合はクライアント数を増やす等で対応可

負荷生成 クライアント

バックエンドインスタンス

Page 50: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

50

推奨テストアプローチ

想定する最大負荷のテスト

通常のトラフィック時のテスト

• トラフィックの多い時

• トラフィックの少ない時

• トラフィックの傾向に変化がある時(朝や昼の時間帯など)

短い時間でトラフィックが大きく変化する場合のテスト

※ELB以外にも負荷生成クライアント、バックエンドEC2インスタンスも監視すべき

• アプリケーション内部の動作も要確認

時間

負荷

Page 51: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

51

負荷テストの注意事項

ELBの初期スケールに注意 • スケールするまでに、HTTP 503レスポンスを返す期間があり得る

• 回避策: • ELBの暖気運転( Pre-Warming)申請をする

• 5分間隔で50%以上のトラフィック増加をしないよう負荷テストを設定

DNSクエリの仕方に注意 • テストクライアント側で少なくとも1分に1回DNSの再解決をする

スティッキーセッション利用時の割り振り方 • 同じCookieでリクエストを続けた場合などは振り分けに偏りが

バックエンドインスタンスのアイドルタイムアウト • 60秒以上に設定しないとELBが誤って不健全なホストと見なす可能性あり

Page 52: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

52

5.まとめ

Page 53: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

53

まとめ

ELBはAWSが提供するロードバランシングサービス

• 運用管理コストを抑えながらスケーラブルで高可用なインフラを構築可能

• 各種サービスとの連携もスムーズ&随時拡充

• 負荷試験時はその特性を理解した上で

• 急激な負荷の増大が想定される場合には、サポート加入の上で暖気申請(Pre-Warming)を

Page 54: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

54

日本語Link

(クラウドサービス活用集に掲載)

VPC内ELB配置設計指針

ロードバランサとSocket接続を使用したイベント通知サーバの負荷分散

Elastic Load Balancing開発者ガイド • http://docs.aws.amazon.com/ja_jp/ElasticLoadBalancing/lat

est/DeveloperGuide/Welcome.html

Elasitc Load Balancingを評価するためのベストプラクティス • http://d36cz9buwru1tt.cloudfront.net/jp/documentation/Be

stPracticesInEvaluatingELB-ja-final.pdf

Page 55: [AWSマイスターシリーズ]Amazon Elastic Load Balancing (ELB)

© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

55

英語Link(最新版)

参考資料 • Amazon Elastic Load Balancing Developer Guide

http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/Welcome.html

• Best Practices in Evaluating Elastic Load Balancing

http://aws.amazon.com/articles/1636185810492479

• Amazon ELB FAQ http://aws.amazon.com/ec2/faqs/

Elastic Load Balancing の箇所

• AWS re: Invent CPN 205: Zero to Millions of Requests

https://www.youtube.com/watch?v=xKF-Aawz9oc