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
160
ロードバランサーって何? / 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
31
Developer Consoleを使い倒そう / Use Web Browser DevTools
nekonenene
0
4
まだまだマイナー?! 未踏事業について教えます / Introduction of Mitou Project
nekonenene
1
86
Docker for Windows/macOS
nekonenene
0
4
技術的負債を防ぐには / What is the Technical Debt
nekonenene
0
290
画像処理の基礎の基礎 / Ultra Basic of Image Processing
nekonenene
0
20
伝わる文章を書こう講座 / Write the Kind Japanese Message
nekonenene
2
130
Unity で Android 自動ビルドしたかった話 / I tried Android build of Unity using Docker, but...
nekonenene
0
2k
これでわかるB-treeアルゴリズム / B-tree algorithm
nekonenene
12
9.7k
Other Decks in Technology
See All in Technology
10分でわかるfreee エンジニア向け会社説明資料
freee
18
520k
分布で見る効果検証入門 / ai-distributional-effect
cyberagentdevelopers
PRO
4
700
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
49k
GitHub Universe: Evaluating RAG apps in GitHub Actions
pamelafox
0
180
いまならこう作りたい AWSコンテナ[本格]入門ハンズオン 〜2024年版 ハンズオンの構想〜
horsewin
9
2.1k
Shift-from-React-to-Vue
calm1205
3
1.3k
Automated Promptingを目指すその前に / Before we can aim for Automated Prompting
rkaga
0
110
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
290k
Forget efficiency – Become more productive without the stress
ufried
0
140
pandasはPolarsに性能面で追いつき追い越せるのか
vaaaaanquish
4
4.6k
10分でわかるfreeeのQA
freee
1
3.4k
Figma Dev Modeで進化するデザインとエンジニアリングの協働 / figma-with-engineering
cyberagentdevelopers
PRO
1
430
Featured
See All Featured
The Invisible Side of Design
smashingmag
297
50k
Building Adaptive Systems
keathley
38
2.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
How GitHub (no longer) Works
holman
311
140k
Designing for humans not robots
tammielis
249
25k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
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