SlideShare a Scribd company logo
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
8th July 2020
Kensuke Shimokawa
サーバーレスでのAPI管理の考え方
@_kensh
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Who am I?
Name
Kensuke Shimokawa
Company
Amazon Web Services Japan K.K.
Role
Serverless Specialist Solutions Architect
@_kensh
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本セッションは
想定される聴講者
• オンプレでWEBアプリやAPIを構築したことがある
• クラウド上でVMベースでAPI構築、管理、運用している
• 開発者、運用者、またはそれらの人員を管理している人
• サーバーレス での API管理の考え方を知りたい
ゴール
• サーバーレス でのAPI構築、運用の考え方を理解する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Table of contents
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
今日お話しするテーマ の “API”
Web API言語処理系API
[SDK/ライブラリ等]
ネットワーク
呼び出しAPI
“Application Programming Interface”:
プログラムやソフトウェア同士がやり取りするための取り決め・仕様
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• モノリスで運用しているアプリでは、画面項目追加といった比較的小規模な
機能変更でも、多くのコンポーネントが密接に関係している
• 影響範囲の特定が難しい
• ビルド、テストに時間がかかる
• 特性の異なる要件の機能が一体になっていることで、スケールしない
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
変更の影響が小さくなると、
リリースの速度が向上可能に
Monolith
すべてを実行
Microservices
ひとつのことを実行
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
「API」と「疎結合なコミュニケーション」が自動化を
可能にして信頼性を向上
FUNCTION
API
API
MICROSERVICE
FUNCTION
EVENT
API
MICROSERVICE
EVENT
API
MICROSERVICE
APPLICATION
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
モノリスクライアント DB
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
分散
モノリス
分散
モノリス
分散
モノリス DB
モノリスを機能ごとに分割してみる
ただしDBは共有のまま
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感(継続)
• モノリスで運用しているアプリでは、画面項目追加といった比較的小規模な
機能変更でも、多くのコンポーネントが密接に関係している
• 影響範囲の特定が難しい
• → データベースを共通に持つため、項目追加削除など破壊的変更をする際
には他のサービスの影響範囲を見極める必要がある
• ビルド、テストに時間がかかる
• → 影響のある範囲をビルド・テストするため、やはり時間がかかる
• 特性の異なる要件の機能が一体になっていることで、スケールしない
• → 単一サービスを独立にアプリケーション層でスケールさせることはでき
るが、結局は共通のデータベースにアクセスするため、他のサービスの影
響は避けられない
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
目的に応じたデータベース
膨大なデータ量?
単一DBタイプ
では全てに
応じるのは困難
それぞれのモジュール化サービスのデータニーズはどのようなものか?
データウェアハウス?
高速レンダリング?
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWSのデータベースサービス =“Purpose Built DB”
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.https://d1.awsstatic.com/webinars/jp/pdf/services/expertonlinekameda-200209234556.pdf
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
モノリスを機能ごとに分割し、データベースもサービスごとに用意する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ビジネス戦略におけるテクノロジーの選択
モジュール型
サービス
できる限り
マネージドで
自動化
& 標準化
みんなで
責任を分担
目的に応じた
選択
アーキテクチャ
パターン
1
運用
モデル
2
ソフトウェア
配信
3
管理 &
ガバナンス
4
データ
管理
5
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
• マイクロサービス の選択肢
• VMベースで構築
• コンテナで構築
• サーバーレス で構築
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
• マイクロサービス の選択肢
• VMベースで構築
• コンテナで構築
• サーバーレス で構築
• 関数レベルの抽象化
• サーバーのリソース確保不要
• メンテナンス不要
• セキュリティパッチなど不要
• 使った分だけの支払い
• 柔軟、自動化、スケール
• 自動の高可用性
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
モノリスのスケール
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス のスケール
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
モノリスのデリバリーパイプライン
開発者 サービス
デリバリーパイプライン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービスのデリバリーパイプライン
開発者 サービス デリバリーパイプライン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• モノリスで運用しているアプリでは、画面項目追加といった比較的小規模な
機能変更でも、多くのコンポーネントが密接に関係している
• 影響範囲の特定が難しい
• → サービスごとに責任分界が明確
• → API (例えばRESTで公開)の契約に変更がない場合、内部の変更は容易
• ビルド、テストに時間がかかる
• → 単一コンポーネントのビルド、テスト時間に収まる
• 特性の異なる要件の機能が一体になっていることで、スケールしない
• → それぞれのサービスに必要なだけのリソースを割り当てて、コスト効率
よくスケールできる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• マイクロサービス に分割するのは成功したが、サービス が増えて行くにつれ
て、クライアントがサービス エンドポイントに直接アクセスするのがつらい
• アクセスプロトコルが千差万別
• クライアント側がバックエンドの能力を個々に把握する必要がある
• 可用性、回復性、スループットなど
• サービス 側のREST契約が破棄されると直接クライアント影響が出る
• 既存資産(モノリス)があり、全てをマイクロサービス に置き換えることは
できない
• モノリスとマイクロサービス を共存させたい
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
REST
REST
REST
REST
クライアントは、RESTでマイクロサービス
と直接会話すると
クライアントが知るべきマイクロサービス が
どんどん増えて行く
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
API ゲートウェイパターンを導入する
クライアント
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
REST
REST
REST
REST
</>
APIゲートウェイ
API ゲートウェイによって、さまざまなバックエンドサービスの呼び出しを
統一された APIで統合
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
</>
APIゲートウェイ
API ゲートウェイのダウンストリームプロトコルが多種に渡っても、
クライアントからはRESTでアクセス可能とする
REST
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント マイクロサービス
DB
DB
DB
REST
REST
サーバーレス で実装する場合、APIゲートウェイはAmazon API Gateway、Queueの
実現にAmazon SQS、ロジックの実行にAWS Lambdaが利用できる
REST
Amazon SQS AWS Lambda
AWS Lambda
Amazon
API Gateway
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クライアント
DB
DB
既存のモノリスの前段にAPI Gatewayを配置して、クライアントとモノリスやマイ
クロサービス との繋がりを疎結合にすることができる
REST
AWS Lambda
Amazon
API Gateway
モノリス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• マイクロサービス に分割するのは成功したが、サービス が増えて行くにつれ
て、クライアントがサービス エンドポイントに直接アクセスするのがつらい
• アクセスプロトコルが千差万別
• → Amazon API Gatewayは多種多様なサービスと統合
• クライアント側がバックエンドの能力を個々に把握する必要がある
• 可用性、回復性、スループットなど
• →ダウンストリームの能力に応じて、API Gatewayのスループットを調整できる
• サービス 側のREST契約が破棄されると直接クライアント影響が出る
• → API Gateway 層で(ある程度)影響を吸収できる(e.g. template利用)
• モノリスとマイクロサービス を共存させたい
• → API Gatewayでバックエンドを抽象化する
• クライアントからはモノリスを意識させない
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• システムが順調に軌道に乗り、当初はWebブラウザだけを想定していたクラ
イアントが、モバイル(iOS/Android)対応を迫られることになった。
• 返却するレスポンスデータの形式が異なる
• モバイルとブラウザアプリで、クライアント数が異なり適切にQuota
割当したい(または個別にスロットリング設定したい)
• APIの形式拡張や性能要件はクライアント開発者に決定、設定させたい
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ
APIゲートウェイ
クライアントが多様化してくると全てのクライアントの要求に応える
単一のAPIエンドポイントを維持するのが困難に
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
デバイスやクライアントタイプごとに、エンドポイントを分ける
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
• エンドポイントを分けることにより
• デバイスごとに異なる設定ができる
• Quota設定
• セキュリティ設定
• ログ設定
• スロットリング設定
• デバイスごとに提供コンテンツを変
えて配信できる
• エンドポイントの設定変更権限を、
フロント開発者に委譲できる
• BFFパターン
BFFパターンを導入する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• システムが順調に軌道に乗り、当初はWebブラウザだけを想定していたクラ
イアントが、モバイル(iOS/Android)対応を迫られることになった。
• 返却するレスポンスデータの形式が異なる
• → API Gateway層や、サービス 統合により異なる形式のデータを提供
• モバイルとブラウザアプリで、クライアント数が異なり適切にQuota
割当したい(または個別にスロットリング設定したい)
• APIの形式拡張や性能要件はクライアント開発者に決定、設定させたい
• → API Gatewayの設定変更権限のみを与えたRoleを作成し、フロントエンド開発
者に提供できる
• → API Gatewayのモック機能を使ってバックエンド実装を待たずに試験できる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• 静的コンテンツアクセスがAPI Gatewayエンドポイントに集中し、トラフィッ
クの大部分を閉めるようになった。
• API Gatewayエンドポイントの負荷を下げたい
• マイクロサービス はロジックに専念したい
• ラウンドトリップのレイテンシーも改善したい
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
css, js, html, image
静的コンテンツ
静的コンテンツは、APIエンドポイントを介して配信されている
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
オブジェクト
ストレージ
css, js, html, image
静的コンテンツ
静的コンテンツは、APIゲートウェイのエンドポイントではなく、
オブジェクトストレージに取得に行く
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
css, js, html, image
静的コンテンツ
Amazon Simple Storage
Service
オブジェクトストレージとしてAmazon S3の静的ウェブサイトのホスティング
機能が使える
https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/WebsiteHosting.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
CDN css, js, html, image
静的コンテンツ
エッジロケーションから配信したい
Amazon Simple Storage
Service
オブジェクトストレージとの間にCDNを配置することで、エッジロケーション
から配信でき、さらにエッジキャッシュも利用できる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
css, js, html, image
静的コンテンツ
エッジロケーションから配信したい
Amazon CloudFront
Amazon Simple Storage
Service
CDNとしてAmazon CloudFrontが利用できる。エッジロケーションと呼ばれる
世界規模のネットワークを通じてコンテンツが配信できる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• 静的コンテンツアクセスがAPI Gatewayエンドポイントに集中し、トラフィッ
クの大部分を閉めるようになった。
• API Gatewayエンドポイントの負荷を下げたい
• マイクロサービス はロジックに専念したい
• → 静的コンテンツGETのトラフィックをAmazon S3へオフロード
• ラウンドトリップのレイテンシーも改善したい
• → 静的コンテンツGETのトラフィックに対しAmazon CloudFrontキャッシュ利用
• → CloudFrontとAWSオリジンサービス 間の通信費は無料
• → S3へのアクセスをCloudFront経由のみに絞れる
• https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/DeveloperGuide/private-
content-restricting-access-to-s3.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• サービスの利用者が増えてきて、サービスの認知も高まってきた。しかし、
アクセスの中に、悪意のあるリクエストが増えてきている。
• バックエンドリソースが攻撃リクエストにより消費される
• バックエンドのアプリケーション層の脆弱性を攻撃される
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
css, js, html, image
静的コンテンツ
Amazon S3
Amazon
CloudFront
エンドポイントやエッジに対するLayer7の攻撃が発生している
🔥
🔥
🔥
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
WAF
WAF
WAF css, js, html, image
静的コンテンツ
Amazon S3
Amazon
CloudFront
Web Application Firewall (WAF)を導入し、Layer7の攻撃に備える
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
css, js, html, image
静的コンテンツ
Amazon S3
Amazon
CloudFront
AWS WAF では、SQL インジェクションやクロスサイトスクリプティングなどをブロック、
また、ユーザー定義したパターンを除外するルールを作成できる
AWS WAF
AWS WAF
AWS WAF
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• サービスの利用者が増えてきて、サービスの認知も高まってきた。しかし、
アクセスの中に、悪意のあるリクエストが増えてきている。
• バックエンドリソースが攻撃リクエストにより消費される
• → アクセスパターンのルールを定義して、不当なリクエストを除外
• バックエンドのアプリケーション層の脆弱性を攻撃される
• → SQLインジェクションやXSSなどの一般的な攻撃に対応
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• クライアントからのリクエストパターンは限られており、多くのクエリーパ
ラメータが共通であるにも関わらず、バックエンドの計算リソースを消費し
て、毎回計算し返却している。
• 計算リソースの消費を改善したい
• レイテンシーを改善したい
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
オブジェクト
ストレージ
WAF
WAF
WAF css, js, html, image
静的コンテンツ
Amazon
CloudFront
Amazon CloudFront がキャッシュしない設定になっていたり、API Gatewayに適切に
キャッシュ設定がされていない場合、オリジンやバックエンドのリソースが消費される
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
オブジェクト
ストレージ
WAF
WAF
WAF Cache css, js, html, image
静的コンテンツ
Amazon
CloudFront
Amazon CloudFront がキャッシュ保持する時間を制御できます。この期間を短くすると、
動的なコンテンツを供給できます。この期間を長くすると、クライアントパフォーマンス
は向上します。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache css, js, html, image
静的コンテンツ
Amazon
CloudFront
API Gatewayのキャッシュ機能を使うことで、キャッシュヒットすればダウンストリーム
に処理を連携することなくレスポンスをクライアントに返却できます
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
Backend For Frontend
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache css, js, html, image
静的コンテンツ
Amazon
CloudFront
AWS Lambda Amazon DynamoDB
Amazon DynamoDB
accelerator (DAX)
Amazon ElastiCache
Lambda関数からElastiCacheにアクセスしたり、DynamoDB
の前段にDAX(DynamoDB Accelerator)を配置することもで
きます。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• クライアントからのリクエストパターンは限られており、多くのクエリーパ
ラメータが共通であるにも関わらず、バックエンドの計算リソースを消費し
て、毎回計算し返却している。
• 計算リソースの消費を改善したい
• → キャッシュヒットするとキャッシュから返却値を取得できるため、バッ
クエンドリソース負荷の軽減が見込まれる
• レイテンシーを改善したい
• → キャッシュヒットするとバックエンド処理時間がラウンドトリップタイ
ムにのらない為、レイテンシーが改善する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• マイクロサービス やAPIのエンドポイントが増えるたびに、ログの独自管理が
困難になってきており、統一したログの管理手法が必要
• APIに問題が起きた場合のデバッグ方法を確立しておきたい
• APIのend to endのトレーサビリティも改善したい
• APIのエラーやレイテンシーのメトリックを把握しサービスの改善に役
立てたい
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache css, js, html, image
静的コンテンツ
Amazon
CloudFront
オブザーバビリティ(可観測性)
分散サービスに何らかの問題が発生した場合、個々のサービスごとにモニタリング手法が
異なっていては、 オブザーバビリティ(可観測性)が高くはならない
Log
Log
Log
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache
Log
css, js, html, image
静的コンテンツ
Amazon
CloudFront
全てのエンドポイントが統一的に
アクセスできるLog収集機能が必要
オブザーバビリティ(可観測性)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache css, js, html, image
静的コンテンツ
Amazon
CloudFront
Amazon CloudWatch Logsを利用
すると統一したログ収集が可能
Amazon CloudWatch Logs
オブザーバビリティ(可観測性)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache
Log
css, js, html, image
静的コンテンツ
Amazon
CloudFront
AWS Lambda
LambdaやAuroraもCloudWatch Logs
にログ出力(統合ログ基盤)
Amazon CloudWatch Logs
Amazon Aurora
オブザーバビリティ(可観測性)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache
Log
Trace Metric
css, js, html, image
静的コンテンツ
Amazon
CloudFront
AWS Lambda Amazon Aurora
メトリックやトレースを管理したい
ログだけでなく、メトリックや
トレースも管理したい
オブザーバビリティ(可観測性)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
オブジェクト
ストレージ
WAF
WAF
WAF
Cache
Cache
Cache
Trace Metric
css, js, html, image
静的コンテンツ
Amazon
CloudFront
AWS Lambda Amazon Aurora
メトリックやトレースを管理したい
AWS X-Rayでサービストレース、
CloudWatchではメトリック管理
AWS X-Ray
Log
CloudWatch
オブザーバビリティ(可観測性)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• マイクロサービス やAPIのエンドポイントが増えるたびに、ログの独自管理が
困難になってきており、統一したログの管理手法が必要
• → Amazon CloudWatch Logsを利用して、多種多様なAWSサービスの
ログを一元管理できる
• APIに問題が起きた場合のデバッグ方法を確立しておきたい
• APIのend to endのトレーサビリティも改善したい
• → AWS X-Rayを利用すると、各サービスを経由するリクエストをトレー
スし、サービスマップを描くことができる
• APIのエラーやレイテンシーのメトリックを把握しサービスの改善に役
立てたい
• → Amazon CloudWatch Metricsを利用して、AWSサービスのメトリックを
収集
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
課題感
• 認証済みのユーザーのみをサービス利用させたり、認証していないユーザー
でもアクセスできたりとエンドポイントごとに設定したい
• 各マイクロサービス ごとに個人情報の取り扱いやサービスの重要性が異な
り、認可をエンドポイントごとに分けたい
• マイクロサービス ごとに認証認可を実装すると、サービスが増えるた
びに同様のコンポーネントの開発、試験、運用の工数がかかる。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
WAF
WAF
CDNWAF
Cache
Cache
Cache
Log
Trace Metric
オブザーバビリティ(可観測性)
css, js, html, image
静的コンテンツ
認証認可
認証認可
認証認可
認証認可機能を各サービス側で
実装するパターン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
WAF
WAF
CDNWAF
Cache
Cache
Cache
Log
Trace Metric
オブザーバビリティ(可観測性)
css, js, html, image
静的コンテンツ
認証認可
リクエストの検証
認証認可機能をAPIゲートウェイ側で
統合的に実装するパターン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス
マイクロサービス
マイクロサービス
DB
DB
DB
Queue
REST
REST
Event
Webブラウザ
モバイルアプリ endpoint
endpoint
APIゲートウェイ
BFF
WAF
WAF
CDNWAF
Cache
Cache
Cache
Log
Trace Metric
オブザーバビリティ(可観測性)
css, js, html, image
静的コンテンツ
リクエストの検証
Amazon
Cognito
Amazon Cognitoを利用するとAPI Gateway
と連携し、認証認可機能を付加できます
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
• 認証済みのユーザーのみをサービス利用させたり、認証していないユーザー
でもアクセスできたりとエンドポイントごとに設定したい
• → API GatewayとAmazon Cognitoを統合し、認証済みのユーザーをア
クセス可能にしたり、認証機能を導入しないAPIなど個別に設定でき
る。
• 各マイクロサービス ごとに個人情報の取り扱いやサービスの重要性が異な
り、認可をエンドポイントごとに分けたい
• マイクロサービス ごとに認証認可を実装すると、サービスが増えるた
びに同様のコンポーネントの開発、試験、運用の工数がかかる。
• → API GatewayとAmazon Cognitoを統合し、認証済みのユーザーと未認
証のユーザーとに異なる認可を与えたり、ユーザーグループごとに異なる
認可を設定することができる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめ
• サーバーレス を利用することにより、ログやメトリック収集などの非機能要
件もスクラッチ実装する必要なく、サービス統合するだけで利用可能になる
• 全てを一度にサーバーレス に置き換えて行く必要はなく、要件や課題に応じ
て後からサービス連携していくことで機能追加できる
• サーバーレス でAPIを管理することで、本来のユーザーの価値に貢献する部分
にコストを割り当てることができる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you !
@_kensh
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Appendix
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サーバーレスのビジネス戦略
Serverless-First : サーバーレステクノロジーをアプリケーション
のアーキテクチャの第一の選択肢とする方針のこと
 サーバー管理が不要
 柔軟、自動化、スケール
 価値への支払い
 自動の高可用性
サーバーレスが意味するものは何か?
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
モニタリングについて
Metrics
LogsTraces
Amazon
CloudWatch
AWS X-Ray
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
API: マイクロサービスのフロントドア
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2002 - Bezos API Mandate(APIの勅命)
今後、全てのチームはデータと機能をインターフェースを通じて公開せよ。
チーム間のコミュニケーションは、その公開されたインターフェースを通じて行え。
公開インターフェースを
使わないプロセス間通信は認めない(直接リンク、他のチームのデータの直接読み取り、共有メモリ、その
他のいかなるバックドアも)。ネットワークを経由したインターフェース呼び出しのみが許可される。
技術は特に規定しない。
全てのインターフェースは例外なく、外部に公開できるように設計し直さなければならない。つまり、各チーム
はインターフェースを世界中の開発者に公開できるように計画・設計しなければならない。例外なく。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービス アーキテクチャ
マイクロサービスアーキテクチャは1つのアプリケーションを小さなサービス
で、各々のプロセスで実行され、HTTPのAPIのようなLightweightなメカニズム
で通信するようにする開発スタイルのアプローチです。
これらのサービスはビジネスケイパビリティから構築され、完全自動化された
個別のデプロイができます。
サービスの集中型のマネジメントを最小化し、サービスは異なるプログラミン
グ言語で書かれ、異なるデータストレージが使われます。
Martin Fowler
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
増分型/追加型による適用
- レガシーアプリのコンポーネント
にイベントとAPIを作成
- イベントとAPIで連携
(それぞれの独立性を維持)
モノリス(一枚岩)からマイクロ型へ
ストラングラーパターン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
TCO & 運用の役割の変化
運用
従来型の
アプリ開発
サーバーレス
アプリ開発
開発
本番開始
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“ガードレール”
とは?
アプリケーション振る舞いが望まし
くないほどに発生したりその影響範
囲が広がりすぎないように一定規模
に留めるようにするプロセスや手法
のメカニズム
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
現実世界における “ガードレール”
モニタリング プロビジョニング デプロイ コスト管理
セキュリティ
& コンプライアンス
CPU 利用率
Database
スループット
ビジネス
プロセス
アカウントの
設定/アクセ
ス
標準化・コン
プライアンス
認定された保
守
時間枠
ツールセット
管理
テストリリー
スのサイズと
時期
リソースコス
ト
リソースの
利用率
ランレートの
計算・管理
アクセス許可
リソース利用
状況管理
構成管理
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Realtor.com : サービス呼び出しにAPIを使用
Lambda
ファンクション
Amazon CloudWatch
モニタリング
Amazon
CloudFront
モバイル
アプリ
API Gateway
キャッシュ
ブラウザ
アプリ
イメージ処理
インターネット
Amazon
DynamoDB
“日々 8億のイメージ処理
をAmazon API Gateway
経由で処理している”
Kuntal Shah,
SVP Engineering,
Realtor.com
Amazon
API Gateway
従業員
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
On-Premise
既存互換I/F新アプリ向けI/F
アダストリア様
サーバーレスによるモバイルバックエンド
マネージド
業務注力
マネージド
自動リソース管理
S3
API
Gateway
• モバイルアプリ「.st」
• PC Web用 ECサイト
認証
負荷に応じて自動でリソース拡張/縮退
API
API
バック
エンド
EC
システム
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
今、まさにパラダイムシフトのとき!
実験的な領域や
更新頻度の高い
エリアから
機能を迅速に
リリース
より良い
サービスの
構築へ
ビジネス
ロジックに
フォーカス
ソフトウェア
システムの
分離
Win
customers
75% の組織は今後 2 年でサーバーレステクノロジーの
利用や計画をしている 1
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
デプロイ/アプリケーション展開のスケール
1000s の
チーム
マイクロ
サービス
CI/CD サーバーレス
年間 6000万以上のデプロイ*
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
飛越し型での適用(リープフロッグ)キャパシティ–コストモデル
オ ペ レ ー シ ョナル – 開 発 モ デ ル
オンプレミスクラウド
“レガシー” アーキテクチャ モダンアーキテクチャ
AWS
EC2
AWS
ECS
AWS
FARGATE
AWS
EKS
コンテナ
AWS
ECS
AWS
FARGATE
AWS
EKS
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
イベント駆動アーキテクチャによる
信頼性とスケーラビリティ
非同期イベント
応答性の改善と
依存性の削除
イベントルーター
プロデューサとコンシューマを
お互いに抽象化
イベントストア
サービスが処理可能になるまで
メッセージをバッファリング
イベントの投入 イベント配信
イベントストア
ビジネス
ロジック

More Related Content

What's hot (20)

PDF
Infrastructure as Code (IaC) 談義 2022
Amazon Web Services Japan
 
PDF
20190806 AWS Black Belt Online Seminar AWS Glue
Amazon Web Services Japan
 
PDF
20200630 AWS Black Belt Online Seminar Amazon Cognito
Amazon Web Services Japan
 
PDF
20200303 AWS Black Belt Online Seminar AWS Cloud Development Kit (CDK)
Amazon Web Services Japan
 
PDF
20190326 AWS Black Belt Online Seminar Amazon CloudWatch
Amazon Web Services Japan
 
PPTX
20211109 bleaの使い方(基本編)
Amazon Web Services Japan
 
PDF
Amazon Athena 初心者向けハンズオン
Amazon Web Services Japan
 
PDF
20190821 AWS Black Belt Online Seminar AWS AppSync
Amazon Web Services Japan
 
PDF
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
Amazon Web Services Japan
 
PDF
20190522 AWS Black Belt Online Seminar AWS Step Functions
Amazon Web Services Japan
 
PDF
DevOps with Database on AWS
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2017 Amazon Athena
Amazon Web Services Japan
 
PPTX
[社内勉強会]ELBとALBと数万スパイク負荷テスト
Takahiro Moteki
 
PDF
AWS Black Belt Online Seminar Amazon Aurora
Amazon Web Services Japan
 
PPTX
分散トレーシングAWS:X-Rayとの上手い付き合い方
Recruit Lifestyle Co., Ltd.
 
PDF
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
Amazon Web Services Japan
 
PDF
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
Amazon Web Services Japan
 
PDF
20210216 AWS Black Belt Online Seminar AWS Database Migration Service
Amazon Web Services Japan
 
PDF
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
Amazon Web Services Japan
 
PDF
AWS における Microservices Architecture と DevOps を推進する組織と人とツール
Amazon Web Services Japan
 
Infrastructure as Code (IaC) 談義 2022
Amazon Web Services Japan
 
20190806 AWS Black Belt Online Seminar AWS Glue
Amazon Web Services Japan
 
20200630 AWS Black Belt Online Seminar Amazon Cognito
Amazon Web Services Japan
 
20200303 AWS Black Belt Online Seminar AWS Cloud Development Kit (CDK)
Amazon Web Services Japan
 
20190326 AWS Black Belt Online Seminar Amazon CloudWatch
Amazon Web Services Japan
 
20211109 bleaの使い方(基本編)
Amazon Web Services Japan
 
Amazon Athena 初心者向けハンズオン
Amazon Web Services Japan
 
20190821 AWS Black Belt Online Seminar AWS AppSync
Amazon Web Services Japan
 
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
Amazon Web Services Japan
 
20190522 AWS Black Belt Online Seminar AWS Step Functions
Amazon Web Services Japan
 
DevOps with Database on AWS
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 Amazon Athena
Amazon Web Services Japan
 
[社内勉強会]ELBとALBと数万スパイク負荷テスト
Takahiro Moteki
 
AWS Black Belt Online Seminar Amazon Aurora
Amazon Web Services Japan
 
分散トレーシングAWS:X-Rayとの上手い付き合い方
Recruit Lifestyle Co., Ltd.
 
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
Amazon Web Services Japan
 
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
Amazon Web Services Japan
 
20210216 AWS Black Belt Online Seminar AWS Database Migration Service
Amazon Web Services Japan
 
ゲームアーキテクチャパターン (Aurora Serverless / DynamoDB)
Amazon Web Services Japan
 
AWS における Microservices Architecture と DevOps を推進する組織と人とツール
Amazon Web Services Japan
 

Similar to 20200708サーバーレスでのAPI管理の考え方 (20)

PDF
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon Web Services Japan
 
PDF
20200728 AWS Black Belt Online Seminar What's New in Serverless
Amazon Web Services Japan
 
PPTX
API Academy:マイクロサービス化へのファーストステップ
CA Technologies
 
PDF
ハイブリットクラウド環境におけるモダンアプリケーション開発
政雄 金森
 
PDF
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
Amazon Web Services Japan
 
PDF
AWS and PCI DSS
Kameda Harunobu
 
PDF
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
Amazon Web Services Japan
 
PDF
[CTO Night & Day 2019] CTO のための一歩進んだコンテナ入門 #ctonight
Amazon Web Services Japan
 
PDF
AWS の IoT 向けサービス
Amazon Web Services Japan
 
PDF
Javaプログラマーももう逃げられない。マイクロサービスとAPIの世界。
Takakiyo Tanaka
 
PDF
20201118 AWS Black Belt Online Seminar 形で考えるサーバーレス設計 サーバーレスユースケースパターン解説
Amazon Web Services Japan
 
PDF
Management & Governance on AWS こんなこともできます
Amazon Web Services Japan
 
PDF
AWSの様々なアーキテクチャ
Kameda Harunobu
 
PDF
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
Amazon Web Services Japan
 
PDF
[CTO Night & Day 2019] グローバルのサービス展開に向けたマルチリージョンアーキテクチャ- #ctonight
Amazon Web Services Japan
 
PDF
[CTC Forum 2019/10/25] 事例から学ぶ!AWS 移行でデータベースの管理・コストを削減する方法
Takanori Ohba
 
PDF
[AWS DevDay] Cognito / Amplify で加速するエンタープライズのアプリケーション開発
Yuki Ando
 
PDF
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
Junji Nishihara
 
PDF
セキュリティ設計の頻出論点
Tomohiro Nakashima
 
PDF
IoT@Loft #4 - IoT製品の量産化および運用を効率化させるためのAWS サービスの使い方
Amazon Web Services Japan
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon Web Services Japan
 
20200728 AWS Black Belt Online Seminar What's New in Serverless
Amazon Web Services Japan
 
API Academy:マイクロサービス化へのファーストステップ
CA Technologies
 
ハイブリットクラウド環境におけるモダンアプリケーション開発
政雄 金森
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
Amazon Web Services Japan
 
AWS and PCI DSS
Kameda Harunobu
 
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
Amazon Web Services Japan
 
[CTO Night & Day 2019] CTO のための一歩進んだコンテナ入門 #ctonight
Amazon Web Services Japan
 
AWS の IoT 向けサービス
Amazon Web Services Japan
 
Javaプログラマーももう逃げられない。マイクロサービスとAPIの世界。
Takakiyo Tanaka
 
20201118 AWS Black Belt Online Seminar 形で考えるサーバーレス設計 サーバーレスユースケースパターン解説
Amazon Web Services Japan
 
Management & Governance on AWS こんなこともできます
Amazon Web Services Japan
 
AWSの様々なアーキテクチャ
Kameda Harunobu
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
Amazon Web Services Japan
 
[CTO Night & Day 2019] グローバルのサービス展開に向けたマルチリージョンアーキテクチャ- #ctonight
Amazon Web Services Japan
 
[CTC Forum 2019/10/25] 事例から学ぶ!AWS 移行でデータベースの管理・コストを削減する方法
Takanori Ohba
 
[AWS DevDay] Cognito / Amplify で加速するエンタープライズのアプリケーション開発
Yuki Ando
 
"Kong Summit, Japan 2022" パートナーセッション:Kong on AWS で実現するスケーラブルな API 基盤の構築
Junji Nishihara
 
セキュリティ設計の頻出論点
Tomohiro Nakashima
 
IoT@Loft #4 - IoT製品の量産化および運用を効率化させるためのAWS サービスの使い方
Amazon Web Services Japan
 
Ad

More from Amazon Web Services Japan (20)

PDF
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
Amazon Web Services Japan
 
PDF
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
Amazon Web Services Japan
 
PDF
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
Amazon Web Services Japan
 
PDF
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
Amazon Web Services Japan
 
PDF
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Web Services Japan
 
PPTX
20220409 AWS BLEA 開発にあたって検討したこと
Amazon Web Services Japan
 
PDF
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
Amazon Web Services Japan
 
PDF
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
Amazon Web Services Japan
 
PDF
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
Amazon Web Services Japan
 
PDF
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
Amazon Web Services Japan
 
PDF
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
Amazon Web Services Japan
 
PDF
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
Amazon Web Services Japan
 
PDF
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Web Services Japan
 
PPTX
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
Amazon Web Services Japan
 
PDF
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
Amazon Web Services Japan
 
PDF
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
Amazon Web Services Japan
 
PDF
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
Amazon Web Services Japan
 
PDF
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
Amazon Web Services Japan
 
PDF
20211203 AWS Black Belt Online Seminar AWS re:Invent 2021アップデート速報
Amazon Web Services Japan
 
PPTX
20211109 JAWS-UG SRE keynotes
Amazon Web Services Japan
 
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
Amazon Web Services Japan
 
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
Amazon Web Services Japan
 
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
Amazon Web Services Japan
 
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
Amazon Web Services Japan
 
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Web Services Japan
 
20220409 AWS BLEA 開発にあたって検討したこと
Amazon Web Services Japan
 
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
Amazon Web Services Japan
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
Amazon Web Services Japan
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
Amazon Web Services Japan
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
Amazon Web Services Japan
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
Amazon Web Services Japan
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
Amazon Web Services Japan
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Web Services Japan
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
Amazon Web Services Japan
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
Amazon Web Services Japan
 
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
Amazon Web Services Japan
 
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
Amazon Web Services Japan
 
20211209 Ops-JAWS Re invent2021re-cap-cloud operations
Amazon Web Services Japan
 
20211203 AWS Black Belt Online Seminar AWS re:Invent 2021アップデート速報
Amazon Web Services Japan
 
20211109 JAWS-UG SRE keynotes
Amazon Web Services Japan
 
Ad

Recently uploaded (10)

PDF
ABC2025S LT講演「世界の窓から Androidこんにちは2025」アプリ自動生成の将来?ロボティクスの夢再び?
嶋 是一 (Yoshikazu SHIMA)
 
PDF
20250710_Devinで切り拓くDB革命_〜価値創出に集中せよ〜.pdf
Masaki Yamakawa
 
PDF
20250630_aws_reinforce_2025_aws_sheild_network_security_director
uedayuki
 
PDF
プライバシ保護のためのインターネットアーキテクチャの進化 (2025-07-11)
Jun Kurihara
 
PDF
[Hardening Designers Confernece 2025]ランサムウェアでの見えざるログ・見えるログ
kataware
 
PDF
生成AIパネルトーク(Interop25Tokyo APPS JAPAN M1-07,M2-07 嶋ポジショントーク)
嶋 是一 (Yoshikazu SHIMA)
 
PDF
SIG-AUDIO 2025 Vol.02 オンラインセミナー SIG-Audioプレゼン資料_オーディオプラグイン開発_塩澤達矢.pdf
IGDA Japan SIG-Audio
 
PDF
人気ブロックチェーン基盤「Hyperledger Fabric」最新版を動かしてみた!
LFDT Tokyo Meetup
 
PDF
Hyperledger Fabric最新v3.x系での機能強化、変更点にキャッチアップ!
LFDT Tokyo Meetup
 
PDF
Hyperledger Fabric公式サンプル fabric-samples徹底解説
LFDT Tokyo Meetup
 
ABC2025S LT講演「世界の窓から Androidこんにちは2025」アプリ自動生成の将来?ロボティクスの夢再び?
嶋 是一 (Yoshikazu SHIMA)
 
20250710_Devinで切り拓くDB革命_〜価値創出に集中せよ〜.pdf
Masaki Yamakawa
 
20250630_aws_reinforce_2025_aws_sheild_network_security_director
uedayuki
 
プライバシ保護のためのインターネットアーキテクチャの進化 (2025-07-11)
Jun Kurihara
 
[Hardening Designers Confernece 2025]ランサムウェアでの見えざるログ・見えるログ
kataware
 
生成AIパネルトーク(Interop25Tokyo APPS JAPAN M1-07,M2-07 嶋ポジショントーク)
嶋 是一 (Yoshikazu SHIMA)
 
SIG-AUDIO 2025 Vol.02 オンラインセミナー SIG-Audioプレゼン資料_オーディオプラグイン開発_塩澤達矢.pdf
IGDA Japan SIG-Audio
 
人気ブロックチェーン基盤「Hyperledger Fabric」最新版を動かしてみた!
LFDT Tokyo Meetup
 
Hyperledger Fabric最新v3.x系での機能強化、変更点にキャッチアップ!
LFDT Tokyo Meetup
 
Hyperledger Fabric公式サンプル fabric-samples徹底解説
LFDT Tokyo Meetup
 

20200708サーバーレスでのAPI管理の考え方

  • 1. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 8th July 2020 Kensuke Shimokawa サーバーレスでのAPI管理の考え方 @_kensh
  • 2. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Who am I? Name Kensuke Shimokawa Company Amazon Web Services Japan K.K. Role Serverless Specialist Solutions Architect @_kensh
  • 3. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本セッションは 想定される聴講者 • オンプレでWEBアプリやAPIを構築したことがある • クラウド上でVMベースでAPI構築、管理、運用している • 開発者、運用者、またはそれらの人員を管理している人 • サーバーレス での API管理の考え方を知りたい ゴール • サーバーレス でのAPI構築、運用の考え方を理解する
  • 4. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Table of contents
  • 5. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 今日お話しするテーマ の “API” Web API言語処理系API [SDK/ライブラリ等] ネットワーク 呼び出しAPI “Application Programming Interface”: プログラムやソフトウェア同士がやり取りするための取り決め・仕様
  • 6. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 7. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • モノリスで運用しているアプリでは、画面項目追加といった比較的小規模な 機能変更でも、多くのコンポーネントが密接に関係している • 影響範囲の特定が難しい • ビルド、テストに時間がかかる • 特性の異なる要件の機能が一体になっていることで、スケールしない
  • 8. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 変更の影響が小さくなると、 リリースの速度が向上可能に Monolith すべてを実行 Microservices ひとつのことを実行
  • 9. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 「API」と「疎結合なコミュニケーション」が自動化を 可能にして信頼性を向上 FUNCTION API API MICROSERVICE FUNCTION EVENT API MICROSERVICE EVENT API MICROSERVICE APPLICATION
  • 10. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. モノリスクライアント DB
  • 11. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント 分散 モノリス 分散 モノリス 分散 モノリス DB モノリスを機能ごとに分割してみる ただしDBは共有のまま
  • 12. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感(継続) • モノリスで運用しているアプリでは、画面項目追加といった比較的小規模な 機能変更でも、多くのコンポーネントが密接に関係している • 影響範囲の特定が難しい • → データベースを共通に持つため、項目追加削除など破壊的変更をする際 には他のサービスの影響範囲を見極める必要がある • ビルド、テストに時間がかかる • → 影響のある範囲をビルド・テストするため、やはり時間がかかる • 特性の異なる要件の機能が一体になっていることで、スケールしない • → 単一サービスを独立にアプリケーション層でスケールさせることはでき るが、結局は共通のデータベースにアクセスするため、他のサービスの影 響は避けられない
  • 13. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 目的に応じたデータベース 膨大なデータ量? 単一DBタイプ では全てに 応じるのは困難 それぞれのモジュール化サービスのデータニーズはどのようなものか? データウェアハウス? 高速レンダリング?
  • 14. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWSのデータベースサービス =“Purpose Built DB”
  • 15. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.https://d1.awsstatic.com/webinars/jp/pdf/services/expertonlinekameda-200209234556.pdf
  • 16. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント マイクロサービス マイクロサービス マイクロサービス DB DB DB モノリスを機能ごとに分割し、データベースもサービスごとに用意する
  • 17. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ビジネス戦略におけるテクノロジーの選択 モジュール型 サービス できる限り マネージドで 自動化 & 標準化 みんなで 責任を分担 目的に応じた 選択 アーキテクチャ パターン 1 運用 モデル 2 ソフトウェア 配信 3 管理 & ガバナンス 4 データ 管理 5
  • 18. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント マイクロサービス マイクロサービス マイクロサービス DB DB DB • マイクロサービス の選択肢 • VMベースで構築 • コンテナで構築 • サーバーレス で構築
  • 19. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント マイクロサービス マイクロサービス マイクロサービス DB DB DB • マイクロサービス の選択肢 • VMベースで構築 • コンテナで構築 • サーバーレス で構築 • 関数レベルの抽象化 • サーバーのリソース確保不要 • メンテナンス不要 • セキュリティパッチなど不要 • 使った分だけの支払い • 柔軟、自動化、スケール • 自動の高可用性
  • 20. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. モノリスのスケール
  • 21. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス のスケール
  • 22. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. モノリスのデリバリーパイプライン 開発者 サービス デリバリーパイプライン
  • 23. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービスのデリバリーパイプライン 開発者 サービス デリバリーパイプライン
  • 24. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • モノリスで運用しているアプリでは、画面項目追加といった比較的小規模な 機能変更でも、多くのコンポーネントが密接に関係している • 影響範囲の特定が難しい • → サービスごとに責任分界が明確 • → API (例えばRESTで公開)の契約に変更がない場合、内部の変更は容易 • ビルド、テストに時間がかかる • → 単一コンポーネントのビルド、テスト時間に収まる • 特性の異なる要件の機能が一体になっていることで、スケールしない • → それぞれのサービスに必要なだけのリソースを割り当てて、コスト効率 よくスケールできる
  • 25. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 26. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • マイクロサービス に分割するのは成功したが、サービス が増えて行くにつれ て、クライアントがサービス エンドポイントに直接アクセスするのがつらい • アクセスプロトコルが千差万別 • クライアント側がバックエンドの能力を個々に把握する必要がある • 可用性、回復性、スループットなど • サービス 側のREST契約が破棄されると直接クライアント影響が出る • 既存資産(モノリス)があり、全てをマイクロサービス に置き換えることは できない • モノリスとマイクロサービス を共存させたい
  • 27. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント マイクロサービス マイクロサービス マイクロサービス DB DB DB REST REST REST REST クライアントは、RESTでマイクロサービス と直接会話すると クライアントが知るべきマイクロサービス が どんどん増えて行く
  • 28. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. API ゲートウェイパターンを導入する クライアント マイクロサービス マイクロサービス マイクロサービス DB DB DB REST REST REST REST </> APIゲートウェイ API ゲートウェイによって、さまざまなバックエンドサービスの呼び出しを 統一された APIで統合
  • 29. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event </> APIゲートウェイ API ゲートウェイのダウンストリームプロトコルが多種に渡っても、 クライアントからはRESTでアクセス可能とする REST
  • 30. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント マイクロサービス DB DB DB REST REST サーバーレス で実装する場合、APIゲートウェイはAmazon API Gateway、Queueの 実現にAmazon SQS、ロジックの実行にAWS Lambdaが利用できる REST Amazon SQS AWS Lambda AWS Lambda Amazon API Gateway
  • 31. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クライアント DB DB 既存のモノリスの前段にAPI Gatewayを配置して、クライアントとモノリスやマイ クロサービス との繋がりを疎結合にすることができる REST AWS Lambda Amazon API Gateway モノリス
  • 32. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • マイクロサービス に分割するのは成功したが、サービス が増えて行くにつれ て、クライアントがサービス エンドポイントに直接アクセスするのがつらい • アクセスプロトコルが千差万別 • → Amazon API Gatewayは多種多様なサービスと統合 • クライアント側がバックエンドの能力を個々に把握する必要がある • 可用性、回復性、スループットなど • →ダウンストリームの能力に応じて、API Gatewayのスループットを調整できる • サービス 側のREST契約が破棄されると直接クライアント影響が出る • → API Gateway 層で(ある程度)影響を吸収できる(e.g. template利用) • モノリスとマイクロサービス を共存させたい • → API Gatewayでバックエンドを抽象化する • クライアントからはモノリスを意識させない
  • 33. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 34. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • システムが順調に軌道に乗り、当初はWebブラウザだけを想定していたクラ イアントが、モバイル(iOS/Android)対応を迫られることになった。 • 返却するレスポンスデータの形式が異なる • モバイルとブラウザアプリで、クライアント数が異なり適切にQuota 割当したい(または個別にスロットリング設定したい) • APIの形式拡張や性能要件はクライアント開発者に決定、設定させたい
  • 35. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ APIゲートウェイ クライアントが多様化してくると全てのクライアントの要求に応える 単一のAPIエンドポイントを維持するのが困難に
  • 36. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ デバイスやクライアントタイプごとに、エンドポイントを分ける
  • 37. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend • エンドポイントを分けることにより • デバイスごとに異なる設定ができる • Quota設定 • セキュリティ設定 • ログ設定 • スロットリング設定 • デバイスごとに提供コンテンツを変 えて配信できる • エンドポイントの設定変更権限を、 フロント開発者に委譲できる • BFFパターン BFFパターンを導入する
  • 38. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • システムが順調に軌道に乗り、当初はWebブラウザだけを想定していたクラ イアントが、モバイル(iOS/Android)対応を迫られることになった。 • 返却するレスポンスデータの形式が異なる • → API Gateway層や、サービス 統合により異なる形式のデータを提供 • モバイルとブラウザアプリで、クライアント数が異なり適切にQuota 割当したい(または個別にスロットリング設定したい) • APIの形式拡張や性能要件はクライアント開発者に決定、設定させたい • → API Gatewayの設定変更権限のみを与えたRoleを作成し、フロントエンド開発 者に提供できる • → API Gatewayのモック機能を使ってバックエンド実装を待たずに試験できる
  • 39. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 40. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • 静的コンテンツアクセスがAPI Gatewayエンドポイントに集中し、トラフィッ クの大部分を閉めるようになった。 • API Gatewayエンドポイントの負荷を下げたい • マイクロサービス はロジックに専念したい • ラウンドトリップのレイテンシーも改善したい
  • 41. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend css, js, html, image 静的コンテンツ 静的コンテンツは、APIエンドポイントを介して配信されている
  • 42. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend オブジェクト ストレージ css, js, html, image 静的コンテンツ 静的コンテンツは、APIゲートウェイのエンドポイントではなく、 オブジェクトストレージに取得に行く
  • 43. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend css, js, html, image 静的コンテンツ Amazon Simple Storage Service オブジェクトストレージとしてAmazon S3の静的ウェブサイトのホスティング 機能が使える https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/WebsiteHosting.html
  • 44. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend CDN css, js, html, image 静的コンテンツ エッジロケーションから配信したい Amazon Simple Storage Service オブジェクトストレージとの間にCDNを配置することで、エッジロケーション から配信でき、さらにエッジキャッシュも利用できる
  • 45. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend css, js, html, image 静的コンテンツ エッジロケーションから配信したい Amazon CloudFront Amazon Simple Storage Service CDNとしてAmazon CloudFrontが利用できる。エッジロケーションと呼ばれる 世界規模のネットワークを通じてコンテンツが配信できる
  • 46. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • 静的コンテンツアクセスがAPI Gatewayエンドポイントに集中し、トラフィッ クの大部分を閉めるようになった。 • API Gatewayエンドポイントの負荷を下げたい • マイクロサービス はロジックに専念したい • → 静的コンテンツGETのトラフィックをAmazon S3へオフロード • ラウンドトリップのレイテンシーも改善したい • → 静的コンテンツGETのトラフィックに対しAmazon CloudFrontキャッシュ利用 • → CloudFrontとAWSオリジンサービス 間の通信費は無料 • → S3へのアクセスをCloudFront経由のみに絞れる • https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/DeveloperGuide/private- content-restricting-access-to-s3.html
  • 47. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 48. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • サービスの利用者が増えてきて、サービスの認知も高まってきた。しかし、 アクセスの中に、悪意のあるリクエストが増えてきている。 • バックエンドリソースが攻撃リクエストにより消費される • バックエンドのアプリケーション層の脆弱性を攻撃される
  • 49. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend css, js, html, image 静的コンテンツ Amazon S3 Amazon CloudFront エンドポイントやエッジに対するLayer7の攻撃が発生している 🔥 🔥 🔥
  • 50. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend WAF WAF WAF css, js, html, image 静的コンテンツ Amazon S3 Amazon CloudFront Web Application Firewall (WAF)を導入し、Layer7の攻撃に備える
  • 51. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend css, js, html, image 静的コンテンツ Amazon S3 Amazon CloudFront AWS WAF では、SQL インジェクションやクロスサイトスクリプティングなどをブロック、 また、ユーザー定義したパターンを除外するルールを作成できる AWS WAF AWS WAF AWS WAF
  • 52. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • サービスの利用者が増えてきて、サービスの認知も高まってきた。しかし、 アクセスの中に、悪意のあるリクエストが増えてきている。 • バックエンドリソースが攻撃リクエストにより消費される • → アクセスパターンのルールを定義して、不当なリクエストを除外 • バックエンドのアプリケーション層の脆弱性を攻撃される • → SQLインジェクションやXSSなどの一般的な攻撃に対応
  • 53. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 54. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • クライアントからのリクエストパターンは限られており、多くのクエリーパ ラメータが共通であるにも関わらず、バックエンドの計算リソースを消費し て、毎回計算し返却している。 • 計算リソースの消費を改善したい • レイテンシーを改善したい
  • 55. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend オブジェクト ストレージ WAF WAF WAF css, js, html, image 静的コンテンツ Amazon CloudFront Amazon CloudFront がキャッシュしない設定になっていたり、API Gatewayに適切に キャッシュ設定がされていない場合、オリジンやバックエンドのリソースが消費される
  • 56. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend オブジェクト ストレージ WAF WAF WAF Cache css, js, html, image 静的コンテンツ Amazon CloudFront Amazon CloudFront がキャッシュ保持する時間を制御できます。この期間を短くすると、 動的なコンテンツを供給できます。この期間を長くすると、クライアントパフォーマンス は向上します。
  • 57. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend オブジェクト ストレージ WAF WAF WAF Cache Cache Cache css, js, html, image 静的コンテンツ Amazon CloudFront API Gatewayのキャッシュ機能を使うことで、キャッシュヒットすればダウンストリーム に処理を連携することなくレスポンスをクライアントに返却できます
  • 58. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF Backend For Frontend オブジェクト ストレージ WAF WAF WAF Cache Cache Cache css, js, html, image 静的コンテンツ Amazon CloudFront AWS Lambda Amazon DynamoDB Amazon DynamoDB accelerator (DAX) Amazon ElastiCache Lambda関数からElastiCacheにアクセスしたり、DynamoDB の前段にDAX(DynamoDB Accelerator)を配置することもで きます。
  • 59. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • クライアントからのリクエストパターンは限られており、多くのクエリーパ ラメータが共通であるにも関わらず、バックエンドの計算リソースを消費し て、毎回計算し返却している。 • 計算リソースの消費を改善したい • → キャッシュヒットするとキャッシュから返却値を取得できるため、バッ クエンドリソース負荷の軽減が見込まれる • レイテンシーを改善したい • → キャッシュヒットするとバックエンド処理時間がラウンドトリップタイ ムにのらない為、レイテンシーが改善する
  • 60. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 61. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • マイクロサービス やAPIのエンドポイントが増えるたびに、ログの独自管理が 困難になってきており、統一したログの管理手法が必要 • APIに問題が起きた場合のデバッグ方法を確立しておきたい • APIのend to endのトレーサビリティも改善したい • APIのエラーやレイテンシーのメトリックを把握しサービスの改善に役 立てたい
  • 62. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF オブジェクト ストレージ WAF WAF WAF Cache Cache Cache css, js, html, image 静的コンテンツ Amazon CloudFront オブザーバビリティ(可観測性) 分散サービスに何らかの問題が発生した場合、個々のサービスごとにモニタリング手法が 異なっていては、 オブザーバビリティ(可観測性)が高くはならない Log Log Log
  • 63. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF オブジェクト ストレージ WAF WAF WAF Cache Cache Cache Log css, js, html, image 静的コンテンツ Amazon CloudFront 全てのエンドポイントが統一的に アクセスできるLog収集機能が必要 オブザーバビリティ(可観測性)
  • 64. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF オブジェクト ストレージ WAF WAF WAF Cache Cache Cache css, js, html, image 静的コンテンツ Amazon CloudFront Amazon CloudWatch Logsを利用 すると統一したログ収集が可能 Amazon CloudWatch Logs オブザーバビリティ(可観測性)
  • 65. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF オブジェクト ストレージ WAF WAF WAF Cache Cache Cache Log css, js, html, image 静的コンテンツ Amazon CloudFront AWS Lambda LambdaやAuroraもCloudWatch Logs にログ出力(統合ログ基盤) Amazon CloudWatch Logs Amazon Aurora オブザーバビリティ(可観測性)
  • 66. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF オブジェクト ストレージ WAF WAF WAF Cache Cache Cache Log Trace Metric css, js, html, image 静的コンテンツ Amazon CloudFront AWS Lambda Amazon Aurora メトリックやトレースを管理したい ログだけでなく、メトリックや トレースも管理したい オブザーバビリティ(可観測性)
  • 67. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF オブジェクト ストレージ WAF WAF WAF Cache Cache Cache Trace Metric css, js, html, image 静的コンテンツ Amazon CloudFront AWS Lambda Amazon Aurora メトリックやトレースを管理したい AWS X-Rayでサービストレース、 CloudWatchではメトリック管理 AWS X-Ray Log CloudWatch オブザーバビリティ(可観測性)
  • 68. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • マイクロサービス やAPIのエンドポイントが増えるたびに、ログの独自管理が 困難になってきており、統一したログの管理手法が必要 • → Amazon CloudWatch Logsを利用して、多種多様なAWSサービスの ログを一元管理できる • APIに問題が起きた場合のデバッグ方法を確立しておきたい • APIのend to endのトレーサビリティも改善したい • → AWS X-Rayを利用すると、各サービスを経由するリクエストをトレー スし、サービスマップを描くことができる • APIのエラーやレイテンシーのメトリックを把握しサービスの改善に役 立てたい • → Amazon CloudWatch Metricsを利用して、AWSサービスのメトリックを 収集
  • 69. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 70. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 課題感 • 認証済みのユーザーのみをサービス利用させたり、認証していないユーザー でもアクセスできたりとエンドポイントごとに設定したい • 各マイクロサービス ごとに個人情報の取り扱いやサービスの重要性が異な り、認可をエンドポイントごとに分けたい • マイクロサービス ごとに認証認可を実装すると、サービスが増えるた びに同様のコンポーネントの開発、試験、運用の工数がかかる。
  • 71. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF WAF WAF CDNWAF Cache Cache Cache Log Trace Metric オブザーバビリティ(可観測性) css, js, html, image 静的コンテンツ 認証認可 認証認可 認証認可 認証認可機能を各サービス側で 実装するパターン
  • 72. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF WAF WAF CDNWAF Cache Cache Cache Log Trace Metric オブザーバビリティ(可観測性) css, js, html, image 静的コンテンツ 認証認可 リクエストの検証 認証認可機能をAPIゲートウェイ側で 統合的に実装するパターン
  • 73. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス マイクロサービス マイクロサービス DB DB DB Queue REST REST Event Webブラウザ モバイルアプリ endpoint endpoint APIゲートウェイ BFF WAF WAF CDNWAF Cache Cache Cache Log Trace Metric オブザーバビリティ(可観測性) css, js, html, image 静的コンテンツ リクエストの検証 Amazon Cognito Amazon Cognitoを利用するとAPI Gateway と連携し、認証認可機能を付加できます
  • 74. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 • 認証済みのユーザーのみをサービス利用させたり、認証していないユーザー でもアクセスできたりとエンドポイントごとに設定したい • → API GatewayとAmazon Cognitoを統合し、認証済みのユーザーをア クセス可能にしたり、認証機能を導入しないAPIなど個別に設定でき る。 • 各マイクロサービス ごとに個人情報の取り扱いやサービスの重要性が異な り、認可をエンドポイントごとに分けたい • マイクロサービス ごとに認証認可を実装すると、サービスが増えるた びに同様のコンポーネントの開発、試験、運用の工数がかかる。 • → API GatewayとAmazon Cognitoを統合し、認証済みのユーザーと未認 証のユーザーとに異なる認可を与えたり、ユーザーグループごとに異なる 認可を設定することができる
  • 75. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 76. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ • サーバーレス を利用することにより、ログやメトリック収集などの非機能要 件もスクラッチ実装する必要なく、サービス統合するだけで利用可能になる • 全てを一度にサーバーレス に置き換えて行く必要はなく、要件や課題に応じ て後からサービス連携していくことで機能追加できる • サーバーレス でAPIを管理することで、本来のユーザーの価値に貢献する部分 にコストを割り当てることができる
  • 77. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you ! @_kensh
  • 78. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Appendix
  • 79. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サーバーレスのビジネス戦略 Serverless-First : サーバーレステクノロジーをアプリケーション のアーキテクチャの第一の選択肢とする方針のこと  サーバー管理が不要  柔軟、自動化、スケール  価値への支払い  自動の高可用性 サーバーレスが意味するものは何か?
  • 80. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. モニタリングについて Metrics LogsTraces Amazon CloudWatch AWS X-Ray
  • 81. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. API: マイクロサービスのフロントドア
  • 82. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2002 - Bezos API Mandate(APIの勅命) 今後、全てのチームはデータと機能をインターフェースを通じて公開せよ。 チーム間のコミュニケーションは、その公開されたインターフェースを通じて行え。 公開インターフェースを 使わないプロセス間通信は認めない(直接リンク、他のチームのデータの直接読み取り、共有メモリ、その 他のいかなるバックドアも)。ネットワークを経由したインターフェース呼び出しのみが許可される。 技術は特に規定しない。 全てのインターフェースは例外なく、外部に公開できるように設計し直さなければならない。つまり、各チーム はインターフェースを世界中の開発者に公開できるように計画・設計しなければならない。例外なく。
  • 83. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービス アーキテクチャ マイクロサービスアーキテクチャは1つのアプリケーションを小さなサービス で、各々のプロセスで実行され、HTTPのAPIのようなLightweightなメカニズム で通信するようにする開発スタイルのアプローチです。 これらのサービスはビジネスケイパビリティから構築され、完全自動化された 個別のデプロイができます。 サービスの集中型のマネジメントを最小化し、サービスは異なるプログラミン グ言語で書かれ、異なるデータストレージが使われます。 Martin Fowler
  • 84. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 増分型/追加型による適用 - レガシーアプリのコンポーネント にイベントとAPIを作成 - イベントとAPIで連携 (それぞれの独立性を維持) モノリス(一枚岩)からマイクロ型へ ストラングラーパターン
  • 85. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. TCO & 運用の役割の変化 運用 従来型の アプリ開発 サーバーレス アプリ開発 開発 本番開始
  • 86. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “ガードレール” とは? アプリケーション振る舞いが望まし くないほどに発生したりその影響範 囲が広がりすぎないように一定規模 に留めるようにするプロセスや手法 のメカニズム
  • 87. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 現実世界における “ガードレール” モニタリング プロビジョニング デプロイ コスト管理 セキュリティ & コンプライアンス CPU 利用率 Database スループット ビジネス プロセス アカウントの 設定/アクセ ス 標準化・コン プライアンス 認定された保 守 時間枠 ツールセット 管理 テストリリー スのサイズと 時期 リソースコス ト リソースの 利用率 ランレートの 計算・管理 アクセス許可 リソース利用 状況管理 構成管理
  • 88. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Realtor.com : サービス呼び出しにAPIを使用 Lambda ファンクション Amazon CloudWatch モニタリング Amazon CloudFront モバイル アプリ API Gateway キャッシュ ブラウザ アプリ イメージ処理 インターネット Amazon DynamoDB “日々 8億のイメージ処理 をAmazon API Gateway 経由で処理している” Kuntal Shah, SVP Engineering, Realtor.com Amazon API Gateway 従業員
  • 89. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. On-Premise 既存互換I/F新アプリ向けI/F アダストリア様 サーバーレスによるモバイルバックエンド マネージド 業務注力 マネージド 自動リソース管理 S3 API Gateway • モバイルアプリ「.st」 • PC Web用 ECサイト 認証 負荷に応じて自動でリソース拡張/縮退 API API バック エンド EC システム
  • 90. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 今、まさにパラダイムシフトのとき! 実験的な領域や 更新頻度の高い エリアから 機能を迅速に リリース より良い サービスの 構築へ ビジネス ロジックに フォーカス ソフトウェア システムの 分離 Win customers 75% の組織は今後 2 年でサーバーレステクノロジーの 利用や計画をしている 1
  • 91. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. デプロイ/アプリケーション展開のスケール 1000s の チーム マイクロ サービス CI/CD サーバーレス 年間 6000万以上のデプロイ*
  • 92. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 飛越し型での適用(リープフロッグ)キャパシティ–コストモデル オ ペ レ ー シ ョナル – 開 発 モ デ ル オンプレミスクラウド “レガシー” アーキテクチャ モダンアーキテクチャ AWS EC2 AWS ECS AWS FARGATE AWS EKS コンテナ AWS ECS AWS FARGATE AWS EKS
  • 93. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. イベント駆動アーキテクチャによる 信頼性とスケーラビリティ 非同期イベント 応答性の改善と 依存性の削除 イベントルーター プロデューサとコンシューマを お互いに抽象化 イベントストア サービスが処理可能になるまで メッセージをバッファリング イベントの投入 イベント配信 イベントストア ビジネス ロジック