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
ヤプリにおけるAWSコスト最適化の取り組み
Search
kmitsuhashi
October 30, 2023
Technology
0
560
ヤプリにおけるAWSコスト最適化の取り組み
kmitsuhashi
October 30, 2023
Tweet
Share
More Decks by kmitsuhashi
See All by kmitsuhashi
累計ダウンロード数1億8000万を超えるアプリケーションプラットフォームのレガシーシステム脱却とモダン化への道
kmitsuhashi
0
340
Other Decks in Technology
See All in Technology
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
110
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
300
AWS環境におけるランサムウェア攻撃対策の設計
nrinetcom
PRO
0
170
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
200
20241218_今年はSLI/SLOの導入を頑張ってました!
zepprix
0
100
Work as an App Engineer
lycorp_recruit_jp
0
360
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
3
1.4k
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
500
クレカ・銀行連携機能における “状態”との向き合い方 / SmartBank Engineer LT Event
smartbank
2
100
Wantedly での Datadog 活用事例
bgpat
2
680
.NET 9 のパフォーマンス改善
nenonaninu
0
1.3k
[JAWS-UG新潟#20] re:Invent2024 -CloudOperationsアップデートについて-
shintaro_fukatsu
0
120
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Documentation Writing (for coders)
carmenintech
67
4.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
The Language of Interfaces
destraynor
154
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Building an army of robots
kneath
302
44k
Building Your Own Lightsaber
phodgson
103
6.1k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Transcript
ϠϓϦʹ͓͚Δ AWSίετ࠷దԽͷ औΓΈ
Speaker ϓϩμΫτ։ൃຊ෦ ج൫෦ SREάϧʔϓ ࡾڮ ᇈଠ େखSIerͰΠϯϑϥΤϯδχΞ/ΫϥυΞʔΩςΫ τͱͯ͠ͷܦݧΛੵΈɺ20224݄ΑΓϠϓϦͷ SREϝϯόʔͱͯ͠δϣΠϯɻݱࡏSREϓϥΫς ΟεͷಋೖΛத৺ͱͨ͠ۀʹྭΜͰ͍ΔɻAWSͱ
New Relicͱ່(ࠓ࢈·Εͨ)ͱϛχνϡΞμοΫε (·ͩࣂͬͯͳ͍)͕͖ɻҭٳ෮ؼϗϠϗϠ
01 02 03 04 05 AWSίετ࠷దԽͷऔΓΈഎܠ ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ ۩ମతͳίετ࠷దԽࢪࡦ ͦͷଞͷऔΓΈ ·ͱΊͱࠓޙͷ՝
01 AWSίετ࠷దԽͷ औΓΈഎܠ
͜Ε·Ͱ։ൃεϐʔυαʔϏε࣭͕༏ઌͰੵۃతͳࢿ͕ߦΘΕ͖͕ͯͨɺԁ҆ͷ ӨڹʹΑΓίετ͕ॏཁࢹ͞ΕΔΑ͏ʹͳͬͨ ԁ҆ͷӨڹͰίετ͕ॏཁࢹ͞Ε࢝ΊΔ 01 AWSίετ࠷దԽͷऔΓΈഎܠ ্ঢ 20211݄ 5݄ 9݄ 20221݄
5݄ 9݄ ച্ʹର͢ΔΠϯϑϥίετൺ
ΠϨΪϡϥʔͳίετ૿ʹରԠ͖ͯͨ͠ 01 AWSίετ࠷దԽͷऔΓΈഎܠ • ίετͷେ͖͍AWSΞΧϯτͷίετਪҠΛि࣍Ͱ֬ೝ͠ରԠΛߦ͖ͬͯͨ • AWSͰCost Anomaly DetectionͰҟৗͷࣗಈݕग़Ͱ͖ΔΑ͏ʹ͍ͯ͠Δ 0
50 100 150 200 9/1 9/2 9/3 9/4 9/5 9/6 9/7 RDS ECS CloudWatch ࢹͰͷίετ૿Ճ ͷ֬ೝ Cost Anomaly DetectionͰͷࣗಈݕग़
ैདྷͷΓํͷམͱ݀͠ 01 AWSίετ࠷దԽͷऔΓΈഎܠ • ͦͦͷίετ͕࠷దͰ͋ΔͱݶΒͳ͍ • ࠓճͷΑ͏ʹதظεύϯͰΠϯϑϥίετͷൺ্͕ঢ͍ͯ͠Δ߹ʹؾ͚ͮͳ͍ 0 50 100
150 200 9/1 9/2 9/3 9/4 9/5 9/6 9/7 RDS ECS CloudWatch ࣮࠷ॳ͔ΒաεϖοΫ ظ͔͠ݟ͍ͯͳ͍
৽ͨʹ໘ͭͭ͋͠Δ՝ 01 AWSίετ࠷దԽͷऔΓΈഎܠ ࣄۀ֦େʹ͍૿Ճ͢ΔAWSΞΧϯτʹ͕ಧ͔ͳ͘ͳΓͭͭ͋Δ prod stg dev prod stg dev
prod stg dev αʔϏεA༻ͷΞΧϯτ αʔϏεB༻ͷΞΧϯτ αʔϏεBͷҕୗઌ༻ͷ ΞΧϯτ SREνʔϜ શһ͕Ѳ Ұ෦ϝϯ όʔͷΈѲ ར༻ঢ়گෆ໌
01 AWSίετ࠷దԽͷऔΓΈഎܠ ࠓճͷऔΓΈʹΑΓ ͜Ε·Ͱͷ՝Λղܾ͢Δͱͱʹɺ ظؒͰ$10,000/݄ͷίετΛ ݮ͢Δ͜ͱʹޭͨ͠
02 ͲͷΑ͏ʹίετ࠷దԽʹ औΓΜ͔ͩ
Cloud Financial Management(CFM)ϑϨʔϜϫʔΫʹ͋ΔΑ͏ʹܧଓతͳίετ࠷దԽ Λ࣮ݱ͢ΔʹՄࢹԽ͕ඞཁͰ͋Δ ՄࢹԽ͔Β࢝ΊΔ 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ՄࢹԽ https://aws.amazon.com/jp/blogs/news/aws-cost-optimization-guidebook/
ίετΛ࠷దԽ͠Ϧιʔε ޮͱՁΛ࠷େԽ͢Δ
• ΞΧϯτԣஅͰίετਪҠΛ֬ೝ͍ͨ͠ • தظͰͷΛੳͰ͖ΔΑ͏ʹ͍ͨ͠ • Cost ExplorerͷΑ͏ʹৄࡉͳྉۚ༁͕ݟ͑ΔΑ͏ʹ͍ͨ͠ ͱݴͬͯ… • ࡞ΓࠐΈಋೖϝϯςφϯε͕େมͳͷͰආ͚͍ͨ
• खಈͰͷΦϖϨʔγϣϯۃྗආ͚͍ͨ • Cost ExplorerͰຖճؤுΔͷͭΒ͍ ࠷ߴͷμογϡϘʔυΛ࡞Γ͍ͨʂʂ 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ՄࢹԽ
AWS͔Βఏڙ͞Ε͍ͯΔίετ࠷దԽͷͨΊͷμογϡϘʔυ ςϯϓϨʔτ͕ఏڙ͞Ε͍ͯΔͨΊͰߏங͕Մೳ Cloud Intelligence Dashboards(CID)ʂʂ 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ՄࢹԽ https://www.wellarchitectedlabs.com/cost/200_labs/200_cloud_intelligence/
༷ʑͳαʔϏεͱ࿈ܞ ؍ͷҟͳΔμογϡ ϘʔυΛෳఏڙ
CIDͷಛ 1 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ՄࢹԽ ͲͷΞΧϯτͷͲͷϦιʔε ͷίετ͕ߴ͍͔Ұྎવ தظͰͷΞΧϯτશମͷ ίετਪҠ͕Θ͔Δ
https://d1s0yx3p3y3rah.cloudfront.net/anonymous-embed?dashboard=cudos
CIDͷಛ 2 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ՄࢹԽ S3 Storage Lens ͳͲͷίετ࠷దԽʹཱͭػೳ
ͱͷ࿈ܞ ίετ࠷దԽͷͨΊͷਪࣄ ߲Λදࣔ https://d1s0yx3p3y3rah.cloudfront.net/anonymous-embed?dashboard=cudos
CIDͷಛ 3 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ՄࢹԽ https://d1s0yx3p3y3rah.cloudfront.net/anonymous-embed?dashboard=cudos ࠓޙ༗ྉԽ͞ΕΔϦιʔεʹ ૉૣ͘ରԠ
• ਝʹίετΛ࠷దԽ͢ΔΫΠοΫΟϯ࠷దԽࢪࡦ͔Βݕ౼͢Δ • ఆ൪ͷࢪࡦ͚ͩͰͳ͘ɺ͔ͬ͠Γੳ্ͨ͠ͰࣗࣾͰͷΫΠοΫΟϯࢪࡦΛࡧ͢Δ ࠷దԽࢪࡦΛݕ౼͢Δ 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ࠷దԽ https://aws.amazon.com/jp/blogs/news/aws-cost-optimization-guidebook/
ఆ൪ͷΫΠοΫΟϯ ࠷దԽࢪࡦ
1. ίετͷେ͖͍ϦιʔεΛϦετΞοϓ͠ɺݪҼੳΛߦ͏ 2. ࠷దԽ༨͕͋ΔϦιʔεʹର͠ࢪࡦΛݕ౼͢Δ 3. ࢪࡦͷ࣮ࢪޮՌͱ࣮ࢪΛࢉग़͠༏ઌΛ͚ͭΔ қରޮՌͰࢪࡦʹ༏ઌΛ͚ͭΔ 02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ -
࠷దԽ https://aws.amazon.com/jp/blogs/news/aws-cost-optimization-framework/
02 ͲͷΑ͏ʹίετ࠷దԽʹऔΓΜ͔ͩ - ࠷దԽ ΞΧϯτ αʔϏε ݱঢ় ࢪࡦ ݮֹ
༏ઌॱҐ ํ Account A RDS m5.8xlarge εϖοΫ࠷దԽ $XXX/݄ 5 3 XXXͷͨΊอཹ Account A S3 ແظݶอଘ ϥΠϑαΠΫϧ ϙϦγʔઃఆ $XXX/݄ 2 2 ࣮ࢪ͢Δ Account B ElastiCache ෆཁϦιʔεՔ ಇ Ϧιʔεআ $XXX/݄ 1 1 ࣮ࢪ͢Δ Account A DynamoDB ΦϯσϚϯυΩ ϟύγςΟ ϦβʔϒυΩϟ ύγςΟߪೖ $XXX/݄ 3 4 XXXͷͨΊ࣮ࢪ ͠ͳ͍ ɾɾɾ
03 ۩ମతͳίετ࠷దԽࢪࡦ
S3 VPCΤϯυϙΠϯτΛར༻͢Δ 03 ۩ମతͳίετ࠷దԽࢪࡦ • ϓϥΠϕʔταϒωοτ͔ΒS3ΞΫηεͷࡍʹNAT GateawayΛ௨ΔΑ͏ʹͳ͍ͬͯͨ • S3ʹஔ͔ΕͨେྔͷassetσʔλʹΞΫηε͢ΔͨΊಛʹྉ͕ۚߴ͘ͳ͍ͬͯͨ ※
ap-northeast-1ϦʔδϣϯͰͷ20238݄25ݱࡏͷՁ֨ ແྉ Private subnet Public subnet VPC Endpoint (Gateway) AWS Fargate NAT Gateway Amazon Simple Storage Service (Amazon S3) asset $0.062/GB ※
• ΄ͱΜͲͷS3όέοτʹϥΠϑαΠΫϧϙϦγʔ͕ઃఆ͞Ε͍ͯͳ͔ͬͨ • S3 Storage LensͰංେԽ͍ͯ͠ΔόέοτΛಛఆ͠ରԠΛߦͬͨ S3ϥΠϑαΠΫϧϙϦγʔΛઃఆ͢Δ 03 ۩ମతͳίετ࠷దԽࢪࡦ S3
Standard S3 Glacier Instant Retrieval Archive Delete όέοτ͝ͱʹཁ݅ ʹ߹Θͤͯઃఆ Ҡߦ࣌ʹίετ͕ Ͷͳ͍͜ͱΛ֬ೝ
• σϑΥϧτͰContainer Insights༗ޮԽʹͳ͍ͬͯͨ • ಛʹ։ൃڥͰ50ۙ͘ͷECSΫϥελʔ͕ར༻͞Ε͓ͯΓɺେྔͷΧελϜϝτϦΫε ͕ૹ৴͞Ε͍ͯͨ ։ൃڥͷContainer InsightsແޮԽ͢Δ 03 ۩ମతͳίετ࠷దԽࢪࡦ
େྔͷΧελ ϜϝτϦΫε CloudWatch ECS Cluster ECS Cluster ECS Cluster ɾ ɾ ɾ
• ۀ࣌ؒʹ߹Θͤͯࣗಈىಈ/ఀࢭΛߦ͍͕ͬͯͨɺҰதར༻͞Εͳ͍͜ͱ͋ͬͨ • ։ൃऀ͕slack commandΛ͖ͬͯͳλΠϛϯάͰڥΛ্ཱͪ͛ΒΕΔΑ͏ʹͨ͠ ։ൃڥΛσϑΥϧτఀࢭʹ͢Δ 03 ۩ମతͳίετ࠷దԽࢪࡦ User AWS
Lambda ؒࣗಈఀࢭ EC2 & Fargate slack command API Call Πϯϑϥىಈ
• CloudWatch Logsͷϩάอ࣋ظؒઃఆ • ։ൃڥͷAuroraಉظσʔλͷݟ͠ • ෆཁϦιʔεͷఀࢭ/আ • AuroraόοΫΞοϓσʔλอ࣋ظؒݟ͠ •
։ൃڥϦιʔεͷڞ௨Խ • etc. ͦͷଞͷࢪࡦ 03 ۩ମతͳίετ࠷దԽࢪࡦ
04 ͦͷଞͷऔΓΈ
• ि࣍ఆྫͰͷίετ֬ೝରΞΧϯτΛݶఆ͍ͯ͠ΔͨΊɺ݄࣍ͰΞΧϯτશମͷ ίετਪҠΛݟΔΑ͏ʹ͍ͯ͠Δ(ݱঢ়खಈͷͨΊྑ͍ํ๏Λࡧத) ݄࣍ͰΞΧϯτશମͷίετΛৼΓฦΔ 04 ͦͷଞͷऔΓΈ ຖ݄ ROIΛධՁ
• ։ൃڥಉҰϦιʔε͕ෳ͋Γɺಛੑ͕ҟͳΔͨΊɺCIDͷଞʹNew RelicΛ׆༻ͯ͠ ֤໘ͷར༻ঢ়گݟ͑ΔΑ͏ʹ͍ͯ͠Δ ։ൃڥར༻ঢ়گΛՄࢹԽ͢Δ 04 ͦͷଞͷऔΓΈ
05 ·ͱΊͱࠓޙͷ՝
• CFMϑϨʔϜϫʔΫʹଇΓίετՄࢹԽͷΈΛಋೖͨ͜͠ͱͰɺFinOps࣮ફͷͨΊ ͷୈҰาΛ౿Έग़͢͜ͱ͕Ͱ͖ͨ • ΫΠοΫΟϯ࠷దԽΛ࣮ࢪ͢Δ͜ͱͰظؒͰ$10,000/݄ͷίετΛݮ͢Δ͜ͱʹ ޭͨ͠ ·ͱΊ 05 ·ͱΊͱࠓޙͷ՝
• ύϒϦοΫIPv4ͷ༗ྉԽʹ͏ରԠΛݕ౼/࣮ࢪ͢Δ • αʔϏε͝ͱʹதظతͳΛߟྀͨ͠ίετ࠷దԽࢦඪΛݕ౼͢Δ (ROIΛݟΔ͚ͩͰෛՙରࡦͷͨΊͷϦιʔε૿ڧ࣌ʹਖ਼͘͠ධՁͰ͖ͳ͍) • FinOpsΛ࣮ફ͢ΔͨΊͷΈΛ͍͑ͯ͘ • ίετͷઈର͕େ͖͘ͳ͍Ϧιʔεʹ͍ͭͯ࠷దԽ༨͕͋Δ͔ੳΛߦ͏ •
Savings Plans / Reserved InstanceͷߪೖઓུΛݟ͢ • etc. ࠓޙͷ՝ 05 ·ͱΊͱࠓޙͷ՝
• 20233݄29ൃച • ͲͷΑ͏ʹAWSͷίετ࠷దԽʹऔΓΜͰ͍ͬͨ ΒΑ͍͔ɺΦϯϓϨϛεͷ࣌ͱԿ͕ҧ͏ͷ͔ମ ܥతʹ·ͱ·ΊΒΕ͍ͯΔ • ॳֶऀͷํʹΘ͔Γ͘͢ஸೡʹॻ͔Ε͍ͯΔ ͓͢͢Ίͷॻ੶ 05
·ͱΊͱࠓޙͷ՝ https://www.kadokawa.co.jp/product/322104000266/