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.1k
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
980
Other Decks in Programming
See All in Programming
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
cmp.Or に感動した
otakakot
2
150
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
初めてDefinitelyTypedにPRを出した話
syumai
0
410
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
イベント駆動で成長して委員会
happymana
1
320
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
ヤプリ新卒SREの オンボーディング
masaki12
0
130
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
Quine, Polyglot, 良いコード
qnighy
4
640
Jakarta EE meets AI
ivargrimstad
0
150
Featured
See All Featured
Site-Speed That Sticks
csswizardry
0
23
Embracing the Ebb and Flow
colly
84
4.5k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Done Done
chrislema
181
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Typedesign – Prime Four
hannesfritz
40
2.4k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
YesSQL, Process and Tooling at Scale
rocio
169
14k
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. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ