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
WEARのEKSコストを救いたい
Search
mi.kobaaaa
February 26, 2023
Programming
1
3.2k
WEARのEKSコストを救いたい
【Autify x ZOZO x dip共同開催】AWSコスト削減事例祭り
https://zozotech-inc.connpass.com/event/273113/
mi.kobaaaa
February 26, 2023
Tweet
Share
More Decks by mi.kobaaaa
See All by mi.kobaaaa
WEAR のワークフロー実行基盤コストを何とかしたい
mikobaaaaa0920
0
1k
Other Decks in Programming
See All in Programming
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
Zoneless Testing
rainerhahnekamp
0
120
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
2
370
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
1
390
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
670
Spatial Rendering for Apple Vision Pro
warrenm
0
130
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
350
ドメインイベント増えすぎ問題
h0r15h0
2
410
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
500
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
160
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The Language of Interfaces
destraynor
154
24k
Gamification - CAS2011
davidbonilla
80
5.1k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Transcript
WEARͷEKSίετΛٹ͍͍ͨ גࣜձࣾZOZO ϒϥϯυιϦϡʔγϣϯ։ൃຊ෦ όοΫΤϯυ෦ SREϒϩοΫ খྛ ະདྷ Copyright © ZOZO,
Inc. AWSίετݮࣄྫࡇΓ
© ZOZO, Inc. ࣗݾհ
© ZOZO, Inc. גࣜձࣾZOZO ϒϥϯυιϦϡʔγϣϯ։ൃຊ෦ όοΫΤϯυ෦ SREϒϩοΫ খྛ ະདྷ •
@mirai_kobaaaaaa • ΏΔ;ΘܥSRE • ͖ͳαʔϏεɿAWS CDK
© ZOZO, Inc.
None
© ZOZO, Inc. https://zozo.jp/ 6 • ϑΝογϣϯEC • 1,500Ҏ্ͷγϣοϓɺ8,500Ҏ্ͷϒϥϯυͷऔΓѻ͍ •
ৗ࣌90ສҎ্ͷΞΠςϜͱຖฏۉ2,600Ҏ্ͷ৽ண Λܝࡌʢ202212݄࣌ʣ • ϒϥϯυݹணͷϑΝογϣϯκʔϯʮZOZOUSEDʯίεϝઐ ϞʔϧʮZOZOCOSMEʯɺۺͷઐϞʔϧ ʮZOZOSHOESʯɺϥάδϡΞϦʔˍσβΠφʔζκʔϯ ʮZOZOVILLAʯΛల։ • ଈૹαʔϏε • ΪϑτϥοϐϯάαʔϏε • πέ͍ ͳͲ
© ZOZO, Inc. https://wear.jp/ 7 • ϑΝογϣϯίʔσΟωʔτΞϓϦ • 1,600ສμϯϩʔυಥഁɺίʔσΟωʔτߘ૯1,300ສ݅ Ҏ্ʢ202212݄࣌ʣ
• ϐοΫΞοϓλά͔Β࠷৽ͷτϨϯυΛνΣοΫ • ίʔσΟωʔτண༻ΞΠςϜΛެࣜαΠτͰߪೖՄೳ • WEARެೝͷਓؾϢʔβʔΛWEARISTAͱೝఆɻϞσϧɾλϨϯ τɾσβΠφʔɾΠϯϑϧΤϯαʔͱ͍֤ͬͨքஶ໊ਓࢀՃ
© ZOZO, Inc. ຊ͓͢͠Δ͜ͱ
© ZOZO, Inc. ຊ͓͢͠Δ͜ͱ • WEAR ʹ͓͚Δ EKS ίετ࠷దԽʹ͚ͨଧͪख ◦
ݱঢ়ͷऔΓΈͱࠓޙͷଧͪख ◦ ௐࠪͨ݁͠ՌɺԿ͕՝ͩͬͨͷ͔ ◦ ͳͥ࠷దԽ͕ඞཁͳͷ͔ ຊ͓͠͠ͳ͍͜ͱ • EKS (Amazon Elastic Kubernetes Service) ͷࡉ͔ͳ༷ • ෦ΞϓϦέʔγϣϯͷৄࡉ • Kubernetes ͷ֓ཁɺৄࡉ
© ZOZO, Inc. ͋Ε2022
© ZOZO, Inc. AWS ίετ૿Λݕ • EKS ίετ͕૿Ճ ◦ ࣌
ECS => EKS ͷϦϓϨΠεϓϩδΣΫτ͕ਐߦத ◦ ͦͷͨΊଟগͷίετ૿Ճఆൣғͱ͍ͯͨ͠
© ZOZO, Inc. AWS ίετ૿Λݕ • ཌ݄ɺߋʹ EKS ίετ͕૿Ճ ◦
2ϲ݄લͱൺͯ10ഒ ◦ ҟৗͱஅ͠ௐࠪ։࢝ 10ഒ
© ZOZO, Inc. ௐࠪ݁Ռ
© ZOZO, Inc. ௐࠪ݁Ռ • όονॲཧϫʔΫϑϩʔΛ࣮ߦ͢Δ Cluster ͷίετ͕ٸ૿͍ͯͨ͠ ◦ 2,400pod/day
͕࣮ߦ͞Ε͍ͯΔ ◦ Fargate ͷΈͰߏ Mecha Ippai Fargate Batch Cluster
© ZOZO, Inc. ௐࠪ݁Ռ • όονॲཧϫʔΫϑϩʔΛ࣮ߦ͢Δ Cluster ͷίετ͕ٸ૿͍ͯͨ͠ ◦ 2,400pod/day
͕࣮ߦ͞Ε͍ͯΔڥ ◦ Fargate ͷ༻ྔ͕૿Ճ͠ίετ͕ਹΜͰ͍ͨ Mecha Ippai Fargate Batch Cluster ͕͜͜ʂ
© ZOZO, Inc. උߟɿEKSίετͷߟ͑ํ • EKSίετԼهͷ߹ࢉͰܭࢉ͞ΕΔ ◦ Kubernetes Worker Node
࣮ߦڥͷίετ ◦ EKS Cluster ͷίετ Amazon EKS + AWS Fargate Amazon EC2 EKS Cluster Kubernetes Worker Nodes
© ZOZO, Inc. උߟɿWorker Node ͷίετ • Fargate ͷ߹ ◦
Image Pull ։͔࢝Β Pod ͕ऴྃ͢Δ·Ͱʹ༻͞ΕͨϦιʔεͰܭࢉ ◦ ࣮ߦ͞ΕΔ Fargate ͷεϖοΫʹΑΓࢉग़ AWS Fargate 1࣌ؒͨΓͷ vCPU ୯Ґ 1࣌ؒͨΓͷ GB ୯Ґ Pod × ×
© ZOZO, Inc. උߟɿWorker Node ͷίετ Ex. 2ͷ EKS Pod
Λ30ϑϧՔಇͤͨ͞߹ Pod ͷεϖοΫ 1vCPU, 2GBϝϞϦͱ͢Δ ߹ܭ vCPU ྉۚ = (Pod ) × (vCPU ) × (CPU ࣌ؒ͋ͨΓͷྉۚ) × (࣌ؒ୯Ґͷ 1 ͋ͨΓͷ CPU ༻࣌ؒ) × () ߹ܭϝϞϦྉۚ = (Pod ) × (ϝϞϦ (GB)) × (GB ͋ͨΓͷྉۚ) × (࣌ؒ୯Ґͷ 1 ͋ͨΓͷ ϝϞϦ ༻࣌ؒ) × () Fargate ͷίϯϐϡʔςΟϯάͷֹ݄ྉۚ = (CPU ֹ݄ྉۚ) + (ϝϞϦͷֹ݄ྉۚ) ྫ Fargate ͷίϯϐϡʔςΟϯάͷֹ݄ྉۚ = 72.8064USD + 2.4348USD = 88.74USD ྫ vCPU ྉۚ = 2 × 1 × 0.05056USD × 24 × 30 = 72.81USD ྫϝϞϦྉۚ = 2 × 2 × 0.00553USD × 24 × 30 = 15.93USD ※2023/2/10࣌Ͱͷ౦ژϦʔδϣϯྉ͔ۚΒࢼࢉ
© ZOZO, Inc. උߟɿWorker Node ͷίετ • EC2 ͷ߹ ◦
Managed Node Group ͷ߹ࢉग़ํ๏ಉ͡ ◦ Worker Node ࣮ߦͷͨΊʹ༻ͨ͠ AWS ϦιʔεͰࢉग़ EC2 Πϯελϯείετ EBS ϘϦϡʔϜ Πϯελϯε × × Amazon EC2
© ZOZO, Inc. උߟɿWorker Node ͷίετ Ex. 2ͷ EKS Pod
Λ30ϑϧՔಇͤͨ͞߹ ߹ܭΠϯελϯεྉۚ = (ΠϯελϯελΠϓͷ࣌ؒͨΓྉۚ) × (Πϯελϯε) × (Πϯελϯε࣌ؒ) ߹ܭ EBS ྉۚ = (1 ϲ݄ʹϓϩϏδϣχϯά͞Εͨ GB) × (1 ϲ݄͋ͨΓͷΠϯελϯε࣌ؒ) × (1 GB ͋ͨΓͷֹ݄ྉۚ) ※2023/2/10࣌Ͱͷ౦ژϦʔδϣϯྉ͔ۚΒࢼࢉ Pod ͷεϖοΫ 1vCPU, 2GBϝϞϦͱ͢Δ ྫ߹ܭ EBS ྉۚ = 20 × (720 ࣌ؒ / 730࣌ؒ) × 0.12USD = 2.38USD ྫ߹ܭΠϯελϯεྉۚ = 0.107USD × 1 × 720 = 77.04 USD ྫͰ͋Ε 2vCPU, 4GBϝϞϦ͕ඞཁͰ͋ΔͨΊɺc5.large ͔ͭ ൚༻SSD (gp2: 20GB)Ͱܭࢉ͢Δ ྫ߹ܭ EC2 ྉۚ = 77.04 USD + 2.38USD = 79.42USD
© ZOZO, Inc. උߟɿWorker Node ͷίετ Ex. 2ͷ EKS Pod
Λ30ϑϧՔಇͤͨ͞߹ ߹ܭΠϯελϯεྉۚ = (ΠϯελϯελΠϓͷ࣌ؒͨΓྉۚ) × (Πϯελϯε) × (Πϯελϯε࣌ؒ) ߹ܭ EBS ྉۚ = (1 ϲ݄ʹϓϩϏδϣχϯά͞Εͨ GB) × (1 ϲ݄͋ͨΓͷΠϯελϯε࣌ؒ) × (1 GB ͋ͨΓͷֹ݄ྉۚ) ※2023/2/10࣌Ͱͷ౦ژϦʔδϣϯྉ͔ۚΒࢼࢉ Pod ͷεϖοΫ 1vCPU, 2GBϝϞϦͱ͢Δ ྫ߹ܭ EBS ྉۚ = 20 × (720 ࣌ؒ / 730࣌ؒ) × 0.12USD = 2.38USD ྫ߹ܭΠϯελϯεྉۚ = 0.107USD × 1 × 720 = 77.04 USD ྫͰ͋Ε 2vCPU, 4GBϝϞϦ͕ඞཁͰ͋ΔͨΊɺc5.large ͔ͭ ൚༻SSD (gp2: 20GB)Ͱܭࢉ͢Δ ྫ߹ܭ EC2 ྉۚ = 77.04 USD + 2.38USD = 79.42USD Fargateͷࠩ10% ※Fargate or EC2 ӡ༻ίετؑΈΔඞཁ͕͋Γ·͢ɻ͝ҙԼ͍͞ɻ
© ZOZO, Inc. ଧͪख
© ZOZO, Inc. ଧͪख • ଧͪखͱͯ͠ԼهΛݕ౼ ▪ ࣮ࡍͷϝτϦΫε͔Β Fargate Pod
ͷ࣮ߦ spec Λௐ ◦ Fargate spec ͷ optimize ◦ EKS on Fargate ͔Β EKS on EC2 ͷҠߦ ◦ Fargate ࣮ߦ࣌ؒͷݮ ▪ ෆཁͳ Fargate Pod ͷࣗಈআ Image Pull ͷվળ ▪ EKS on EC2 Ҡߦ͢Δ͜ͱʹΑΔίετѹॖ
© ZOZO, Inc. Fargate spec ͷ optimize • Datadog μογϡϘʔυ͔Β
pod ͷར༻ϝτϦΫεΛνΣοΫ
© ZOZO, Inc. Fargate spec ͷ optimize • ࣮ࡍͷϝτϦΫε͔Βඞཁ spec
Λ࠶ࢉग़͠ɺManifest Λमਖ਼ • ෳͷ Deployment શͯʹରͯ͠ௐ
© ZOZO, Inc. Fargate ࣮ߦ࣌ؒͷݮ • ϫʔΫϑϩʔ࣮ߦྃޙʹ Fargate Pod ͕আ͞ΕΔ·Ͱͷ࣌ؒΛઃఆ
• كʹϫʔΫϑϩʔ࣮ߦྃޙʹআ͞Εͳ͍ Fargate Pod ͕ଘࡏ͍ͯͨ͠ ◦ job ʹରͯ͠ .spec.ttlSecondsAfterFinished ΛՃ
© ZOZO, Inc. Fargate ࣮ߦ࣌ؒͷݮ • Image ѹॖΞϧΰϦζϜมߋʹΑΔ Image Pull
࣌ؒͷݮ • gzip ѹॖํ͔ࣜΒ zstd ѹॖํࣜʹมߋ͢Δ͜ͱͰ Image αΠζΛѹॖ
© ZOZO, Inc. Fargate ࣮ߦ࣌ؒͷݮ • Image ѹॖΞϧΰϦζϜมߋʹΑΔ Image Pull
࣌ؒͷݮ • gzip ѹॖํ͔ࣜΒ zstd ѹॖํࣜʹมߋ͢Δ͜ͱͰ Image αΠζΛѹॖ • WEARͰ Image Pull ࣌ؒͷӨڹগͳ͔ͬͨͨΊҰ୴ޙճ͠ 5%ఔѹॖ
© ZOZO, Inc. Fargate ࣮ߦ࣌ؒͷݮ • AWS ެࣜΑΓϒϩά͕ެ։͞Ε͍ͯ·͢ͷͰੋඇ͝ҰಡԼ͍͞ʂ ref. https://aws.amazon.com/jp/blogs/news/reducing-aws-fargate-startup-times-with-zstd-compressed-container-images/
© ZOZO, Inc. EKS on Fargate ͔Β EKS on EC2
ͷҠߦ ※ݕূத • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ Batch Cluster Fargate Fargate Batch Cluster EC2 EC2
© ZOZO, Inc. • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ Batch Cluster
Fargate Fargate Batch Cluster EC2 EC2 ◦ Fargate Λഇࢭ͠ɺશͯ EC2 ʹࡌͤସ͑Δ ◦ EC2 Managed Node Group Λར༻͠ɺӡ༻ίετ͑Δ EKS on Fargate ͔Β EKS on EC2 ͷҠߦ ※ݕূத
© ZOZO, Inc. • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ • ୯७ͳ
EKS on EC2 ͷҠߦͰͳ͘ɺPod ͷੑ࣭ຖʹஔ͢ΔϊʔυΛௐ Batch Cluster EC2 Critical Group EC2 Common Group EKS on Fargate ͔Β EKS on EC2 ͷҠߦ ※ݕূத
© ZOZO, Inc. Batch Cluster EC2 Critical Group EC2 Common
Group ࣮ߦڥʹߴ͍ Πϯελϯεੑೳ͕ෆཁͳPod Ex. Operator EKS on Fargate ͔Β EKS on EC2 ͷҠߦ ※ݕূத • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ • ୯७ͳ EKS on EC2 ͷҠߦͰͳ͘ɺPod ͷੑ࣭ຖʹஔ͢ΔϊʔυΛௐ
© ZOZO, Inc. Batch Cluster EC2 Critical Group EC2 Common
Group EKS on Fargate ͔Β EKS on EC2 ͷҠߦ ※ݕূத • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ • ୯७ͳ EKS on EC2 ͷҠߦͰͳ͘ɺPod ͷੑ࣭ຖʹஔ͢ΔϊʔυΛௐ ࣮ߦڥʹߴ͍ Πϯελϯεੑೳ͕ඞཁͳPod Ex. σʔλॲཧ
© ZOZO, Inc. ◦ Manifest ʹ Node Affinity ΛՃ͠એݴతʹϊʔυΛબ EKS
on Fargate ͔Β EKS on EC2 ͷҠߦ ※ݕূத • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ • ୯७ͳ EKS on EC2 ͷҠߦͰͳ͘ɺPod ͷੑ࣭ຖʹஔ͢ΔϊʔυΛௐ
© ZOZO, Inc. Batch Cluster EC2 Critical Group EC2 Common
Group Deployment Critical Deployment Common EKS on Fargate ͔Β EKS on EC2 ͷҠߦ ※ݕূத ◦ Manifest ʹ Node Affinity ΛՃ͠એݴతʹϊʔυΛબ • Pod ࣮ߦج൫Λ EC2 ʹมߋ͢Δ͜ͱͰɺߋͳΔίετѹॖΛਤΔ • ୯७ͳ EKS on EC2 ͷҠߦͰͳ͘ɺPod ͷੑ࣭ຖʹஔ͢ΔϊʔυΛௐ
© ZOZO, Inc. ·ͱΊ
© ZOZO, Inc. ·ͱΊ WEARʹ͓͚Δ EKS ίετݮʹ·ͭΘΔ͋Ε͜ΕΛհ͠·ͨ͠ • ·ͣίετΛ Watch
͢Δ͜ͱ • ݱঢ়ʹ߹Θͤͨ࠷దԽΛଓ͚͍ͯ͘͜ͱ • αʔϏεͷϦιʔεΛ؍ଌ͠ଓ͚Δ͜ͱ ৭ʑ͓͠͠·͕ͨ͠ɺେͳ͜ͱԼه3ͩͱߟ͍͑ͯ·͢ ਐߦதͰ͋Γ·͕͢ɺϐʔΫ࣌ͷ50%ఔ·Ͱίετݮ͕Ͱ͖͍ͯ·͢
© ZOZO, Inc. Զͨͪͷઓ͍͜Ε͔Βͩʂ
© ZOZO, Inc. We are hiring!
© ZOZO, Inc. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ