Skip to main content
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SaaS テナント毎コストの把握に便利な
AWS Application Cost Profilerの紹介
鄭宇鎭
第⼗五 回 「 アッ プ デー ト紹介 とちょっぴり DIV E DE E P する AWS の 時間」
ISV/SaaS ソリューションアーキテクト
アマゾンウェブサービスジャパン
2022/02/25
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
1. SaaSテナント毎利⽤コストの把握
2. SaaSコストプロファイリング
3. AWS Application Cost Profilerの紹介
4. まとめ
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SaaSテナント毎利⽤コストの把握
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⼀般的なSaaSのアーキテクチャー
• 開発効率化のため、マイクロサービスアー
キテクチャが多い
• 費⽤効率化のため、マルチテナントアーキ
テクチャが多い
Web application
Amazon API Gateway
Microservice Microservice Microservice
Application services
Tenant 1 Tenant 2 Tenant 3
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
テナント毎利⽤コストの把握が難しい理由
• 複数テナントがリソースを共有している
• テナント毎の利⽤パターンが様々である
• 利⽤量の標準モデリングが難しい
• リソース毎にコストの⾒⽅が違う
Web application
Amazon API Gateway
Microservice Microservice Microservice
Application services
Tenant 1 Tenant 2 Tenant 3
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon RDS
コストユニット ≠ 利⽤料ユニット
Amazon ECS
container
T1 T2 T3
T1 Golf club
T2 Golf bag
T1 Golf cart
T3 Golf bag
コンピュート
ストレージ (compute)
ストレージ (disk)
Instance
コストユニット
Tenant 1 = 10%
Tenant 2 = 72%
Tenant 3 = 18%
Tenant 1 = 38%
Tenant 2 = 35%
Tenant 3 = 27%
Tenant 1 = 58%
Tenant 2 = 17%
Tenant 3 = 25%
利⽤料ユニット
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
各リソースにテナント毎利⽤量を関連付け
収集されたテナント毎の利⽤量を集計
• Amazon EC2
• Tenant 1 = 80%
• Tenant 2 = 20%
• Amazon DynamoDB
• Tenant 1 = 54%
• Tenant 2 = 46%
• Amazon SQS
• Tenant 1 = 73%
• Tenant 2 = 27%
• Amazon RDS
• Tenant 1 = 61%
• Tenant 2 = 39%
全体インフラコスト
テナント毎利⽤コスト
1
2
Tenant 1 cost = $156.12
Tenant 2 cost = $133.22
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
なぜテナント毎の利⽤コストを把握することは重要か︖
ベーシックプラン スタンダードプラン アドバンストプラン
インフラコスト
テナント売上
カタログデータサイズ
• 提供プラン・テナント・インフラコストの関連性が把握でき、
販売戦略や開発戦略でそのインサイトを利⽤可能
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
テナント毎利⽤コスト分析は業務と開発チームの両⽅に影響を与える
プロダクトオーナーは商品詳細情報に動画機能を追加しようとしている。
• 動画機能は追加料⾦を設定すべきか︖
• その機能がテナント毎インフラコストにどう影響するか︖
• 提供プランのストラテジーにはどう影響するか︖
開発チームは在庫データのため新しいストレージを導⼊しようとしている。
• すべてのテナントでこの機能を提供するのか︖
• その機能がテナント毎のマージンにどう影響するか︖
• 提供プラン毎に異なるリテンションポリシーを提供すべきか︖
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SaaSコストプロファイリング
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⼀般的なコストプロファイリング戦略
グローバル
エントリポイント
プロファイリング
マイクロサービス
エントリポイント
プロファイリング
リソース毎
利⽤料ベースの
プロファイリング
Microservice
% %
Microservice % %
% %
Common dimensions: リクエスト頻度/レイテンシー
• 労⼒︓低
• 精度︓低
• 労⼒︓中
• 精度︓中
• 労⼒︓⾼
• 精度︓⾼
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
テナントのアクティビティから利⽤コストを算出
Application API
Microservice
Resource
Source
{
TenantId: 93902,
ExecutionTime: 4ms
Dimension: Frequency
ResourceId: <id>
}
Consumption
event
Event ingestion
and aggregation
Tenant ResourceId Allocation
19393 arn:aws:s3:::my_bucket/tenant19393 11%
19393 arn:aws:rds:us-west-1:111:db:mydb 4%
84719 arn:aws:s3:::my_bucket/tenant84719 8%
84719 arn:aws:rds:us-west-1:111:db:mydb 12%
Tenant Allocation
19393 15%
84179 14%
Normalized cost-per-tenant aggregate
1
2
3
Consumption by resource
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
テナント毎の利⽤コストを把握するアーキテクチャー
Microservice
Cost metrics
instrumentation
Amazon
CloudWatch
Logs
AWS
Lambda
Amazon
Kinesis Data
Firehose
Amazon S3
Consumption and
aggregation
service
Tenant Allocation
19393 15%
93993 14%
41949 47%
82109 24%
{
TenantId: 93902,
ExecutionTime: 4ms
Dimension: Frequency
ResourceId: <id>
}
Consumption event
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Application Cost Profilerの紹介
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(再掲)テナント毎の利⽤コストを把握するアーキテクチャー
Microservice
Cost metrics
instrumentation
Amazon
CloudWatch
Logs
AWS
Lambda
Amazon
Kinesis Data
Firehose
Amazon S3
Consumption and
aggregation
service
Tenant Allocation
19393 15%
93993 14%
41949 47%
82109 24%
{
TenantId: 93902,
ExecutionTime: 4ms
Dimension: Frequency
ResourceId: <id>
}
Consumption event
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Application Cost Profilerを利⽤する場合
Application
Cost Profiler
SaaS アプリケーション
リソース利⽤量
ログ
2
レポート作成
3
4
ログアップロード
6
レポート作成 API呼び出し or
⽇次・⽉次定期作成
Application
Cost Profiler用
S3 bucket
SaaS provider
1 レポート定義を作成
リソース利⽤量
キャプチャー
読み込み
5
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Application Cost Profiler (ACP)
リモート測定、ビッグデータの
計算のインフラストラクチャ投資
と運⽤オーバーヘッドの削減
柔軟なテナント
メタデータ収集:
独⾃またはサポートされ
ているログメカニズム
テナント毎の利⽤データと
AWS課⾦情報を関連付け
価格設定と販売活動を
最適化するためのインサ
イト
• 共有リソースの消費に関するテナント毎の利⽤コストが把握できるレポートを提供する。
• テナント毎の利⽤量データとAWS課⾦に基づいてテナント毎の利⽤コストを把握することが可能。
ベネフィット
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
主な機能と特徴
リソース利⽤データと課
⾦の関連付けしテナント
毎利⽤コストを算出
簡単にテナント毎
の利⽤コストをト
ラッキング
レポート機能を管理
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Application Cost Profiler レポート定義を設定
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Metrics file
コストメトリクス処理の⼀元化
Application
Cost Profiler
Application services
Order Lambda
layer
Product
Shared services
SaaS environment
Metrics
Upload
メトリクス収集のための仕組みは共有サービス(Shared Services)として運⽤
Ingest
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
必要に応じてサービス利⽤メトリクスを収集
Web application
API Gateway
Microservice
Application services
Tenant 1 Tenant 2
Lambda
authorizer
Microservice
REST entry point
Service
consumption
Microservice
Metrics and
analytics
service
Shared services
Upload
Application
Cost Profiler用
S3 bucket
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Application Cost Profilerのためのログ出⼒
Metrics and
analytics
service
{
TenantId: Tenant1,
UsageAccountId: 123456789012,
ResourceId: arn:aws:s3::bucket_name/key_name,
StartTime: 1613681437032.9001,
EndTime: 1613681437041.5312
}
Lambda
layer
Microservice
ResourceId: arn:aws:s3::bucket_name/key_name,
StartTime: 1613681437032.9001,
EndTime: 1613681437041.5312
Resolve and inject tenant
and account context
Metrics
file
1
2
3
4
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
リソース利⽤を集計し、テナント毎利⽤コストに集計
Tenant Resource Duration
Tenant1 S3-arn 100
Tenant2 S3-arn 25
Tenant3 RDS-arn 401
Tenant2 RDS-arn 105
Tenant3 RDS-arn 220
Tenant1 RDS-arn 350
Tenant1 S3-arn 240
Tenant3 S3-arn 831
Tenant2 S3-arn 120
テナント毎利⽤量データ
Tenant Resource Percentage
Tenant1 S3-arn 26%
Tenant1 RDS-arn 32%
Tenant2 S3-arn 11%
Tenant2 RDS-arn 10%
Tenant3 S3-arn 63%
Tenant3 RDS-arn 58%
リソース利⽤アクティビティ
アクティビティを
テナント毎の利⽤
コストに集計
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Application Cost Profilerでコスト関連付け
AWS bill
テナント毎利⽤量データ
Tenant Resource Percentage
Tenant1 S3-arn 26%
Tenant1 RDS-arn 32%
Tenant2 S3-arn 11%
Tenant2 RDS-arn 10%
Tenant3 S3-arn 63%
Tenant3 RDS-arn 58%
S3-arn = $535
RDS-arn = $743
Tenant Resource Cost
Tenant1 S3 $139.10
Tenant1 RDS $237.76
Tenant2 S3 $58.85
Tenant2 RDS $74.30
Tenant3 S3-arn $337.05
Tenant3 RDS-arn $430.94
これでSaaSプロバイダーの典型的な課題であるテナント毎コストの把握が容易になる
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
様々な分析データとの関連付けで更なるインサイトを
• コストの傾向を⼀般的な指標と関連付け
• コストとユーザーアクティビティの関連付け
• 提供プランとコストの関連付け
• コストを機能またはアプリケーションサービス
に関連付け
機能の利⽤
トレンド
エンドユーザ
利⽤トレンド
オンボーディング
メトリクス
テナント毎
コスト
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Application Cost Profiler利⽤において
• コスト分析のためのメトリクスと
実際の課⾦は分けて考えましょう
• テナント毎コストの合理的な概算を
⽬指してください
• 複雑すぎないようバランスを
取りましょう
Account Debit Credit Balance
9892941 $12.00 $130.00 $118.00
1848193 $41.00 $0.00 $77.00
3999314 $0.00 $100.00 $177.00
6892992 $20.00 $5.00 $192.00
4108482 $40.00 $60.00 $212.00
2949230 $69.00 $0.00 $123.00
General ledger
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
まとめ
• Application Cost Profilerを利⽤すればお客様の環境に最適な
コスト分析戦略を⾒つけることが可能になります
• Application Cost Profilerは会計のためのツールではなく、
コスト分析のためのサービスです
• 優先度の⾼いリソースから始めてください
• SaaSプロバイダーにおいてテナント毎の利⽤コストの把握はビジネ
ス戦略、技術戦略に必須です
• 簡単にコストを把握するために是⾮
Application Cost Profilerをお試しください
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
付録︓DEMO
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(再掲)AWS Application Cost Profilerを利⽤する場合
Application
Cost Profiler
SaaS アプリケーション
リソース利⽤量
ログ
2
レポート作成
3
4
ログアップロード
6
レポート作成 API呼び出し or
⽇次・⽉次定期作成
Application
Cost Profiler用
S3 bucket
SaaS provider
1 レポート定義を作成
リソース利⽤量
キャプチャー
読み込み
5
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ACP⽤S3バケット
• 「import/ 」はアプリケーションからのログがアップロードされる
• 「reports/」はACPの集計・分析結果ファイルが保存される
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ACPの分析対象ファイルをアップロード︓import/
• 「import/ 」に様々なアプリケーションからリソース利⽤時間が分かるようなログをアップロード
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ACPの分析対象ファイルの例
• Lambdaが出したリソース利⽤ログの例
※ファイルフォーマットは、https://docs.aws.amazon.com/ja_jp/application-cost-profiler/latest/userguide/creating-
report.html#resource-usage-table
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ACPの分析結果ファイル出⼒ ︓report/
• ACPは⽇次・⽉次の設定により、⾃動的にログを集計し、結果ファイルを出⼒
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ACP分析結果ファイルの例
• ACPが出⼒したレポートファイル(テナント毎利⽤コストログ)の例
※レポートファイルの項⽬詳細は、https://docs.aws.amazon.com/ja_jp/application-cost-profiler/latest/userguide/getting-
reports.html
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ACPのレポートファイルの可視化
• ACPが出⼒したレポートファイルをQuickSightを使い可視化した例
Thank you!
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.