Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ロードバランサーって何? / What is the load balancer?
Search
ハトネコエ
July 31, 2017
Technology
0
170
ロードバランサーって何? / What is the load balancer?
「ロードバランサーってよく聞くけど何物?」から始まり、DSRのメリット・デメリットなど。
社内勉強会にて発表。
ハトネコエ
July 31, 2017
Tweet
Share
More Decks by ハトネコエ
See All by ハトネコエ
Godot 4.3 と学ぶインタラクティブミュージック / Interactive Music Basics with Godot 4.3
nekonenene
0
47
Developer Consoleを使い倒そう / Use Web Browser DevTools
nekonenene
0
8
まだまだマイナー?! 未踏事業について教えます / Introduction of Mitou Project
nekonenene
1
97
Docker for Windows/macOS
nekonenene
0
8
技術的負債を防ぐには / What is the Technical Debt
nekonenene
0
290
画像処理の基礎の基礎 / Ultra Basic of Image Processing
nekonenene
0
24
伝わる文章を書こう講座 / Write the Kind Japanese Message
nekonenene
2
140
Unity で Android 自動ビルドしたかった話 / I tried Android build of Unity using Docker, but...
nekonenene
0
2.1k
これでわかるB-treeアルゴリズム / B-tree algorithm
nekonenene
12
9.8k
Other Decks in Technology
See All in Technology
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
470
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
300
C++26 エラー性動作
faithandbrave
2
710
Wantedly での Datadog 活用事例
bgpat
1
430
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
210
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
240
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
520
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
700
Featured
See All Featured
Writing Fast Ruby
sferik
628
61k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The Language of Interfaces
destraynor
154
24k
It's Worth the Effort
3n
183
28k
Why Our Code Smells
bkeepers
PRO
335
57k
Optimising Largest Contentful Paint
csswizardry
33
3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A designer walks into a library…
pauljervisheath
204
24k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
A Tale of Four Properties
chriscoyier
157
23k
Typedesign – Prime Four
hannesfritz
40
2.4k
Transcript
ϩʔυόϥϯαʔ͕ Θ͔Βͳ͍ ϋτωίΤ @nekonenene 201707݄31
• ϩʔυόϥϯαʔɺௐΕௐΔ΄Ͳ NATSSL௨৴ͳͲલఏͱͳΔωοτϫʔΫ ͕ࣝΓࢁͳ͜ͱ͕Θ͔ͬͯɺ શ෦৮ΕΒΕͳ͍ͷͰɺؾʹͳͬͯͨ ࣍ϖʔδͷ͜ͱͷΈѻ͍·͢ • L4ʢτϥϯεϙʔτɿTCP/UDPʣ • L7ʢΞϓϦέʔγϣϯʣ
ϩʔυόϥϯαʔΘ͔Βͳ͍
• ϩʔυͬͯͳʹʁ ಓʁ • ͲΜͳΈͳͷʁ • σʔλΛͲ͏ͬͯΫϥΠΞϯτʹ͢ͷʁ • ઐ༻ͷػցΛങΘͳ࣮ͯ͘ݱͰ͖Δʁ •
ෳͷϩʔυόϥϯαΛཱͯͨͱ͖ɺ ͦΕͷଓཧͲ͕͓͜͜ͳ͏ͷʁ ͕͜͜Θ͔Βͳ͍
• load ͱ͍͏ͱʮσʔλΛಡΈࠐΉʢಈࢺʣʯ ͷΠϝʔδ͕ڧ͍͚Ͳɺʮॏՙʢ໊ࢺʣʯͷ ҙຯ͕ݩʑɻͭ·Γʮෛՙʯ • ʮՙΛੵΉɾ٧ΊࠐΉʯˠʮర͢Δʯ ˠʮσʔλΛॻ͖ࠐΉɾಡΈࠐΉʯ ͱ͍͏ྲྀΕͰίϯϐϡʔλ༻ޠͱͯ͠Θ ΕΔΑ͏ʹͳͬͨͬΆ͍
1. ϩʔυͬͯͳʹʁ
• load balancing ʮෛՙࢄʯͱ͍͏ҙຯͰ ϩʔυόϥϯαͦΕΛͬͯ͘ΕΔͷ • ͳͷͰɺҙຯ߹͍ͱ͍͚ͯ͠Ͳɺ جຊతʹϩʔυόϥϯγϯά༻ʹ࡞ΒΕͨ ͷΛϩʔυόϥϯαͱͯ͠ޠ͍͖ͬͯ·͢ ϩʔυόϥϯα
• ϩʔυόϥϯα͕ͲͷαʔόʔΛબ͢Δ͔ ͷख๏͍͘Β͔͋Δɻ͓ͳྫˣ • ϥϯυϩϏϯํࣜɿ୯७ʹॱ൪ʹબ • ॏΈ͚ͮɿൺΛఆٛ • ࠷খଓɿݱࡏͷίωΫγϣϯ͕࠷খ͞ ͍αʔόʹసૹ
2. ͲΜͳΈͳͷʁ ࢀߟ : http://www.infraexpert.com/study/loadbalancer4.html
• DNSͷAϨίʔυͰɺಉυϝΠϯʹ ෳͷIPΞυϨεΛׂΓͯΔ͜ͱͰ ϥϯυϩϏϯํࣜΛ࣮ݱ͢Δͷ ʢϩʔυόϥϯα͍Βͣʂ खܰʂʣ • RFC3484ʹͯʮෳׂΓ͕ͯ͋Δ߹ ͬͱ͍ۙαʔόΛબʯͱͳͬͨͷͰݱ ࡏϥϯυϩϏϯʹͳΒͳ͍͜ͱ
DNSϥϯυϩϏϯ
• ϥϯυϩϏϯͰͳ͍Ͱ͕͢ɺ AWS Route53ͰWeightͷࢦఆ͕͓͜ͳ ͑ɺDNSʹΑΔʮॏΈ͚ͮʯͷෛՙࢄ͕Մ ೳͰ͢ DNSʹΑΔෛՙࢄ ࢀߟ : http://qiita.com/nagizero/items/385ed12c60f229a4df9c
• AWSͷυΩϡϝϯτతʹɺELB CLBʢClassic Load Balancerʣ ALBʢApplication Load Balancerʣ ʹ͔Ε·͕͢ɺELBʹCLBͱ͠·͢ •
ͳ͓ɺALBEC2Πϯελϯεͷ Ͳͷίϯςφʹͭͳ͙͔·ͰΛ੍ޚ͢Δɻ ϥϯυϩϏϯϧʔςΟϯάΞϧΰϦζϜisԿ ELBͲͷํࣜʁ
• ʰσϑΥϧτͰɺϩʔυόϥϯαʔɺ ϩʔυόϥϯαʔʹରͯ͠༗ޮʹ͢ΔΞϕΠ ϥϏϦςΟʔκʔϯؒͰۉʹτϥϑΟοΫ Λࢄ͠·͢ʱ ( http://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/classic/ introduction.html ) •
ॏΈ͚ͮ 1:1:1:1:1:1:ʢུ ͷࢄํࣜΛऔ͍ͬͯΔΑ͏Ͱ͢Ͷ CLBͲͷํࣜʁ
• αʔόʔ͔ΒͷϨεϙϯε͕ϩʔυόϥϯ αʔΛܦ༝͍ͯͯ͠ɺϩʔυόϥϯαʔͷ ෛՙେ͖͍ΑͶʁ ͱࢥ͍ͬͯͨͷͰɺΫϥΠΞϯτૹΔ ͷͩͱࢲࢥ͍ͬͯͨɻ • ্هํࣜΛDSRʢDirect Server Returnʣߏ
ͱݴ͏ 3. ΫϥΠΞϯτͲ͏ͬͯʁ
• αʔόʔ͔Βฦ͢ใ͕ϩʔυόϥϯαʔ Λ௨Βͳ͍ͷͰɺΞϓϦέʔγϣϯͷใ ಘΒΕͳ͍ • ΞϓϦέʔγϣϯతͳใʹΑΔෛՙࢄ͕ ͓͜ͳ͑ͳ͍ʢ͖ͬ͞ͷ࠷খଓͳͲʣ • CookieΛ༻͍ͨεςΟοΩʔηογϣϯ ʢύʔγεςϯεʣ͓͜ͳ͑ͳ͍
DSRͷσϝϦοτ ࢀߟ : http://knowledge.sakura.ad.jp/tech/527
• HTTPS௨৴Λ͓͜ͳ͏߹ɺ҉߸Խɾ෮߸ʹ ͦΕͳΓͷෛՙ • ϩʔυόϥϯαʔʹ͍ͬͨΜฦ͢͜ͱͰ SSLΞΫηϥϨʔλʢ҉߸Խɾ෮߸͢Δ ͷʣ͖ϩʔυόϥϯαʔͰ͋Εɺ ͦ͜ʹෛՙΛҰͰ͖Δ͠ɺSSLূ໌ॻͦ ͜ʹ͚ͩஔ͍ͯɺαʔόͱHTTP௨৴Մೳ DSRΛΘͳ͍ϝϦοτ
• ಈըετϦʔϛϯά࠶ੜͷΑ͏ʹɺ େྔͷϨεϙϯεΛαʔόʔ͕ฦ͢γεςϜ ͷ߹ɺϩʔυόϥϯαʔͷεϧʔϓοτ ʢσʔλసૹʣੑೳ͕͍͔ͭͳ͍͔Β DSRΛ͏΄͏͕͍͍ɺͱ͍͏߹͋Δ • ͨͩɺௐͯΈͨײ͡DSRΛקΊͳ͍ௐ ͕ଟ͘ײͨ͡ DSRΛ͏΄͏͕͍͍߹
ࢀߟ : http://www.infraexpert.com/study/loadbalancer12.html
• ϩʔυόϥϯαʔΛௐΔͱ F5 Networks.Inc ͷʰBIG-IPʱͷ͕ଟ͍… • ͰɺࣗαʔόͰݐͯΒΕͳ͍͔ʁ • ʰLinux Virtual
Server (LVS)ʱͱ ʰKeepalivedʱΛ༻͍Δ͜ͱͰɺ αʔόʔΛϩʔυόϥϯαʔԽͰ͖Δ 4. ઐ༻ͷػց͕ඞཁʁ
• LVSॏΈ͚ͮʹΑΔࢄΛ͓͜ͳ͑·͢ ʢઃఆํ๏ : http://dsas.blog.klab.org/archives/50664843.html ʣ • Keepalived֤αʔόʔͷࢮ׆ঢ়گΛɺ TCPίωΫγϣϯ͕ுΕΔ͔(TCP_CHECK) HTTPΞΫηεͰ͖Δ͔(HTTP_GET)
ͱ͍ͬͨํ๏Ͱࢹ͠·͢ ʢઃఆํ๏ : http://blog.idcf.jp/entry/cloud/keepalived ʣ LVS + Keepalived
• AWSͷElastic Load Balancingʹ͓͚Δ ϩʔυόϥϯαʔউखʹ૿ݮ͢ΔΒ͍͠ɻ • ͡Ό͋ͲͷϩʔυόϥϯαʔʹৼΔ͔ Ͳ͏͍͏Έʁ • ͜ͷࢿྉ7ϖʔδʹ͋ͬͨDNSϥϯυϩϏϯ
ͱಉ༷ͷํ๏Ͱղܾ͍ͯ͠Δ 5. ϩʔυόϥϯαʔͷόϥϯαʔʁ
ΫϥΠΞϯτ͕ϦΫΤετΛϩʔυόϥϯαʔʹૹ৴͢ΔલʹɺυϝΠϯωʔϜγεςϜ (DNS) αʔόʔΛ༻ͯ͠ϩʔυόϥϯαʔͷυϝΠϯ໊Λղܾ͠·͢ɻ Πϯελϯε amazonaws.com υϝΠϯʹ͋ΔͨΊɺDNS ΤϯτϦ Amazon ʹ Α੍ͬͯޚ͞Ε·͢ɻAmazon
DNS αʔόʔɺ1 ͭҎ্ͷ IP ΞυϨε (ϩʔυόϥϯ αʔ༻ͷϩʔυόϥϯαʔϊʔυͷ IP ΞυϨε) ΛΫϥΠΞϯτʹฦ͠·͢ɻ ΞϓϦέʔγϣϯͷτϥϑΟοΫ͕࣌ؒͷܦաͱͱʹมԽ͢ΔͱɺElastic Load Balancing ϩʔυόϥϯαʔΛεέʔϦϯάͯ͠ DNS ΤϯτϦΛߋ৽͠·͢ɻDNS Τ ϯτϦͰɺ༗ޮظݶ (TTL) 60 ඵʹࢦఆ͞Ε͍ͯΔͨΊɺτϥϑΟοΫͷมԽʹԠ͡ ͯ IP ΞυϨε͕ਝʹ࠶Ϛοϓ͞ΕΔʹҙ͍ͯͩ͘͠͞ɻ AWSυΩϡϝϯτΑΓ Ҿ༻ݩ : http://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/ userguide/how-elastic-load-balancing-works.html#request-routing
εοΩϦʂ
ΑΓਂ͘Γͨ͘ͳͬͨํ ͜ͷεϥΠυ͕ྑ͛͞Ͱ͢ ʰϩʔυόϥϯα࠶ೖʱ https://www.slideshare.net/ ryuichitakashima3/ ss-72343772