test
- 2. Agenda
1. ELB基本編
2. ELB各種機能詳細とTips
3. ELBと各種サービスの連携
4. ELB負荷試験時のTips
5. まとめ
2
© 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基本編
3
© 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で
コントロール可
4
© 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の概念図
ユーザー
開発者
クライアント
HTTP / HTTPS /
TCP / SSL
ELB
EC2
AZ a
HTTP / HTTPS /
TCP / SSL
Web
コンソール
EC2
AZ b
5
© 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
11
© 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サーバに設定を投入すれば完了
www.foo.example.com CNAME myLB-xxxx.ap-northeast-1.elb.amazonaws.com
• Zone Apexの場合
• 通常のDNSサーバではCNAME設定不可
Route 53のエイリアスレコードを使うことで対応可能
16
© 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インスタンスを不健全と判定し、
トラフィックを送らなくなることがあるので注意
18
© 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で送信
HTTP or HTTPS
HTTP or HTTPS
• 1, 2の場合、SSL証明書をELBで一元管理可能
• Cipherの選択も可能
20
© 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が必要
27
© 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と同様
30
© 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自身が能動的に外部と通信を確立すること
はないため特に設定不要
CIDR : 10.0.0.0/24
80
既存のVPC内のセ
キュリティグルー
プの選択も可能
80
443
80
80
22
33
sg-ELB
443: 0.0.0.0/0
sg-EC2
80:sg-ELB
22:10.0.0.0/24
新規作成も可能
(この際は
Inboundのみ)
© 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を生成
40
© 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と各種サービスの連携
41
© 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」を選択
45
© 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
47
© 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
インスタンスも監視すべき
• アプリケーション内部の動作も要確認
50
© 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が誤って不健全なホストと見なす可能性あり
51
© 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.まとめ
52
© 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/Devel
operGuide/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
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.