AWSのオートスケールとなかよく付き合う
by
FUJIWARA Shunichiro
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
AWSͷΦʔτεέʔϧͱ ͳ͔Α͖͘߹͏ YAP(achimon)C::Asia Hachioji 2016 mid 2016-07-02 @fujiwara
Slide 2
Slide 2 text
@fujiwara github.com/fujiwara sfujiwara.hatenablog.com ٕज़෦
Slide 3
Slide 3 text
Agenda • ΦʔτεέʔϧͬͯԿ • ͳͥΦʔτεέʔϧ͢Δͷ͔ • ͦͦΦʔτεέʔϧ͢Δ͖? • Ͳ͏͍͏݅ͰΦʔτεέʔϧΛൃಈ͢Δ͔ • ຊʹى͖ͨා͍
Slide 4
Slide 4 text
Φʔτεέʔϧͱ
Slide 5
Slide 5 text
AWSͷΦʔτεέʔϧ ΞϓϦέʔγϣϯͷෛՙΛॲཧ͢ΔͨΊʹ దͳͷEC2ΠϯελϯεΛىಈ͢ΔΈ
Slide 6
Slide 6 text
ͳͥΦʔτεέʔϧ͢Δͷ͔
Slide 7
Slide 7 text
ͳͥΦʔτεέʔϧ͢Δͷ͔ ΞΫηε(≒ෛՙ)1ͷதͰมಈ͢Δ
Slide 8
Slide 8 text
ͳͥΦʔτεέʔϧ͢Δͷ͔ min : avg : max = 200 : 1000 : 3000 ϐʔΫ࣌ͷෛՙ1ฏۉͷ3ഒ ϐʔΫΛఆͨ͠ΠϯελϯεΛৗ࣌ىಈ͢Δͱ ! ෛՙʹԠͯ͡ΠϯελϯεΛௐ͢ΕઅͰ͖Δ
Slide 9
Slide 9 text
ͳͥΦʔτεέʔϧ͢Δͷ͔ ʰಥൃతͳෛՙʹରԠͰ͖Δʱ • ͋Δఔ·Ͱԣʹ૿ͤΔͷͰ͋Ε ⭕ • ྫ͑RDS͕ϘτϧωοΫʹͳΔͱ… ❓ • ෛՙͷ૿େ͕͗͢Δͱؒʹ߹Θͳ͍
Slide 10
Slide 10 text
ͳͥΦʔτεέʔϧ͢Δͷ͔ ͦͷଞʹخ͍͠(ؾΛ͚ͭΔ)͜ͱ • ো͕ൃੜͨ͠ΠϯελϯεࣗಈͰআ(terminate) • ৽͍͠Πϯελϯε͕ࣗಈͰىಈ • ઃఆ͞ΕͨΛอͱ͏ͱͯ͘͠ΕΔ ! ΠϯελϯεোͰ࠶ىಈෆཁ " আ͞ΕͨΠϯελϯεͷEBSফ໓
Slide 11
Slide 11 text
ͦͦΦʔτεέʔϧ͢Δ͖ʁ
Slide 12
Slide 12 text
ͦͦΦʔτεέʔϧ͢Δ͖ʁ 16ίΞϚγϯ͕ϐʔΫͰ30ඞཁͳγεςϜ ! c4.4xlarge(16 cores) $776.66/month • avg: × 10 = $7,766 / month • max: x 30 = $23,299 / month ฏۉ10ʹ͑ΒΕΕֹࠩ20 $15,533 ≒ 150ສԁ ͋Δఔͷن͕͋Εݮֹ͕େ͖͍
Slide 13
Slide 13 text
ن͕ͦΕ΄ͲͰͳ͍߹ 4ίΞϚγϯ͕ϐʔΫͰ6ඞཁͳγεςϜ ! c4.xlarge(4 cores) $193.98/month • avg: × 4 = $776 / month • max: x 6 = $1,164 / month ࠷3ಈ͔͍ͨ͠ͷͰavg = max / 3 ʹͳΒͳ͍ ֹࠩ2 $387 ఔɺݻఆඅͱൺΔͱ…
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
ͦͦΦʔτεέʔϧ͢Δ͖ʁ·ͱΊ ΦʔτεέʔϧΛߟྀ͍ͯ͠ͳ͍γεςϜʹޙ͔Βಋೖ͢Δʹ ͍Ζ͍Ζඞཁ ӡ༻த҆ఆ͢Δ·Ͱ͍Ζ͍Ζ͋Δ ಋೖɺӡ༻ίετ͕ݮίετʹݟ߹͏͔Ͳ͏͔அ
Slide 16
Slide 16 text
Auto Scaling ུ֓
Slide 17
Slide 17 text
Auto Scaling Group Πϯελϯεͷ·ͱ·Γ͝ͱʹ Auto Scaling GroupΛఆٛ • ͷ࠷খ(min)ɺ࠷େ(max)ɺر (desired) • ؔ࿈͚ͮΔ ELB • ىಈઃఆ (Launch Configuration) • εέʔϦϯάϙϦγʔ
Slide 18
Slide 18 text
࠷খ (min) ❌ ͜ͷҎԼʹݮΒͳ͍ ⭕ ͜ͷΛ࠷ݶҡ࣋͠Α͏ͱ͢Δ min: 3, ݱࡏ3ͷঢ়ଶͰ1͕ϔϧενΣοΫࣦഊ → ৽͍͠Πϯελϯε͕ىಈ͞ΕΔ → ࣦഊͨ͠Πϯελϯε͕আ͞ΕΔ Ұ࣌తʹminΛԼճΔ͜ͱ͕͋Δ
Slide 19
Slide 19 text
ر (desired) ͜ͷΛҡ࣋͠Α͏ͱ͢Δ εέʔϦϯάϙϦγʔʹΑͬͯ desired ͕มߋ͞ΕΔ → Πϯελϯε͕ىಈ/আ͞ΕΔ → desiredΛຬͨͨ͠Βྃ ىಈࣦഊͨ͠߹ɺdesiredΛຬͨ͢·ͰϦτϥΠ ͏·͘ىಈ͠ͳ͍AMIΛ࡞ͬͯ͠·͏ͱӬԕʹ…!
Slide 20
Slide 20 text
࠷େ (max) ͜ͷҎ্ىಈ͠ͳ͍ ઃఆϛεͰͷىಈ͗͢͠ΛࢭͰ͖Δ ෛՙ૿େ࣌ʹఱҪʹͨΔՄೳੑ͕͋ΔͷͰؾΛ͚͓ͭͯ͘
Slide 21
Slide 21 text
εέʔϦϯάϙϦγʔ Ͳ͏͍͏݅ͰdesiredΛ૿Ճɺݮগͤ͞Δ͔ɺͱ͍͏ఆٛ CloudWatchͷϝτϦΫεΛݩʹͨ͠ΞϥʔϜΛτϦΨʹ͢Δ • Auto Scaling GroupͷEC2 CPU༻ • ओʹWebΞϓϦέʔγϣϯ͚ • Amazon SQS ͷΩϡʔʹཷ·͍ͬͯΔ • ඇಉظδϣϒॲཧαʔό(ಈըมͳͲ)͚
Slide 22
Slide 22 text
spot or on demand? ΦϯσϚϯυΠϯελϯε͔εϙοτΠϯελϯε͔ ΦʔτεέʔϧʹͲͪΒͰར༻Մೳ(LaunchConfigͰࢦఆ) ΦϯσϚϯυΠϯελϯε ͍ͭͰಉҰՁ֨ͰىಈͰ͖Δ (εϙοτͱൺΔͱ)ߴ͍ WebΞϓϦέʔγϣϯαʔό͖
Slide 23
Slide 23 text
spot or on demand? εϙοτΠϯελϯε ಈ࡞தͷεϙοτՁ֨ (धཁͱڙڅͰܾఆ)Ͱֹ͕ܾۚ·Δ ͍҆ (͍͍ͨͯͷ߹ΦϯσϚϯυͷ1/5ʙ1/10) ߴಅ͢Δ͜ͱ͕͋Δ (ΦϯσϚϯυՁ֨ͷഒ) ೖࡳՁ֨ΛεϙοτՁ্͕֨ճΔͱΠϯελϯεআ → શ໓͢ΔՄೳੑ͕͋Δ ଟগͷॲཧԆ͕ڐ͞ΕΔδϣϒϫʔΧʔ͖
Slide 24
Slide 24 text
No content
Slide 25
Slide 25 text
γεςϜΛΦʔτεέʔϧʹ ରԠͤ͞Δ
Slide 26
Slide 26 text
γεςϜΛΦʔτεέʔϧʹରԠͤ͞Δ ʮAMI͔Βىಈ͢Δ͚ͩͰɺਖ਼ৗʹՔಇ͢Δঢ়ଶʹͳΔʯ ͜ͷঢ়ଶΛ࡞Βͳ͍ͱΦʔτεέʔϧʹରԠͰ͖ͳ͍ • ϓϩϏδϣχϯά/σϓϩΠ • ࢹ • ϩάసૹ
Slide 27
Slide 27 text
ϓϩϏδϣχϯάɺσϓϩΠख๏ ❌ σϓϩΠ͍ͨ͠λΠϛϯάͰ push ⭕ ىಈͨ͠Πϯελϯε͕ pull ΠϯελϯεΛىಈͨ࣌͠Ͱͷਓؒͷ࡞ۀΛෆཁʹ͢Δ
Slide 28
Slide 28 text
AMIΛຖճ࡞Δ ϓϩϏδϣχϯάɺΞϓϦέʔγϣϯͷσϓϩΠ͕ྃͨ͠ঢ় ଶͰAMIΛ࡞Γ͢ˠ ىಈ͢Δ͚ͩͰOK ϝϦοτ • ىಈ͢Δ͚ͩɺىಈޙʹԿඞཁͳ͍ σϝϦοτ • ઃఆมߋɺΞϓϦέʔγϣϯमਖ਼ͰຖճAMIΛ࡞Γ͢खؒ • มߋ͝ͱʹΠϯελϯεΛશ෦ೖΕସ͑
Slide 29
Slide 29 text
AMIΛຖճ࡞Δ • σϓϩΠස͕ଟ͘ͳ͍αʔϏεͳΒՄೳ (10ճ/͍͔͠…) • ݻఆͷΠϯελϯε͕͋Δ߹Ͳ͏͢Δ…ʁ (σʔλετΞͳͲ͕ϚωʔδυαʔϏεͰͳ͍߹)
Slide 30
Slide 30 text
ϓϧܕͷϓϩϏδϣχϯάɺσϓϩΠख๏ S3ͳͲʹΞʔΧΠϒΛอଘɺ֤ΠϯελϯεͰऔಘɺల։͢Δ AWS CodeDeploy Mamiya github.com/sorah/mamiya Stretcher github.com/fujiwara/stretcher
Slide 31
Slide 31 text
ϓϧܕͷϓϩϏδϣχϯάɺσϓϩΠख๏ Πϯελϯε͕ىಈ࣌ʹࣗΒ࠷৽ͷͷΛऔಘɺ࣮ߦ S3ΛόοΫΤϯυʹ͢ΕՄ༻ੑ ⭕ σϓϩΠ͍
Slide 32
Slide 32 text
⾠ rsyncͳͲͰϓϧܕσϓϩΠΛࣗ࡞͢Δ build్தͷத్ͳঢ়ଶ͕औಘ͞Εͳ͍Α͏ҙ → ΠϯελϯεىಈதσϓϩΠ࡞ۀΛ͠ͳ͍(ͱ͔) औಘݩΛߴՄ༻/ߴੑೳʹ͢Δඞཁ͕͋Δ
Slide 33
Slide 33 text
⾠ Git͔Βऔಘͯ͠σϓϩΠ͢Δ ʮGitσϓϩΠπʔϧͰ͋Γ·ͤΜʯ খنͳΒͳ͍ ن͕େ͖͘ͳΔͱGitαʔόͷෛՙ͕ਂࠁ ৄ͘͠ YAPC::Asia 2015 ੈքల։͢ΔେنΣϒαʔϏεͷσϓϩΠΛࢧ͑Δٕज़ https://speakerdeck.com/hatena/yapc-asia-tokyo-2015
Slide 34
Slide 34 text
γεςϜΛΦʔτεέʔϧʹରԠͤ͞Δ ·ͱΊ ىಈͨ͠Πϯελϯε͕ࣗ͢Δ ͋Δϗετ͔Βશʹ˓˓(ssh)ɺͱ͍͏ൃΛΊΔ
Slide 35
Slide 35 text
ࢹ
Slide 36
Slide 36 text
ࢹͰඞཁͳ͜ͱ ಈతʹࢹରΛ૿ݮͰ͖ΔπʔϧΛ͏ agentΛىಈ͢Δ͚ͩͰࢹରʹՃ agentىಈΛܖػʹࣗಈొઃఆ͕Մೳ APIͰϗετొՄೳ
Slide 37
Slide 37 text
ࢹͰඞཁͳ͜ͱ ΦʔτεέʔϦϯάάϧʔϓશΛूͨ͠ϝτϦΫεΛΈΔ • CPU༻ͳͲ
Slide 38
Slide 38 text
ࢹͰඞཁͳ͜ͱ 1མ͙ͪͨΒ͍Ͱ͘Α͘Α͠ͳ͍ େྔʹىಈ͢ΕམͪΔ͍ͭΔ Πϯελϯεఀࢭ࣌ʹࢹఀࢭʹࣦഊ͢Δ͜ͱ͋Δ ZabbixͰͷτϦΨͷྫ grpavg["AutoScale","icmpping[]",last,0].last(0)<0.7 ʮϗετάϧʔϓͰpingޭׂͨ͠߹͕70%ΛԼճͬͨΒʯ
Slide 39
Slide 39 text
ࢹͰඞཁͳ͜ͱ ELBͷ UnHealthyHostCount ͕Ͳ͏্͕ͯ͠Δ ʰʮUnHealthyHostCount > 0ʯ͕7ؒܧଓͨ͠Βܯࠂʱ
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
ϩάΛ͔ʹΠϯελϯε֎ʹసૹ͢Δ ΦʔτεέʔϧͷΠϯελϯε͕আ(terminate)͞ΕΔͱ ʮEBSফ͑·͢ʯ
Slide 42
Slide 42 text
ࢹͱϩάʹ͍ͭͯ ·ͱΊ γεςϜશମͱ݈ͯ͠શ͔Ͳ͏͔ΛΈΔ ݸผͷΠϯεϯλϯεʹͩ͜ΘΓ͗͢ͳ͍ → ϓϩηεΈ͍ͨͳ ͷ ΠϯελϯεʹӬଓΛ͞ͳ͍ → ϝϞϦΈ͍ͨͳͷ
Slide 43
Slide 43 text
Ͳ͏͍͏݅Ͱ ΦʔτεέʔϧΛൃಈ͢Δ͔
Slide 44
Slide 44 text
εέʔϦϯάϙϦγʔ ΞϓϦέʔγϣϯαʔόͷ߹ͷྫ • ۙ5ؒͷʮฏۉʯCPU༻͕50%Λ͑ͨΒ → ݱࡏͷͷ40%ͷΛىಈ → 7ͳʹ͠ͳ͍(ΠϯελϯεىಈΛͭ) • ۙ1࣌ؒͷʮ࠷ߴʯCPU༻͕25%ΛͬͨΒ → 1ఀࢭ → 3ͳʹ͠ͳ͍(Ұؾʹམͪ͗͢ͳ͍Α͏ʹ)
Slide 45
Slide 45 text
CPU༻(ੵΈ্͛), CPU idle(ฏۉ), ϨεϙϯελΠϜ
Slide 46
Slide 46 text
ΠϯελϯεΛ૿͢ͱ͖ͷίπ CPU 40ʙ50%͙Β͍Ͱىಈ͢Δ • CPU༻্͕͕Δͱॲཧೳྗ͕ઢܗൺྫ͠ͳ͘ͳΔ 100%Ͱ50%ͷ2ഒॲཧͰ͖ΔΘ͚Ͱͳ͍ • Πϯελϯεىಈ·ͰͷϥάΛߟྀ͢Δ 3ʙ5ఔ͑ΒΕΔ͏ͪʹൃಈ͓ͯ͘͠
Slide 47
Slide 47 text
ΠϯελϯεΛ૿͢ͱ͖ͷίπ ݱࡏͷ40%ͷɺ࠷2ىಈ͢Δ • 10͋Δͱ͖ʹ1૿ͯ͠ॲཧೳྗʴ10%͚ͩ +40%͕2ճൃಈ͢Ε2ഒʹͳΔ • Πϯελϯεৗʹىಈޭ͢ΔͱݶΒͳ͍ AWSଆͷɺϓϩϏδϣχϯάσϓϩΠࣦഊ
Slide 48
Slide 48 text
ΠϯελϯεΛݮΒ͢ͱ͖ͷίπ ۙ1࣌ؒͷʮ࠷ߴʯCPU༻͕25%ҎԼ 1ͣͭམͱͯ͠3ͭ • ʮ͍࣌ؒʯͷʮฏۉʯͰམͱ͞ͳ͍ ૿͑Δͱ༨༟͕Ͱ͖ΔˠམͪΔˠෛՙ্͕Δˠىಈ! ༨༟͕े͋Δঢ়ଶ͕࣌ؒଓ͍ͨΒམͱ͢ • Ұؾʹམͱ͢ˠෛՙ্͕͕Δˠىಈ!
Slide 49
Slide 49 text
No content
Slide 50
Slide 50 text
εέʔϦϯάϙϦγʔ·ͱΊ ૿͢ͱ͖େʹ → Γͳ͚Εো ݮΒ͢ͱ͖ண࣮ʹ → ݮΒ͗ͨ͢͠Βো ᮢΛ߈Ί͗͢ͳ͍
Slide 51
Slide 51 text
ϔϧενΣοΫ
Slide 52
Slide 52 text
ELBʹΈࠐΉͨΊʹϔϧενΣοΫ͕ඞཁ 1. EC2Πϯελϯε͕ੜ͖͍ͯΔ 2. (ELB͔Β)TCPͰଓͰ͖Δ 3. (ELB͔Β)HTTPͰԠΛ200Ͱฦ͢ ԿΛ࣋ͬͯਖ਼ৗͱஅ͢Δ͔
Slide 53
Slide 53 text
ELBʹΈࠐΉͨΊʹϔϧενΣοΫ͕ඞཁ 1. ❌ EC2Πϯελϯε͕ੜ͖͍ͯΔ → Πϯελϯεىಈ ≠ ΞϓϦέʔγϣϯͷ४උ 2. ❌ TCPͰଓͰ͖Δ → Webαʔόىಈ ≠ ΞϓϦέʔγϣϯαʔόͷ४උ 3. ⭕ HTTPͰԠΛ200Ͱฦ͢ GET /ping HTTP/1.0 ΞϓϦέʔγϣϯαʔόͰDBଓͳͲνΣοΫ͢Δ
Slide 54
Slide 54 text
ELBʹΈࠐΉͨΊʹϔϧενΣοΫ͕ඞཁ Πϯελϯεىಈ࣌ͷࣄނ͕ଟ͍ ! ΞϓϦέʔγϣϯαʔό͕DBͦͷଞʹଓͰ͖Δ →ΞϓϦέʔγϣϯΑΓԼͷͷͳ͍ͣ !
Slide 55
Slide 55 text
ϔϧενΣοΫ·ͱΊ ࣮֬ʹΞϓϦέʔγϣϯͷ४උ͕Ͱ͖͔ͯΒޭͤ͞Δ ΞϓϦέʔγϣϯαʔόʹࢮ׆ࢹΤϯυϙΠϯτΛ༻ҙ
Slide 56
Slide 56 text
ຊʹ͋ͬͨා͍
Slide 57
Slide 57 text
ຊʹ͋ͬͨා͍(1) ىಈޙʹϔϧενΣοΫ͕௨Βͳ͍ Πϯελϯε
Slide 58
Slide 58 text
ϔϧενΣοΫ͕௨Βͳ͍Πϯελϯε͕ൃੜ શͰͳ͍ ىಈޙͷϓϩϏδϣχϯάɺσϓϩΠͳ͍ ͳ͔ͥElasticacheRedisʹܨ͕Βͳ͍ →ΞϓϦέʔγϣϯϨϕϧͰͷϔϧενΣοΫʹࣦഊ
Slide 59
Slide 59 text
ϔϧενΣοΫ͕௨Βͳ͍Πϯελϯε͕ൃੜ ىಈˠআˠىಈˠআ !!! ͩΜͩΜࣦഊ্͕͕֬ΔΑ͏ͳ…
Slide 60
Slide 60 text
ϔϧενΣοΫ͕௨Βͳ͍Πϯελϯε͕ൃੜ ͡ʔͬͱϩάΛݟΔ ʮΉΉɺ͜ͷIPΞυϨεݟ͕֮͑…ʯ
Slide 61
Slide 61 text
ϔϧενΣοΫ͕௨Βͳ͍Πϯελϯε͕ൃੜ աڈʹىಈ͍ͯͨ͠ΠϯελϯεͷIPΞυϨεΛϩά͔Βऩू 10͙Β͍Ұؾʹىಈ͢Δ ࣦഊͨͭ͠ͷIPΞυϨεΛݟΔ
Slide 62
Slide 62 text
Ṗͯ͢...
Slide 63
Slide 63 text
աڈʹ༻͞Εͨ͜ͱ͕ ͋ΔIPΞυϨε͕࠶ׂΓ ͯ͞ΕͨΠϯελϯε ͕ElastcacheRedisʹܨ ͕Βͳ͍
Slide 64
Slide 64 text
աڈʹ༻͞Εͨ͜ͱ͕͋ΔIPΞυϨε͕࠶ׂΓ ͯ͞ΕͨΠϯελϯε͕ElastcacheRedisʹ ܨ͕Βͳ͍ ElasticacheRedisͷARPςʔϒϧϦϑϨογϡʹ͕͋ͬͨ (20156݄࣌) αϙʔτͰݸผରԠ (20158݄2िҎ߱ʹ৽نىಈ͞Εͨnodeͳ͍ͦ͏Ͱ͢)
Slide 65
Slide 65 text
ΞϓϦέʔγϣϯϨϕϧͷ ϔϧενΣοΫΛ͍ͯͯ͠Α͔ͬͨ
Slide 66
Slide 66 text
ຊʹ͋ͬͨා͍(2) ϝϯςφϯεฤ
Slide 67
Slide 67 text
MHAͰDB masterΓସ͑ ΞϓϦέʔγϣϯΛͯ͢ϝϯςϞʔυʹ MHAͰmaster switch
Slide 68
Slide 68 text
ϝϯς໌͚Α͏ͱͨ͠Β ΞϓϦέʔγϣϯαʔό ͕མ͍ͪͯͨ
Slide 69
Slide 69 text
ϔϧενΣοΫͰDBͷଓΛΈ͍ͯͨ DB master͕switch DBͷӬଓଓ͕அ͞ΕΔˠ࣍ͷϦΫΤετͰ࠶ଓ(༧ఆ) AppPlack͕80ϓϩηε ֤ϓϩηε͕அͰΤϥʔΛฦ͢ →ͳ͔ͳ͔ϔϧενΣοΫ͕௨Βͳ͍ →Πϯελϯεterminate
Slide 70
Slide 70 text
ܭըϝϯςͰͳͯ͘DB͕ࢮ͵͜ͱ͋Δ ϔϧενΣοΫ͕௨Βͳ͍ͱΠϯελϯε͕མͪΔ RDSElasticacheͨ·ʹࢮ͵(ͷ͕લఏ)
Slide 71
Slide 71 text
ʮΠϯελϯεͷࣄނ΄΅ىಈ࣌ʯ Ұਖ਼ৗʹىಈͨ͠Πϯελϯε͕ࢮ͵ͷΠϯελϯεো ͕΄ͱΜͲ ઃఆϛεϛυϧΣΞͷͰશ໓͢Δͷ·͍ͣ → Ұਖ਼ৗʹΈࠐ·ΕͨΒΞϓϦέʔγϣϯϨϕϧͷϔϧε νΣοΫ͠ͳ͍ʂ
Slide 72
Slide 72 text
Ұਖ਼ৗʹΈࠐ·ΕͨΒ… at ίϚϯυΛ͏ ࣗಈىಈͷ࠷ޙʹ at 'now + 5 min' -f /usr/local/sbin/confirm-pass-healthcheck ىಈޙ5ͷ࣌ͰELBͰInServiceͩͬͨΒ touch /dev/shm/pass_healthcheck ͱ͍͏ίϚϯυΛ࣮ߦ
Slide 73
Slide 73 text
nginxͷϨϕϧͰϔϧενΣοΫΛฦ͢ location /ping { if (-f "/dev/shm/pass_healthcheck") { return 200; } # ϑΝΠϧ͕ͳ͚ΕΞϓϦέʔγϣϯͷϔϧενΣοΫ proxy_pass http://app; } tmpfsʹஔ͍ͯ͋ΔͷͰෆҙͷ࠶ىಈ͕͋ͬͯىಈ࣌ͱಉ͡
Slide 74
Slide 74 text
ೖΔ͖ELBͰInServiceʹͳ͍ͬͯΔ͔Λஅ #!/bin/bash instance_id=$(curl -s 169.254.169.254/latest/meta-data/instance-id) for elb in $(jq -r ".[]" /etc/elb.conf) do health=$(aws elb describe-instance-health \ --load-balancer-name "${elb}" --instances "${instance_id}") state=$(echo "$health" | jq -r '.InstanceStates[].State') if [[ $state != "InService" ]]; then exit 1 fi done touch /dev/shm/pass_healthcheck
Slide 75
Slide 75 text
ຊʹ͋ͬͨා͍ ·ͱΊ ੈؒݫ͍͠
Slide 76
Slide 76 text
·ͱΊ Φʔτεέʔϧίετݮʹ༗༻ (نʹΑΔ) ߟ͑ํͷมֵΛഭΒΕΔ (ָ͍͠) ͪΌΜͱ੍ޚ͢Δͷେม (େม)