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
SmartNewsにおける 1000+ノード規模 K8s基盤 でのコスト最適化 – Spot・...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ishikawa ryu
July 02, 2025
Technology
340
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SmartNewsにおける 1000+ノード規模 K8s基盤 でのコスト最適化 – Spot・Gravitonの大規模導入への挑戦
ishikawa ryu
July 02, 2025
More Decks by ishikawa ryu
See All by ishikawa ryu
2021_11_internal_tech_session__lxd
vsanna2
0
160
AnyPay 社内エンジニアLT オフレコmeetup vol1
vsanna2
0
380
Rails5.1.4 overview
vsanna2
0
110
Ruby2.5.0 overview
vsanna2
0
58
React Native Router Flux v4 introduction
vsanna2
1
140
Other Decks in Technology
See All in Technology
EventBridge Connection
_kensh
5
710
LLMにもCAP定理があるという話
harukasakihara
0
330
AIの性能が向上しても未解決な組織の重大問題は何か?/An Unsolved Organizational Problem in the Age of AI
moriyuya
4
660
「エンジニア進化論」2028年の開発完全自動化、エンジニアはどう進化するか
cyberagentdevelopers
PRO
6
5.1k
なぜ Platform Engineering の土台に Kubernetes を選ぶのか
r4ynode
2
640
AI駆動開発を通して感じた、 AI時代のデザイナーの役割変化
whisaiyo
3
2.1k
FinOps × AIエージェントで実現する コストインシデントの自動調査
oasis1994liveforever
0
130
How Timee Delivers Day 1 Production Ready LLM Features
tomoyks
0
220
非定型業務をAI slackbotで自動化する ~ 社内要望を自動壁打ちするbotを作った ~/automating-ad-hoc-work-with-ai-slackbot
shibayu36
0
650
"何を作るか"を任される エンジニアは、どう育つのか
yutaokafuji
1
680
現地で盛り上がった WWDC26 Keynote
zozotech
PRO
1
240
手塩にかけりゃいいってもんじゃない
ming_ayami
0
570
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
280
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Between Models and Reality
mayunak
4
330
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
The Pragmatic Product Professional
lauravandoore
37
7.3k
The browser strikes back
jonoalderson
0
1.2k
Building Applications with DynamoDB
mza
96
7.1k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Accessibility Awareness
sabderemane
1
140
Transcript
SmartNewsにおける 1000+ノード規模 K8s基盤 でのコスト最適化 – Spot・Gravitonの大規模導入への挑戦 2025/06 Yu Hu, Ryu
Ishikawa CUS-33
Copyright © SmartNews, Inc. All rights reserved. Self Introduction Yu
Hu Senior Software Engineer Infrastructure Ryu Ishikawa Senior Software Engineer Product
Copyright © SmartNews, Inc. All rights reserved. Agenda • What
is SmartNews? • Background o Cost efficiency comes necessary and urgent o Savings Plans and Reserved Instance are not sufficient • Platform-Led Initiatives o Challenges o Solutions o Outcomes • Product Team's Success Story
MISSION 世界中の良質な情報を 必要な人に送り届ける Delivering the world’s quality information to the
people who need it.
MISSION 世界中の良質な情報を 必要な人に送り届ける Delivering the world’s quality information to the
people who need it. What is SmartNews ? : Product
MISSION 世界中の良質な情報を 必要な人に送り届ける What is SmartNews ? : Partnership with
AWS 1000+ノード規模のクラスタを複数運用 Amazon EKS を国内有数の規模で活用 その上に、AWSのマネージドサービスと社内でホストしたOSSを 組み合わせて多種多様な社内プラットフォームを構築 Ex: Flink/Spark/Trino/Hive/Kafka/ClickHouse/Milvus/TF Serving, etc マルチリージョン構成、Amazon EC2 Spot Instances や AWS Graviton の 活用、他発展的技術をAWSエキスパートと協働しながら最大限活用 🙌 AWS利用開始 Launch Spot・Graviton の活用 2025 EKSの導入 2020 マネージド サービス活用拡大 2015
Copyright © SmartNews, Inc. All rights reserved Copyright © SmartNews,
Inc. All rights reserved Background 7
Copyright © SmartNews, Inc. All rights reserved. Background: Cost Increasing
2024年1月、ある部門で予算の156%のシステムコストが発生 2024/01/01の予算 2024/01/01の実際のコスト 56% over 💸 Total Group A Group B
Copyright © SmartNews, Inc. All rights reserved. • 不定期かつ大規模なAuto-Scaling •
多くの並列新機能開発 • 多くの並列A/Bテスト • etc… Savings Plans と Reserved Instance では我々のワークロードには不十分 Background: Cost Increasing スタートアップとして柔軟性を維持しつつ、 より動的なコスト最適を実現するには? How we are • 柔軟なキャパシティの調整 • 安定したキャパシティの確保 So…
Copyright © SmartNews, Inc. All rights reserved Copyright © SmartNews,
Inc. All rights reserved Platform-Led Initiatives 10
11 Ideas
Copyright © SmartNews, Inc. All rights reserved. 要件やサービス特性 Ideas 大きなトラフィックの波
❏ 異なるサービスは異なるInstance Type/Familyを必要とする ❏ 高いパフォーマンスと低いレイテンシーのためには最新世代のインスタンスを使いたい ❏ 様々な時間間隔で、巨大なトラフィックの波が生じる 104 のインスタンスタイプ
Copyright © SmartNews, Inc. All rights reserved. Ideas Savings Plans
Amazon Relational Database Service (Amazon RDS) Amazon ElastiCache Surge Spot Instance K8s workload nodes Base Managed Service K8s computing resources Graviton Instance Reserved Instance On-Demand Instance Intel/AMD/ Graviton Instance Platformとしての方針
Copyright © SmartNews, Inc. All rights reserved. Ideas 1000+ ノード規模のEKSクラスタ上に
20+ チームの管理する 100+ サービスがある中で、 Spot Instance や Graviton の活用促進は簡単ではない。 しかし...
15 Challenges
Copyright © SmartNews, Inc. All rights reserved. Challenges ❏ ユーザー(≒社内エンジニア)教育
❏ Spot Instanceにまつわる不安を払拭 ❏ Spot Instanceを使う動機づけ
Copyright © SmartNews, Inc. All rights reserved. ❏ Spot Instanceの中断や、
キャパシティ不足エラーによる影響の 緩和策を実装 Challenges
Copyright © SmartNews, Inc. All rights reserved. ❏ シームレスで、安全なサービス移行 Challenges
19 Solutions
Copyright © SmartNews, Inc. All rights reserved. ユーザー(≒社内エンジニア)教育 Solutions AWSエキスパートと協働で社内セッションを開催
Spot Instance と Graviton の活用を促すダッシュボード
Copyright © SmartNews, Inc. All rights reserved. ❏ “The Engineering
Triangle” の理解を醸成 ❏ Spotの中断に際して2分間の猶予があることを周知 ❏ サービスに影響があったかどうかがわかるように SLOを定義 ❏ Spot Capacity Poolのサイズを大きくすることで(>20)、 キャパシティは安定することを周知 ❏ AWSにおいてGravitonが幅広く使われており、 その性能とコスト面での利点を解説 Solutions: Knowledge Awareness AWSエキスパートと協働で社内セッションを開催 Fast Cheap Reliable Low Reliability More $$ Slow
Copyright © SmartNews, Inc. All rights reserved. ❏ サービスごとのSpot vs.
On-Demand 利用比率 ❏ サービスごとの時間単位コスト ❏ Spotの割引率 ❏ Spotの時間別/日別 中断回数 ❏ Spotのキャパシティ不足イベント回数 ❏ K8s/PodsのPending 時間 Solutions: Visibility Spot Instance と Graviton の活用を促すダッシュボードの構築
Copyright © SmartNews, Inc. All rights reserved. Solutions: Visibility システムごとのSpot
vs. On-Demand 利用比率を可視化 いくつのCPUコアがSpotまたはOn-Demandのインスタンスから 供給されているかをリアルタイム把握
Copyright © SmartNews, Inc. All rights reserved. どのサービスがどのNodeGroups/NodePoolsで実行されているか、 そのNodegroupがサービスの特性にあっているものかを助言可能に Solutions:
Visibility NodeGroups/NodePools ごとの cpu/mem バランスを可視化
Copyright © SmartNews, Inc. All rights reserved. Solutions: Visibility 社内にモニタリングシステムを構築し、可視化を実現
業界標準の構成
Copyright © SmartNews, Inc. All rights reserved. Solutions: Visibility aws-price-exporter
Prometheus Recording rules Generate Prometheus AWS price Metrics Calculate the Accounted Cpu an Cost with Pod Level cpu/memory: 4 cores / 16G Pod1: 3 cores / 4G Pod2: 1 cores / 12G Pod-i Accounted Cost = max(cpuᵢ, memᵢ / r) / Σᵢ max(cpuᵢ, memᵢ / r) * Node Cost Pod1 50% Pod2 50% コストの分配
Copyright © SmartNews, Inc. All rights reserved. Karpenterを使いスケーリング性能を向上 Spot Instanceの中断やキャパシティ不足の緩和
Solutions Instance Typeを適切に選ぶポリシーの実装 高度なSpot枯渇時のFallbackの実装
Copyright © SmartNews, Inc. All rights reserved. ❏ AWSの Spot
Instance Advisorから利用可能なInstance Typeを確認 ❏ 中断の頻度とコストを見ながら適切なタイプを選択 ◦ 中断の頻度 < 15% ◦ オンデマンドと比較した費用削減 > 50% Solutions: Use selected instance types その結果Capacity insufficient イベントは大きく減少 Spotの入手可能性とコストのバランス
Copyright © SmartNews, Inc. All rights reserved. Solutions: Use selected
instance types Run as Job weekly 自動的にコスト・入手可能性の最適なバランスを取れるよう仕組み化 ❏ この仕組みは主にCluster Autoscalerを対象 ❏ Karpenterではprice-capacity-optimizedを 利用可能 ◦ 中断率とキャパシティの問題は 大幅に改善されている ❏ しかし、多少価格が高くなっても、より 安定性を求める特別なケースに対応する ために、この仕組みを活用
Copyright © SmartNews, Inc. All rights reserved. Cluster Autoscaler: CAはAWS
Auto Scaling Group(ASG)に依存して新しいインスタンスをプ ロビジョニングするため、スケールアップに数分かかる。 この遅延の主な原因は、AWSが新しいインスタンスをプロビジョニングし 、それらのインスタンスがクラスタ内で準備完了になるまでに時間がかか るため。 Karpenter: Karpenterは多くの場合、1分以内にインスタンスをプロビジョニングでき るほど、はるかに迅速にスケールアップするように設計されている。 これは、KarpenterがEC2 APIと直接やり取りし、より遅いASGメカニズ ムをバイパスするため。 Solutions: Use Karpenter to improve scaling performance https://www.nops.io/blog/karpenter-vs-cluster-autoscaler-vs-nks/ EC2 APIと直接やりとり インスタンス立ち上げのために Auto Scaling Group (ASG)に依存 スポットインスタンスを採用する上で、スケールアップのパフォーマン スは非常に重要. なぜなら、中断の通知は2分前にしか来ず、Fallbackの 時間を考慮する必要があるため。 Cluster AutoscalerからKarpenterへの移行
Copyright © SmartNews, Inc. All rights reserved. スケーリングにかかる時間の短縮に成功 サービス全体の 安定性を向上
Solutions: Use Karpenter to improve scaling performance Spot中断に備え 時間短縮 6 Minutes 3 Minutes OSSであるKarpenterを独自でカスタマイズし、効率と安定性を更に向上 ❏ スケールダウンのトリガーとして “利用率” を指定 ❏ 直近3分以内に配置されたPending状態のPodsはスケーリング計画の計算から除外 ❏ Spot Instance中断が発生した際には、即座にNodeClaimsを作成 NodeClaimsの 繰り返し作成を回避
Copyright © SmartNews, Inc. All rights reserved. ❏ 明示的にSpot Instanceを指定できない
❏ どのNodeGroups/NodePoolsを使うかをPriorityでコントロール ❏ その結果、徐々にOn-Demand上でより多くのPodが実行される ❏ Node affinity Preferも使えるが、それは新規のnode作成を引き起こさない Karpenter/CA Solutions: Spot Fallback architecture: arm Generation: 8 Node Selector pricing: spot architecture: arm Generation: 8 Priority: 90 Node Group/Pool pricing: ondmd architecture: arm Generation: 8 Priority: 80 Launch Node Node Group/Pool Karpenter / CA Matching Node Success Failed Success 一般的なSpot InstanceのFallback
Copyright © SmartNews, Inc. All rights reserved. Karpenter/CA pricing: spot
architecture: arm Generation: 8 Weight: 80 expireAfter: 1h capacityType=ON_DE MAND Success ❏ 明示的にSpot Instanceを指定できる ❏ Fallback先のOn-Demandインスタンスは一定間隔で停止 Solutions: Spot Fallback pricing: spot architecture: arm Generation: 8 Node Selector pricing: spot architecture: arm Generation: 8 Weight: 90 Node Pool Launch Node Karpenter Matching Node Success Capacity Failed Check capacity again with a fixed interval Ensure Capacity Keep Cost Efficiency Karpenterの機能を利用: spec.expireAfter: 1h; spec.terminationGracePeriod: 5m 最大限Spotを活用するよう適切にコントロールされたFallback Node Pool
Copyright © SmartNews, Inc. All rights reserved. マルチプラットフォームイメージに対応しGravitonも活用 シームレスで、安全なサービス移行 Solutions
移行するサービスの選定基準 Spot/On-Demandを組み合わせたK8s/Deployment定義
Copyright © SmartNews, Inc. All rights reserved. Solutions: Seamless migration
システム重要度 選択基準 Spot Instanceへの適性 Critical System トランザクション実行時間 < 30秒 (e.g., オンラインサービスの応答時間 < 1秒) ✅ 適合 – 実行時間が2分より短ければ、Spot中断による 処理の強制停止を回避できる トランザクション実行時間 > 2分 (e.g. 時間のかかるオフラインジョブ) ❌ 不適合 – 処理中に強制停止されうる Pod起動時間 < 1分 ✅ 適合 – 再起動しても即座にリカバリできる Pod起動時間 > 1分 & 10+レプリカ ✅ 許容 – 起動に時間がかかるとしても、 レプリカが相当数あれば強制停止の影響を緩和可能 Non-Critical System (特に基なし) ✅ 適合 – 早速Spot Instanceを導入 移行するサービスの選定基準
Copyright © SmartNews, Inc. All rights reserved. ❏ 優れたパフォーマンス ❏
低いコスト ❏ Intel, AMD, Gravitonのより潤沢なキャパシティを実現 Gravitonもサポートするためにマルチプラットフォームイメージを活用 Solutions: Seamless migration m6g.8xlarge: $0.3955 hourly m6i.8xlarge: $0.5882 hourly m6a.8xlarge: $0.6439 hourly.
Copyright © SmartNews, Inc. All rights reserved. Solutions: Seamless migration
Application Load Balancer (ALB) Spot On-Demand 30% 70% Scale in/out for Surge Base Usage Spot/On-Demandを組み合わせたK8s/Deployment定義
Copyright © SmartNews, Inc. All rights reserved. Spot InstanceのNodeGroups/NodePoolsがデフォルトに Outcome
>50% spot usage for monitoring system >80% spot usage for ranking system 100% spot usage for tensorflow serving 高いSpot Instanceの利用率を達成
Copyright © SmartNews, Inc. All rights reserved. 100% Gravitonで実行 Outcome
Gravitonの利用率も大きく向上させることに成功 ワークロードの40%強がGravitonを使用
Copyright © SmartNews, Inc. All rights reserved. Takeaways ❏ 正しい認識を醸成し、簡単にコストを把握できるようにする
❏ Spot中断頻度とコスト削減の幅の適切なバランスをとる ❏ Karpenterを活用してスケーリングパフォーマンスを追求する ❏ Spotのキャパシティ不足に備えてフォールバックの仕組みを作り込む ❏ Gravitonを活用して、Spot活用によるコスト削減に加え 更に10%のコスト削減とより安定したキャパシティの実現を狙う
Copyright © SmartNews, Inc. All rights reserved Copyright © SmartNews,
Inc. All rights reserved 41 Success Stories
Copyright © SmartNews, Inc. All rights reserved. Three Key actions
コスト削減に集中するタスクフォースを組成 1 計測よりはじめよ 2 基本的な施策を愚直に進める 3
Copyright © SmartNews, Inc. All rights reserved. Action1: Made a
task-force team dedicated to cost reduction コスト削減に特化したチームとPICを明確に決めることは改めて重要
Copyright © SmartNews, Inc. All rights reserved. Action2: Measurement comes
first ダッシュボードは灯台。打ち手と推進力の源泉
Copyright © SmartNews, Inc. All rights reserved. Action2: Measurement comes
first コスト構造把握のための十分な投資は不可欠 https://docs.aws.amazon.com/cur/latest/userguide/what-is-cur.html 例: Amazon S3の共有バケットのprefixごとのコスト、社内プラットフォームの コンピュテーションコストなどをチームレベルで分解可能
Copyright © SmartNews, Inc. All rights reserved. Action2: Measurement comes
first 正しいコスト構造の理解は正しい打ち手を導く Div X Group A Group B offline srv
Copyright © SmartNews, Inc. All rights reserved. Action3: Follow the
very basic strategies “Quick Win Optimization” EC2 : PurchasePlanの見直し S3 : LifeCycleRuleの見直し 不要なコンポーネントの削除 https://aws.amazon.com/jp/blogs/news/aws-cost-optimization-guidebook/ AWSコスト最適化ガイドブック offline srv
Copyright © SmartNews, Inc. All rights reserved. Spot Instanceを安全に、そして積極的に活用したい Success
Story: Moving to Spot Instances 安全に … かつ最大限積極的に
Copyright © SmartNews, Inc. All rights reserved. Success Story: Outcome
結果として、適正なコストレベルにまで戻し、そこで安定させることに成功 45% down 🎉 Total Group A Group B 2024/03/31の実際のコスト 2024/03/31の予算 2024/01/01の実際のコスト
Copyright © SmartNews, Inc. All rights reserved. Next Actions コスト改善をワンショットで終わらせてはいけない
コスト説明 なぜ・何にコストがかかっているかを細かい粒度で把握 頑健性 Surge vs. Baseに合わせたPurchasePlanの組み合わせ最適化 更に高速なboot timeの追求 リトライ時のコスト跳ねを避ける小さなジョブを志向 文化 変更前後のコスト確認を習慣化 システム設計・A/Bテストの設計でコストを変数に 自動化 コスト異常の検知とリカバリの自動化
Copyright © SmartNews, Inc. All rights reserved Copyright © SmartNews,
Inc. All rights reserved Wrap up 51
Copyright © SmartNews, Inc. All rights reserved. • ダッシュボードは灯台。打ち手と推進力の源泉 •
コスト構造把握のための十分な投資は不可欠 • 正しいコスト構造の理解は正しい打ち手を導く • Instance Typeを適切に選ぶポリシーの実装 • Karpenterを使いスケーリング性能を向上 • On-DemandへのFailoverの実装 Summary 課題 エンジニア教育 • AWSエキスパートと協働で社内セッションを開催 • Spot Instance と Graviton の導入進捗をみるダッシュボードの構築 安定したSpot活用 シームレスな移行 • 移行するサービスの選定基準 • Gravitonのサポート • Spot/On-Demandを組み合わせたK8s/Deployment定義 取り組み タスクフォース • コスト削減に特化したチームとPICを明確に決めることは重要 計測より始めよ 基本に忠実 • Quick Win Optimization/FinOpsを基本的な施策を愚直に進める