Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ECS×Fargateで実現する運用コストほぼ0なコンテナ運用の仕組み/ ecs fargat...

ECS×Fargateで実現する運用コストほぼ0なコンテナ運用の仕組み/ ecs fargate low cost operation

AWS DevDay Online Japan 2020 の登壇資料です

Shoichiro Nagai(shnagai)

October 20, 2020
Tweet

More Decks by Shoichiro Nagai(shnagai)

Other Decks in Technology

Transcript

  1. © 2020, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. In Partnership with ECS×FargateͰ࣮ݱ͢Δ ӡ༻ίετ΄΅0ͳίϯςφӡ༻ͷ࢓૊Έ ίωώτגࣜձࣾ ӬҪউҰ࿠(shnagai) A - 7
  2. "CPVUϚϚϦ 2"ίϛϡχςΟ Ϣʔβʔ͕೰ΈΛ౤ߘɺ૬ஊ͋͠͏2"ػೳ ઐ໳ՈʹΑΔճ౴΋ظؒݶఆͰఏڙ ϝσΟΞ ೛৷ɾҭࣇͳͲͷهࣄΛXFCͱΞϓϦͰ഑৴ ৽ϚϚͷʮਓʹਓʯʹ͝ར༻͍͍͍ͨͩͯΔΞϓϦɺ৘ใϝσΟΞʮϚϚϦʯ 3ਓʹ1ਓ ৽ϚϚͷ ͕ར༻த!

    ※2 ΞϓϦձһ਺ 250ສਓ ϚϚ޲͚No.1ΞϓϦʹબग़ ※1 ʮୈ̔ճ݈߁ण໋Λͷ͹ͦ͏ʂΞϫʔυʯʹͯ ްੜ࿑ಇলࢠͲ΋Ոఉہ௕৆ ड৆ ※1 1,084ਓͷϚϚ͕બͿʮݱࡏ࢖͍ͬͯΔΞϓϦʯ ʹͯɺ5߲໨ (ଞͷϚϚʹΦεεϝ͍ͨ͠ɺೝ஌౓ɺར༻཰ɺརศੑɺ޷ײ౓) Ͱ ̍ҐΛ֫ಘ͠·ͨ͠ɻʮϚϚ޲͚No.1ΞϓϦʯ͸2019೥3݄Πϯςʔδௐ΂ɹௐࠪର৅ɿ೛৷தʙ2ࡀ0ϲ݄ͷࢠڙΛ࣋ͭঁੑʢn=1,084ʣΛநग़ ※2 2019೥ͷʮϚϚϦʯ಺ͷग़࢈༧ఆ೔Λઃఆͨ͠Ϣʔβʔ਺ͱɺްੜ࿑ಇলൃදʮਓޱಈଶ౷ܭʯͷग़ੜ਺͔Βࢉग़
  3. w ϝϯςφϯείετ͕௿͍ w ίϯτϩʔϧϓϨʔϯʹؔͯ͠͸΄΅ҙࣝ͢Δඞཁ͸ͳ͍ w ίϯςφΛͲ͏ಈ͔͔͢ʹ஫ྗग़དྷΔ w "84ͷϦιʔεͱϑϨϯυϦʔ w "-#

    *".ϩʔϧ $MPVE8BUDI&WFOUT 4UFQ'VODUJPOT w ίωώτ͸"84Ͱ΄΅શͯͷγεςϜΛ૊ΜͰ͍ΔͷͰ࿈ܞָ͕ͳͷ͸େࣄ w ֶशίετ΋௿Ί w αʔϏεɺλεΫఆٛɺΫϥελΛ࠷௿ݶ཈͑Ε͹ίϯςφӡ༻ग़དྷΔ w ࣗ༝౓͸௿͍͕ɺίϯςφӡ༻ʹ͋ͨΓઃఆ߲໨΍ߟྀࣄ߲͕গͳ͍ &$4ͷؾʹೖ͍ͬͯΔͱ͜Ζ
  4. ίωώτͰͷ&$4ӡ༻ͷྺ࢙ 2017೥7݄ ECSຊ൪ӡ༻։࢝ DockerΛ࢖ͬͨίϯςφͷຊ൪ӡ༻։࢝ EC2όοΫΤϯυ 2017೥12݄ શαʔϏεΛECSԽ طଘαʔϏεͷҠߦ͕׬ྃ͠શαʔϏεΛECSͰӡ༻ EC2όοΫΤϯυ 2018೥10݄

    Fargateຊ൪ಋೖ FargateΛຊ൪ӡ༻։࢝ ӡ༻ίετܹݮ͕ͩඅ༻Λ཈͑ΔͨΊʹ༷ʑͳ޻෉ 2020೥5݄ Fargate × λʔήοτ௥੻ ServiceAutoScalling FargateͷॊೈੑΛۦ࢖ͨ͠ಈతΩϟύϓϥΛ࣮ݱ ӡ༻ίετ΄΅0Ͱඅ༻΋࡟ݮ
  5. w &$ࣗମͷӡ༻ w Α͠ͳʹ".*ߋ৽ w Α͠ͳʹ&$ϝϯςφϯεରԠ w Α͠ͳʹ&$Λ؂ࢹ w &$4ؔ࿈ͷӡ༻

    w λεΫ਺Λࣄલʹݟӽͨ͠ΩϟύγςΟϓϥϯχϯά͕ඞཁ w Ͳͷ&$Ͱಈ͔͔͢ w λεΫͷ഑ஔ֬ೝ ແବͳ͘഑ஔ͞Ε͍ͯΔ͔  w खಈεέʔϧΞ΢τΠϯ w ΫϥελΛͲ͏૊Ή͔ &$4º&$ߏ੒͸Α͠ͳʹ&$ͷӡ༻ίετ͕ൃੜ
  6. w &$ࣗମͷӡ༻ w Α͠ͳʹ".*ߋ৽ w Α͠ͳʹ&$ϝϯςφϯεରԠ w Α͠ͳʹ&$Λ؂ࢹ w &$4ؔ࿈ͷӡ༻

    w λεΫ਺Λࣄલʹݟӽͨ͠ΩϟύγςΟϓϥϯχϯά͕ඞཁ w λεΫͷ഑ஔ֬ೝ ແବͳ͘഑ஔ͞Ε͍ͯΔ͔  w खಈεέʔϧΞ΢τΠϯ w ΫϥελΛͲ͏૊Ή͔ &$4º&$ߏ੒͸Α͠ͳʹ&$ͷӡ༻ίετ͕ൃੜ ҰͭҰͭ͸͍ܰ ͕ੵΈॏͳΔͱେ͖ͳӡ༻ίετʹ
  7. w λεΫΛಈ͔͢ج൫ͷ&$ͱλεΫࣗମͷεέʔϧΛߟྀ͢Δ ඞཁ͕͋Δ w ग़དྷͳ͘͸ͳ͍͕ෳࡶͳ࢓૊ΈΛࣗલͰӡ༻͠ͳ͚Ε͹ͳΒͳ͍ w &$4$MVTUFS"VUP4DBMJOH͕ղܾͯ͘͠ΕΔ͔΋  IUUQTBXTBNB[PODPNKQBCPVUBXTXIBUTOFXBNB[POFDTDMVTUFSBVUPTDBMJOHOPXBWBJMBCMF 

    w ӡ༻ίετඅ༻ϐʔΫτϥϑΟοΫΛࡹ͚ΔϦιʔεΛࣄલ ʹ༻ҙ w গ਺ͷΠϯϑϥͱ8FCΤϯδχΞͰαʔϏεӡ༻ w ෳࡶͳ࢓૊ΈΛಋೖͨ͠ࡍͷӡ༻ίετ͸େ͖͍ &$4º&$ߏ੒͸Φʔτεέʔϧ͕ෳࡶ
  8. w &$ࣗମͷӡ༻ w Α͠ͳʹ".*ߋ৽ w Α͠ͳʹ&$ϝϯςφϯεରԠ w Α͠ͳʹ&$Λ؂ࢹ w &$4ؔ࿈ͷӡ༻

    w λεΫ਺Λࣄલʹݟӽͨ͠ΩϟύγςΟϓϥϯχϯά͕ඞཁ w λεΫͷ഑ஔ֬ೝ ແବͳ͘഑ஔ͞Ε͍ͯΔ͔  w खಈεέʔϧΞ΢τΠϯ w ΫϥελΛͲ͏૊Ή͔ 'BSHBUFͷొ৔Ͱ&$4ͷӡ༻͕େ෯ʹָʹͳͬͨ ͦ΋ͦ΋EC2͕ෆཁʹ ͢΂ͯϦιʔεׂΓ౰ͯͷ໰୊
  9. w 3*Ͱ&$ˠ'BSHBUF 4BWJOHT1MBOTͳ͠ ͩͱ໿ഒͷඅ༻ w &$όοΫΤϯυ࣌୅ͱಉ͡λεΫ਺Ͱ'BSHBUFʹҠߦ w ౦ژϦʔδϣϯରԠޙ਺ϲ݄Ͱ·ͩࣄྫ΋ͳ͔ͬͨͷͰ҆શʹ IUUQTUFDIDPOOFIJUPDPNFOUSZ w

    අ༻ΛԼ͛ΔͨΊʹλεΫ਺ΛݮΒ͍ͯͬͨ͠ w &$όοΫΤϯυ࣌୅σϓϩΠ༻ʹ֬อ͞ΕͨϦιʔε෼ΛঃʑʹݮΒ͢ w αʔϏεӡ༻ʹ໰୊ͷͳ͍λεΫ਺ΛݟۃΊΔ &$͔Βղ์͞Ε͕ͨඅ༻͕ߴ͍
  10. &$ͱ'BSHBUFͷྉۚൺֱ 1࣌ؒ͋ͨΓͷඅ༻ൺֱ ($/hour) ap-northeast-1 ΦϯσϚϯυ RI / Compute Savings Plans

    ׂҾ཰ EC2 C5.large 0.107 0.063 શֹલ෷͍ 41% Fargate 2vCPU mem4G 0.12324 0.0961272 શֹલ෷͍ 22% Fargate - EC2 0.01624 0.0331272 EC2RI→FargateSV ໿$24/month * ୆਺෼ߴ͍ EC2RI→Fargate ໿$45/month * ୆਺෼ߴ͍ ※SVͳ͠
  11. 'BSHBUFӡ༻Ͱײ͍ͯͨ͡՝୊ w ΦʔτεέʔϦϯά͕௥͍͔ͭͳ͍ w ͔ͤͬ͘'BSHBUFԽͯ͠Φʔτεέʔϧग़དྷΔΑ͏ʹͳͬͨ w ϐʔΫ࣌ؒʹϨΠςϯγҧ൓Ξϥʔτ͕ग़࢝Ίͨ ຖ൩ώϠώϠ  w

    ݟΔͱΦʔτεέʔϧൃಈͯ͠Δ͕ॳಈʹ௥͍͍͍ͭͯͳ͍ w $16τϦΨͷTఔͷىಈόοϑΝͩͱͪΐͬͱ஗͍ w අ༻͕&$࣌୅ͱൺ΂Δͱߴࢭ·Γ͍ͯͨ͠ w λεΫ਺ΛݮΒͯ͠ɺ4BWJOHT1MBOTΛ࢖ͬͯ΋·ͩߴ͍ w ಉ͡αʔϏεΛӡ༻͢ΔͳΒඅ༻͸গͳ͍ͷ͕ਖ਼ٛͰ͢ΑͶ
  12. &$4λʔήοτ௥੻4FSWJDF"VUP4DBMMJOHͷઃఆ஋ ߲໨ ಺༰ ίωώτͰͷઃఆ஋ λʔήοτ஋ ௥੻ͨ͠ϝτϦΫεͰͷ͖͍͠஋ (ฏۉCPU/ฏۉϝϞϦ/λεΫ͋ͨΓͷreq਺) αʔϏεͷੑ࣭ʹΑΓ ݕূ͠ͳ͕Βద੾ͳᮢ஋ΛೖΕΔ εέʔϧΞ΢τ

    Ϋʔϧμ΢ϯظؒ εέʔϧΞ΢τͨ͠ޙͷ଴ػ࣌ؒ (͜ͷؒ͸࿈ଓͰεέʔϧΞ΢τ͸ൃಈ͠ͳ͍) 60s (ෛՙ࣌͸ຖ෼εέʔϧΞ΢τ) εέʔϧΠϯ Ϋʔϧμ΢ϯظؒ εέʔϧΠϯͨ͠ޙͷ଴ػ࣌ؒ (͜ͷؒ͸࿈ଓͰεέʔϧΠϯ͸ൃಈ͠ͳ͍) 900s (Ώͬ͘Γॖୀͯ͠΄͍͠ͷͰ) εέʔϧΠϯͷແޮԽ On/OffͰεέʔϧΠϯΛߦ͏͔Ͳ͏͔ ࠓճͷ໨తͩͱOff
  13. ࠶ܝ 'BSHBUFӡ༻Ͱײ͍ͯͨ͡՝୊ w ΦʔτεέʔϦϯά͕௥͍͔ͭͳ͍ w ϐʔΫ࣌ʹϨΠςϯγҧ൓Ξϥʔτ͕ग़࢝Ίͨ ຖ൩ώϠώϠ  w ݟΔͱΦʔτεέʔϧൃಈͯ͠Δ͕ॳಈʹ௥͍͍͍ͭͯͳ͍

    w අ༻͕&$࣌୅ͱൺ΂Δͱߴࢭ·Γ͍ͯͨ͠ w λεΫ਺ΛݮΒͯ͠ɺ4BWJOHT1MBOTΛ࢖ͬͯ΋·ͩߴ͍ w ಉ͡αʔϏεΛӡ༻͢ΔͳΒඅ༻͸গͳ͍ͷ͕ਖ਼ٛͰ͢ΑͶ
  14. ݱࡏͷ&$4º'BSHBUFӡ༻ w 'BSHBUFԽ͍ͯ͠ΔαʔϏε͸΄΅ϝϯςෆཁͰӡ༻ w 'BSHBUFΤʔδΣϯτͷWରԠ͸͋ΔͷͰͰ͸ͳ͍ w ϐʔΫ࣌ؒଳͷεέʔϧ΋Ξϥʔτͳ͘উखʹ΍ͬͯ͘ΕͯΔײ͡ w අ༻΋'BSHBUFಋೖ࣌ʹൺ΂ͯେ෯ʹ࡟ݮ w

    ฏۉλεΫՔಇ਺͕Լ͕ͬͨͷͰैྔ՝ۚͷԸܙΛͦͷ··ड͚Δ w 4BWJOHT1MBOTͰׂҾͷԸܙΛड͚Δ w εςʔδϯά΍Ұ෦ͷόονͰ͸'BSHBUF4QPUͰେ෯ͳίετΧοτ
  15. ·ͱΊ ΞʔΩςΫνϟ/߲໨ ӡ༻ίετ අ༻ ϙΠϯτ EC2όοΫΤϯυ ˚ લड़ͷEC2ӡ༻ ˕ Reserved,SpotInstanceΛར༻

    Φʔτεέʔϧ͕ෳࡶͳͷͰɺϐ ʔΫτϥϑΟοΫ*਺ഒʹ଱͑͏ ΔΫϥελ(EC2)Λ༻ҙ Fargate ˕ ˚ SavingsPlansΛར༻ λεΫ਺ݮΒ͠EC2όοΫΤϯυ ͱಉ͘͡Β͍ͷඅ༻ײ RI,Spotͱൺֱ͢Δͱߴ͍ͷͰɺϐ ʔΫτϥϑΟοΫʹ଱͑͏ΔΑ͏ λεΫݮΒ͢+Φʔτεέʔϧ(஗ ͍ͱ͍͏՝୊ײ) Fargate × λʔήοτ௥੻ ServiceAutoScalling ˕ ˕ λεΫ਺੍ޚΛECSʹҕ೚ɻ ฏۉతͳλεΫ਺ͷ࡟ݮʹ੒ޭ͠ අ༻ѹॖ
  16. ·ͱΊ ΞʔΩςΫνϟ/߲໨ ӡ༻ίετ අ༻ ϙΠϯτ EC2όοΫΤϯυ ˚ લड़ͷEC2ӡ༻ ˕ Reserved,SpotInstanceΛར༻

    Φʔτεέʔϧ͕ෳࡶͳͷͰɺϐ ʔΫτϥϑΟοΫ*਺ഒʹ଱͑͏ ΔΫϥελ(EC2)Λ༻ҙ Fargate ˕ ˚ SavingsPlansΛར༻ λεΫ਺ݮΒ͠EC2όοΫΤϯυ ͱಉ͘͡Β͍ͷඅ༻ײ RI,Spotͱൺֱ͢Δͱߴ͍ͷͰɺϐ ʔΫτϥϑΟοΫʹ଱͑͏ΔΑ͏ λεΫݮΒ͢+Φʔτεέʔϧ(஗ ͍ͱ͍͏՝୊ײ) Fargate × λʔήοτ௥੻ ServiceAutoScalling ˕ ˕ λεΫ਺੍ޚΛECSʹҕ೚ɻ ฏۉతͳλεΫ਺ͷ࡟ݮʹ੒ޭ͠ අ༻ѹॖ 'BSHBUFͷϝϦοτΛ׆༻ͯ͠ ӡ༻ෛՙΛۃྗ௿͘ίϯςφӡ༻͢Δ͜ͱ͕ &$4Λબ୒͢ΔڧΈͩͱߟ͍͑ͯΔ
  17. Thank you! © 2020, Amazon Web Services, Inc. or its

    affiliates. All rights reserved. In Partnership with ίωώτגࣜձࣾ ӬҪউҰ࿠(shnagai)