Download - Loadbalance using internal_elb
![Page 1: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/1.jpg)
Internal ELBを使った負荷分散
13年2月18日月曜日
![Page 2: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/2.jpg)
星野 豊 (@con_mame)
クックパッド株式会社 インフラストラクチャー部
http://d.conma.me/
http://facebook.com/conmame
13年2月18日月曜日
![Page 3: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/3.jpg)
好きなCDP
Cache Distributionパターン
13年2月18日月曜日
![Page 4: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/4.jpg)
好きなサービス
Elastic Transcoderhttp://d.conma.me/entry/
2013/01/30/002445
13年2月18日月曜日
![Page 5: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/5.jpg)
提供
13年2月18日月曜日
![Page 6: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/6.jpg)
PC、モバイル合わせて月間利用者数は2,000万人以上
レシピ数130万以上
PC、モバイル合わせて PV 10億/月 以上
PC / smart phone / mobile/ iOS / Android
Ruby on Rails
2011年 11月 AWS完全移行2012年 8月 VPC移行
500インスタンス以上稼働EC2 / ELB / CloudFront / S3 / Glacier / R53 / EIP / ENI etc...
13年2月18日月曜日
![Page 7: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/7.jpg)
ところで
13年2月18日月曜日
![Page 8: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/8.jpg)
Internal ELB知ってますか?
13年2月18日月曜日
![Page 9: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/9.jpg)
Internal ELB使ってますか?
13年2月18日月曜日
![Page 10: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/10.jpg)
これ
13年2月18日月曜日
![Page 11: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/11.jpg)
VPC 内部用Load Balancer
基本的に外向けELBと同じ
VPC内部のインスタンス間の通信をロードバランス
アプリケーションサーバ <-> DB / Cache
アプリケーションサーバ <-> 内部用API
13年2月18日月曜日
![Page 12: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/12.jpg)
DBとかCacheの冗長化どうしてますか?
13年2月18日月曜日
![Page 13: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/13.jpg)
アプリケーションの設定ファイルに複数サーバを並べる
haproxyとかproxyを使う
Floating IP pattern
13年2月18日月曜日
![Page 14: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/14.jpg)
アプリケーションの設定に複数サーバを並べる
サーバ台数多いと設定の配布に時間がかかる
haproxyとかproxyを使う
haproxy自体の冗長化どうしよう... (multicast使いたい...)
Pacemaker + heartbeat(Corosync)
Floating IP pattern
Slave系
内部API...13年2月18日月曜日
![Page 15: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/15.jpg)
そこで、Internal ELB
13年2月18日月曜日
![Page 16: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/16.jpg)
13年2月18日月曜日
![Page 17: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/17.jpg)
を
13年2月18日月曜日
![Page 18: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/18.jpg)
13年2月18日月曜日
![Page 19: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/19.jpg)
すっきり
13年2月18日月曜日
![Page 20: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/20.jpg)
メリットアプリケーションの設定ファイルに複数サーバを並べなくてもいい
切り離し・サービスインが手軽
他のミドルウェアを使わなくていい
管理コストの軽減
コネクションの集約
Multi AZ13年2月18日月曜日
![Page 21: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/21.jpg)
Use Case
13年2月18日月曜日
![Page 22: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/22.jpg)
DB
3306
DB slave
13年2月18日月曜日
![Page 23: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/23.jpg)
注意ELBのヘルスチェックで、tcp:3306をチェックしていると...
blocked because of many connection errors.
mysqladmin flush-hosts
max_connect_errors
MySQLを監視するスクリプトをxinet.d経由で登録して、http:8080:/ のように監視
正常なら 200
MySQLが駄目な感じなら 500とか
13年2月18日月曜日
![Page 24: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/24.jpg)
内部API
80
API
13年2月18日月曜日
![Page 25: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/25.jpg)
Cache
22121twemproxyhaproxy
11211
ElastiCacheor
Memcached / Redis on EC2
13年2月18日月曜日
![Page 26: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/26.jpg)
TIPS
Protocol: httpPort: 80Path: /
13年2月18日月曜日
![Page 27: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/27.jpg)
TIPSMaster / Slave process Down
ENIの移動やELBからの切り離しを行うようなスクリプトを追加
Masterのfailover先をELB配下のslaveに
ENIの移動とELB
アプリケーションの設定変更なし
13年2月18日月曜日
![Page 28: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/28.jpg)
Multi AZ
AZ-a AZ-b
application servermail server
proxy servermail relay server
13年2月18日月曜日
![Page 29: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/29.jpg)
Multi AZ
AZ-a AZ-b
application servermail server
proxy servermail relay server
13年2月18日月曜日
![Page 30: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/30.jpg)
Multi AZ
AZ-a AZ-b
application servermail server
proxy servermail relay server
13年2月18日月曜日
![Page 31: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/31.jpg)
Multi AZ
AZ-a AZ-b
application servermail server
proxy servermail relay server
13年2月18日月曜日
![Page 32: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/32.jpg)
Multi AZ
AZ-a AZ-b
application servermail server
proxy servermail relay server
13年2月18日月曜日
![Page 33: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/33.jpg)
Performance
13年2月18日月曜日
![Page 34: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/34.jpg)
DB編データ数: 約2億connection: 100 - 800試行回数: 100ELB配下に2台のMySQL (m2.4xlarge)
connection DIRECT ELB
100 1897.5 1703.5200 2075.1 1696.3300 2286.7 1897.3400 3098.5 2033.9500 3255.8 2110.2600 3341.2 2687.9700 3923.7 2886.3800 4812.3 3224.3
qps
0
1250
2500
3750
5000
100 200 300 400 500 600 700 800DIRECT ELB
http://bit.ly/12CetAx
13年2月18日月曜日
![Page 35: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/35.jpg)
DB編データ数: 約2億connection: 100 - 800試行回数: 100ELB配下に2台のMySQL (m2.4xlarge)
connection DIRECT ELB
100 1897.5 1703.5200 2075.1 1696.3300 2286.7 1897.3400 3098.5 2033.9500 3255.8 2110.2600 3341.2 2687.9700 3923.7 2886.3800 4812.3 3224.3
qps
0
1250
2500
3750
5000
100 200 300 400 500 600 700 800DIRECT ELB
33%
http://bit.ly/12CetAx
13年2月18日月曜日
![Page 36: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/36.jpg)
ElastiCache+twemproxy編
データ数: 10万
connection: 100
試行回数: 100
key size: 40bytes / value: 400bytes
twemproxy配下に2-4台のElastiCache Node
cache.m1.large
m1.large
Internal ELBウォームアップ無し
13年2月18日月曜日
![Page 37: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/37.jpg)
0"
10000"
20000"
30000"
40000"
50000"
60000"
2" 3" 4"
Sec$
only$twemproxy$(cmd/sec)�
twemproxy1"
twemproxy2"
twemproxy3"
twemproxy4"
twemproxy0"
3000#
3100#
3200#
3300#
3400#
3500#
3600#
3700#
3800#
3900#
4000#
4100#
4200#
2# 3# 4#
Sec$
ELB+twemproxy(cmd/sec)�
twemproxy2#
twemproxy3#
twemproxy4#
13年2月18日月曜日
![Page 38: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/38.jpg)
13年2月18日月曜日
![Page 39: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/39.jpg)
90%劣化...
4,000/sec のアクセスがウォームアップ無しのInternal ELBの性能限界では...
ELBはアクセス量に応じてスケールアップする!
事前ウォームアップも可能
http://bit.ly/Uh68lr
13年2月18日月曜日
![Page 40: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/40.jpg)
注意ELBのIPアドレスは変わることがある
DNSの問い合わせ結果をキャッシュしたり、hostsファイルに書いておいたりするとアクセスできなくなることも
haproxyなどの起動時のDNSの結果をキャッシュするような作りになっているものは、IPアドレスの変更を検知させたり、定期的なreloadを
13年2月18日月曜日
![Page 41: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/41.jpg)
Conclusion
13年2月18日月曜日
![Page 42: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/42.jpg)
ELBは勝手にスケールアップするけど...
事前のパフォーマンス測定
数分とかではなく長時間トラフィックを流してスケールアップの状態を見たり
13年2月18日月曜日
![Page 43: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/43.jpg)
ELBは勝手にスケールアップするけど...
事前のパフォーマンス測定
数分とかではなく長時間トラフィックを流してスケールアップの状態を見たり
∧_̲∧ ⊂(#・ω・) 仕様書はない! / ノ∪ し―-‐‑‒J |l| | ⼈人ペシッ!! __ \ \  ̄ ̄
13年2月18日月曜日
![Page 44: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/44.jpg)
Internal ELBで気軽に負荷分散・冗長化
Floating IP パターンと組の組み合わせで楽にFailover
ELBのIPアドレスの変更にご注意を!
13年2月18日月曜日
![Page 45: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/45.jpg)
Important
13年2月18日月曜日
![Page 46: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/46.jpg)
募集中!!一緒に毎日の料理を支えませんか?
13年2月18日月曜日
![Page 47: Loadbalance using internal_elb](https://reader035.vdocuments.pub/reader035/viewer/2022062617/54b75ea84a7959f71f8b460d/html5/thumbnails/47.jpg)
Q and A
13年2月18日月曜日