Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Asynchronous over Synchronous / 同期という思い込み 世界は非同期で構成されている

kensh
January 20, 2024

Asynchronous over Synchronous / 同期という思い込み 世界は非同期で構成されている

サーバーレスサービスである API Gateway や Lambda を使って 同期的な REST API を構築されている方は多いのではないでしょうか。サーバーレスで REST APIをつくると、リクエストの分だけの課金であったり、デフォルトの可用性が与えられたりメリットは大きいです。ただし、サーバーレスの真価は非同期アーキテクチャにあります。このセッションではさまざまなサーバーレスの非同期パターンを紹介するとともに、実際の顧客事例においてどのようなユースケースで非同期系サーバーレスが利用されているかをご紹介いたします。

kensh

January 20, 2024
Tweet

More Decks by kensh

Other Decks in Technology

Transcript

  1. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 同期という思い込み 世界は⾮同期で構成されている 下川 賢介 A W S - 5 6 アマゾン ウェブ サービス ジャパン合同会社 サービス スペシャリスト統括本部 アプリケーション開発技術本部 サーバーレススペシャリスト
  2. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 下川 賢介 サービス スペシャリスト統括本部 アプリケーション開発技術本部 サーバーレス スペシャリスト Slides https://speakerdeck.com/_kensh Qiita https://qiita.com/_kensh
  3. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Agenda • ⾝近な話から • 今、⾮同期が求められている理由 • ⾮同期について • 世界は⾮同期で構成されている • ユースケースを交えた紹介
  4. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾝近な話から、、、
  5. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 皆さんの⽇常⽣活で ⾮同期になっているもの思い付きますか︖
  6. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 宅配で考えてみる / 在宅時は、、、 荷物を届ける 荷物を受け取れる
  7. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 宅配で考えてみる / 不在時は、、、 荷物を届ける 荷物を受け取れない
  8. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 宅配で考えてみる / 不在時は、、、 荷物を届ける 置き配ができれば
  9. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 宅配で考えてみる / 不在時は、、、 帰宅時に荷物を受け取れる 置き配ができれば ⾮同期
  10. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 皆さんの⽇常⽣活に ⾮同期は、ありふれている︖
  11. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 今、⾮同期が求められている理由
  12. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. イノベーションループ Listen Idea Experiment イノベーション ループ 傾聴 アイデア 実験
  13. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. アーキテクチャの結合度 ⼩さなピースに分けて ゆるく結合させたい
  14. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⼩さなピースを API で結合してみる API API
  15. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ”デリバリー速度” の獲得 • マイクロサービスの最⼤のメリットは、ビジネス変化に対応する “デリバリー速度” の獲得 • でもAPIで作ったサービスは頻繁な変更に対応するのは難しい • なぜなら API には強いインターフェース契約があるから
  16. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 契約による結合 API API インターフェース契約 APIにはインターフェースを公開し 利用者に宣言する必要がある 利用者は公開者の宣言にしたがって 送信する義務を負う
  17. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 互いに依存する API API (API利用者 = クライアント) 契約を守らないと呼び出せない (API提供者) 契約を破棄できない 不自然な維持、冗長な拡張
  18. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 仕様と実装の乖離が許されない API = 契約 • 契約を記述する⼿段の進化 • 契約の配布や、スキーマレジストリ 管理のマネージド化 • 契約は公開されるが強制できるもの ではない • クローズドな API からオープンな API へ
  19. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 多様化、複雑化、膨⼤化する依存関係 API 互いに依存する 互いに依存する API
  20. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ”デリバリー速度” の獲得︖ 達成できたか︖
  21. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 同期的な API の課題 • 他サービスの障害に影響を受ける • 障害影響範囲 • 依存関係の同時デプロイ • クライアントへの統⼀した体験が提供しにくい • ノイジーネイバー対策 • ⾼スループット対策 • Quota / Throttle 管理 • HTTPリソースやメソッドごとに要件が複雑化 • 同⼀エンドポイントでも機能要件や、可⽤性・セキュリティなど⾮機能要件 が異なる
  22. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ”デリバリー速度” の獲得 / 再掲 • マイクロサービスの最⼤のメリットは、ビジネス変化に対応する “デリバリー速度” の獲得 • でもAPIで作ったサービスは頻繁な変更に対応するのは難しい • なぜなら API には強いインターフェース契約があるから そこで、”疎結合” にマイクロサービス を組み⽴てる ⾮同期に “ゆるく” 結合されたアーキテクチャ
  23. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. API における様々な改善 / 補⾜ • サービスメッシュ • API ゲートウェイ • サーキットブレーカー • 集約ログ • ポリグロット • GraphQL • サービスディスカバリ (注意) 今回のセッションでは、⾮同期の理解の ためにあえて同期と⽐較をしていますが、 同期と⾮同期は、排他の関係ではなく、 通常は協調して利⽤します API の管理⽅法も進化していますので API の課題 がそのまま当てはまるわけではありません ※ 本⽇のセッションではAPIの管理⽅法の進化 については割愛
  24. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ”デリバリー速度” の獲得︖ 達成できたか︖ ⇨ ⾮同期アーキテクチャも 検討してみては︖︖
  25. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾮同期について
  26. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 応答性とサービス間依存度の違い API Event
  27. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結合度を実例で確認 (同期API) • プロデューサと、 コンシューマが密結合 • 複数サービスが、 障害ポイント • サービスクオリティの 低いものが、全体の サービス品質を決定 • 外部への依存度が⼤きく、 拡張性が乏しい プロデューサ コンシューマ 😀 受注 サービス 発送 サービス 会計 サービス
  28. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結合度を実例で確認 (同期API) プロデューサ コンシューマ 受注 サービス 発送 サービス 会計 サービス 😩 ダウンストリームの 障害に影響を受ける • プロデューサと、 コンシューマが密結合 • 複数サービスが、 障害ポイント • サービスクオリティの 低いものが、全体の サービス品質を決定 • 外部への依存度が⼤きく、 拡張性が乏しい
  29. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結合度を実例で確認 (同期API) • プロデューサと、 コンシューマが密結合 • 複数サービスが、 障害ポイント • サービスクオリティの 低いものが、全体の サービス品質を決定 • 外部への依存度が⼤きく、 拡張性が乏しい プロデューサ コンシューマ 受注 サービス 発送 サービス 会計 サービス 在庫 サービス NEW NEW 😀 新サービス追加 コードの修正が必要
  30. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結合度を実例で確認 (⾮同期Event) • プロデューサと、 コンシューマが疎結合 • 各サービスは独⽴ • 品質、可⽤性管理を独⾃ に実施可能 • 外部への依存度が、低い ため、拡張性が⾼い プロデューサ コンシューマ 😀 受注 サービス 発送 サービス 会計 サービス Event
  31. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結合度を実例で確認 (⾮同期Event) • プロデューサと、 コンシューマが疎結合 • 各サービスは独⽴ • 品質、可⽤性管理を独⾃ に実施可能 • 外部への依存度が、低い ため、拡張性が⾼い プロデューサ コンシューマ 😀 受注 サービス 発送 サービス 会計 サービス Event ダウンストリームの 障害からの分離
  32. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結合度を実例で確認 (⾮同期Event) • プロデューサと、 コンシューマが疎結合 • 各サービスは独⽴ • 品質、可⽤性管理を独⾃ に実施可能 • 外部への依存度が、低い ため、拡張性が⾼い プロデューサ コンシューマ 😀 受注 サービス 発送 サービス 会計 サービス Event 在庫 サービス コードの修正不要 新サービス追加時に Subscribeするだけ NEW
  33. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 世界は⾮同期で構成されている (顧客事例を添えて)
  34. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 世界は⾮同期で構成されている • ⾮同期レスポンスパターン • モバイル決済 • トラフィックのコントロール • プレイリスト配信サービス • 段階的なキャッシュ⽣成 • リアルタイムリコメンデーション • ⾮同期による分割統治 • POSデータ処理 • セキュアなアップローダー
  35. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾮同期レスポンスパターン
  36. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾮同期アーキテクチャによる応答の課題 • Client が受け取るのは、HTTP 202 Accepted であり、実際の 処理結果ではない • どのように Service B の処理結果 を受け取るか︖ HTTP 202 Accepted 直接の接続性はない
  37. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 国内⼩売企業 EC/モバイル決済の店舗への伝播処理 WebSocket 中継 EC / モバイル モバイルアプリでの キャッシュレス決済 Web での 事前注⽂ WebSocket 店舗POS 即時処理 逐次処理 コネクション管理 Amazon SQS Amazon API Gateway AWS Lambda Amazon DynamoDB
  38. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 国内⼩売企業 EC/モバイル決済の店舗への伝播処理 EC / モバイル モバイルアプリでの キャッシュレス決済 Web での 事前注⽂ 即時処理 逐次処理 Amazon SQS AWS Lambda
  39. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 国内⼩売企業 EC/モバイル決済の店舗への伝播処理 WebSocket 中継 WebSocket 店舗POS コネクション管理 Amazon API Gateway AWS Lambda Amazon DynamoDB
  40. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS Cloud コネクション管理 状態管理 KDDI様 auPAY サービスにおけるイベント駆動の決済完了通知サービス キャッシュレス決済処理の完了の 通知機能をサーバーレス実装 顧客体験向上 マネージド ⾃動リソース管理 スケーラビリティ 配信処理エラー率を⼤幅に改善 インシデント応答時間を 1/3 に短縮 サーバー台数の配慮不要の並列配信で - 同時配信実績: 50% 向上 - 単位処理時間: 1/2 未満に短縮 需要増における対応: これまでの 必要作業が⾃動化され、⼯数 ゼロ へ auPAY アプリ WebSocketによる 即時通知 決済完了したら APIをコール 決済完了通知 API 決済完了 状態を格納 完了更新イベントを受けて通知 決済処理システム 接続管理・通知 Streams API Gateway Lambda API Gateway Lambda DynamoDB
  41. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. KDDI様 auPAY サービスにおけるイベント駆動の決済完了通知サービス auPAY アプリ 決済完了したら APIをコール 決済完了 状態を格納 決済処理システム API Gateway Lambda DynamoDB
  42. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. コネクション管理 状態管理 KDDI様 auPAY サービスにおけるイベント駆動の決済完了通知サービス auPAY アプリ WebSocketによる 即時通知 決済完了通知 API 決済完了 状態を格納 完了更新イベントを受けて通知 接続管理・通知 Streams API Gateway Lambda DynamoDB
  43. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾮同期アーキテクチャによる応答の課題 / 再掲 • Client が受け取るのは、HTTP 202 Accepted であり、実際の 処理結果ではない • どのように Service B の処理結果 を受け取るか︖ HTTP 202 Accepted 直接の接続性はない
  44. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾮同期アーキテクチャによる応答の課題 / 再掲 • Client が受け取るのは、HTTP 202 Accepted であり、実際の 処理結果ではない • どのように Service B の処理結果 を受け取るか︖ • Websocket によるサーバーサイド Push HTTP 202 Accepted connected Push
  45. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. API x Websocket による応答性向上 User API Gateway Mobile client サーバーサイドプッシュ Websocket 接続管理 $connect 処理 ⾮同期 SQS 同期
  46. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. トラフィックのコントロール
  47. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. トラフィック急増の課題 リクエストに応じて スケール プロビジョン オートスケール ハンドルできていないトラフィック 余剰リソース 余剰リソース
  48. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AI 処理 (学習・スコアリング) USEN様 「U MUSIC」AI によるチャンネル選曲とプレイリスト配信サービス 店舗DX :お店の雰囲気、時間帯、 天候に合わせた最適な BGM を提供 コスト最適化 ⾼⽣産性 数⼗万店舗のプレイリストの作成を 並列化し、1時間ごとに 5分 で完了 開発期間を 数ヶ⽉単位 で短縮 新サービスの迅速な展開を加速化 初期投資を 約 6000万円 削減 運⽤⼯数低減 → 中⻑期の維持費も削減 来店者 属性情報 楽曲情報更新 スケーラビリティ データ センター トークン管理 店舗 店舗のお客様 チャンネル情報更新 楽曲管理 配信処理 配信リスト取得 毎時、⾃動学習し 店舗ごとの リストを⽣成 AI 編成担当 チャンネル情報 天気情報 AWS Cloud Lambda SQS API Gateway Lambda SQS API Gateway
  49. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. USEN様 「U MUSIC」AI によるチャンネル選曲とプレイリスト配信サービス 楽曲情報更新 データ センター 楽曲管理 配信処理 配信リスト取得 編成担当 チャンネル情報 Lambda SQS API Gateway Lambda SQS API Gateway
  50. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. トラフィックの⽅向性 今回考えたいのは North-South Traffic 50 API Gateway client client client North-South Traffic East-West Traffic
  51. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Shift North • Traffic の終端をできるだけ North に寄せていく API Gateway client client client North South Traffic terminate
  52. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Shift North • Traffic の終端をできるだけ North に寄せていく • Queue や Stream で Traffic を 終端させて、HTTP status 202 Accepted を返却 API Gateway client client client North South Queue Stream Traffic terminate Shift North
  53. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Shift North • Traffic の終端をできるだけ North に寄せていく • Queue や Stream で Traffic を 終端させて、HTTP status 202 Accepted を返却 • CDN を前段に配置し Edge から の Cache を返却 client client client North South CDN Traffic terminate Shift North
  54. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 段階的なキャッシュ⽣成
  55. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. キャッシュ有効期限を超えた場合の レスポンス低下 • キャッシュから応答できているうちは⾼速 • キャッシュ有効期限を超えた場合、オブジェクト⽣成して応答する ので遅延が顕著になる
  56. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Sansan 様 Eight における⼈物のリアルタイムリコメンデーション ͓஌Γ߹͍Ͱ͔͢ ໊ࢗަ׵ϦΫΤετΛૹ৴ͯ͠ɺ௥Ճ͠·͠ΐ͏ɻ ユーザーアクション 表⽰、クリック、 組織変更… Webサーバー ログ格納 分類、フィルタ 基礎 データ 洗い替え リコメンド計算/キャッシュ化 レーティング⽤データ作成(洗い替え時) レーティング⽤データ更新(随時更新: 10,000件/分) 計算のための キャッシュ処理 つながり度の計算 データ処理 (追加、更新) リアルタイム スコアリング 10万件/分 レーティング テーブル リコメンド結果 ⼀連のデータ処理フロー管理(Step Functions) Aurora Redshift Kinesis Data Streams S3 Bucket Data Pipeline SQS
  57. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Sansan 様 Eight における⼈物のリアルタイムリコメンデーション ͓஌Γ߹͍Ͱ͔͢ ໊ࢗަ׵ϦΫΤετΛૹ৴ͯ͠ɺ௥Ճ͠·͠ΐ͏ɻ ユーザーアクション 表⽰、クリック、 組織変更… Webサーバー リコメンド計算/キャッシュ化 リコメンド結果 HIT!
  58. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Sansan 様 Eight における⼈物のリアルタイムリコメンデーション ͓஌Γ߹͍Ͱ͔͢ ໊ࢗަ׵ϦΫΤετΛૹ৴ͯ͠ɺ௥Ճ͠·͠ΐ͏ɻ ユーザーアクション 表⽰、クリック、 組織変更… Webサーバー リコメンド計算/キャッシュ化 リコメンド結果 SQS 計算のための キャッシュ処理 つながり度の計算 Too Old!
  59. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. キャッシュ更新指⽰を受けるキュー • 同期リクエスト応答には 有効期限切れオブジェクトを返却しつつ SQS に更新命令を送信 • SQS からトリガーされた Lambda は⾮同期に キャッシュを最新化 • 次回以降のキャッシュヒットでは有効期限内のオブジェクト応答 • ランキングやリコメンドなど、”厳密な最新さ” を求められない場合に 有効
  60. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Incremental Cache Generation (段階的なキャッシュ⽣成) User API Gateway Mobile client キャッシュ SQS Timestamp が許容範囲外なら キャッシュ応答後に SQS に更新指⽰ 同期 データストア 取得 ⾮同期 更新
  61. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⾮同期による分割統治
  62. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ⼩さくて⼤量のタスクを捌きたい • Apache Spark など、専⾨性の⾼いエンジニアの確保が難しい • 再試⾏の管理を⼿軽にしたい
  63. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS Cloud 受取 ダイソー様 サーバーレスによるPOSデータ処理 • 5,000 を超える店舗、 70,000 以上の商品点数 • 今後のデータ増加に ⾃動でリソース拡張 それぞれの実際の負荷に応じて独⽴して⾃動で拡張/縮退 処理優先 or コスト優先で処理量の調整を設定可能 チェック ためる 参照更新 参照 コマンド クエリ SNS SNS SNS SQS SQS SQS SQS S3 Aurora S3
  64. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 受取 ダイソー様 サーバーレスによるPOSデータ処理 それぞれの実際の負荷に応じて独⽴して⾃動で拡張/縮退 処理優先 or コスト優先で処理量の調整を設定可能 SNS SQS S3
  65. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ダイソー様 サーバーレスによるPOSデータ処理 それぞれの実際の負荷に応じて独⽴して⾃動で拡張/縮退 処理優先 or コスト優先で処理量の調整を設定可能 チェック SNS SQS SQS
  66. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ダイソー様 サーバーレスによるPOSデータ処理 それぞれの実際の負荷に応じて独⽴して⾃動で拡張/縮退 処理優先 or コスト優先で処理量の調整を設定可能 ためる コマンド SNS SQS SQS SQS
  67. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ダイソー様 サーバーレスによるPOSデータ処理 それぞれの実際の負荷に応じて独⽴して⾃動で拡張/縮退 処理優先 or コスト優先で処理量の調整を設定可能 参照 クエリ SQS SQS Aurora S3
  68. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 横浜ゴム様 需給管理システムのサーバーレス実装 コア業務を内製で再構築 • コア業務のロジックを⾃社で 理解し、差別化機能にする • 運⽤⼯数の省⼒化は必達事項 スケーラビリティ コスト最適化 変更容易性 - 今後の対象拠点の拡⼤展開を ⾒据えたデータ増加に対処可能 - 事業部の要望やデータ構造の 変更に短期での対応が可能 - サーバー運⽤⼯数省⼒化 - ランニングコストの⼤幅な削減 定期実⾏ 最終出⼒結果 中間作業データ データ 準備 データ 整形 集計 最⼤ 50 並列化実⾏ Step Functions 可視化ツール (tableau) オンプレミス 業務担当者 集計 データ 加⼯ 加⼯ / 集計フロー Amazon Athena 各拠点の販売計画・⽣産・在庫データ
  69. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 横浜ゴム様 需給管理システムのサーバーレス実装 最終出⼒結果 中間作業データ データ 準備 データ 整形 集計 最⼤ 50 並列化実⾏ Step Functions 集計 データ 加⼯ 加⼯ / 集計フロー
  70. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 最近の軽量 Map Reduce は Step Functions で "Game Number", "Game Length" 1, 30 2, 29 3, 31 4, 16 ‥ S3 に置かれた CSV ファイル内のデータにビジネスロジックを適⽤して処理を⾏う
  71. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 最近の軽量 Map Reduce は Step Functions で S3 に置かれた CSV ファイル内のデータにビジネスロジックを適⽤して処理を⾏う "Game Number", "Game Length" 1, 30 2, 29 3, 31 4, 16 ‥
  72. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 各イテレーションの実⾏ステータスの確認 ※ DescribeMapRun API でも取得可能
  73. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. セキュアなアップローダー
  74. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. API Gateway でのアップローダーについての課題 • API Gateway には ペイロードサイズ 10 MB 制限が
  75. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. コーセー様 複数の個別カウンセリングアプリを短期間で開発 顧客体験向上のための診断機能付き 個別アプリを半年で 7 本リリース ⾼⽣産性 スケーラビリティ 共通機能を SAM テンプレート化し 個別アプリをそれぞれ 1、2ヶ⽉で構築 お客様の利⽤が増加しても対応可能 (容量⾒積もりの時間短縮に貢献) ファイアウォール SAM テンプレート化 → 個別アプリを迅速展開 マネージド 業務注⼒ 顧客体験の向上・改善に集中 アプリの運⽤・維持をクラウドに移譲 問診・商品リコメンド 画像解析 カウンセリング 画像 アップロード キューにある 処理要求を取得 解析結果 データ ステート更新 キューに配置 解析結果取得 VPC コーセー HADA mite SEKKISEI 透明感測定 ログ処理 API Gateway S3
  76. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. コーセー様 複数の個別カウンセリングアプリを短期間で開発 問診・商品リコメンド カウンセリング 解析結果取得 コーセー HADA mite API Gateway
  77. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. コーセー様 複数の個別カウンセリングアプリを短期間で開発 画像 アップロード キューに配置 コーセー HADA mite S3
  78. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. アップローダーとしての⾮同期パターン • API Gateway には ペイロードサイズ 10 MB 制限が • API Gateway は read / command に専念 • 署名付き URL を発⾏することで、S3 に対するアップロード • write / upload / event は S3 を対象にすることでスケール • 署名付きなのでセキュア • 署名付き URL を取得できるクライアントは API Gateway 経由で認証済み
  79. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon S3 署名付き URL User API Gateway Lambda Mobile client S3 認証 同期 署名付き URL 登録 SQS Lambda 処理 バッファ HTTPS リクエスト ⾮同期 署名付き URL の発⾏
  80. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. まとめ • API Gateway + Lambda で、同期的な REST API を⽣成という以外の、 サーバーレス⾮同期パターンも重要 • 同期、⾮同期は排他的ではなく⼀緒に合わせて使える • 多くのエンタープライズ企業で、⾮同期アーキテクチャが導⼊されている • ⾮同期は、障害影響の分離を可能にし、デプロイ依存関係の解消にも役⽴つ ⾮同期処理は 世界中でどこにでもある、 ありふれた アーキテクチャ パターン ということ
  81. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 世界は⾮同期で満ちている 同期という思い込みを捨てて、⾮同期へ︕
  82. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Thank you! Kensuke Shimokawa Slides https://speakerdeck.com/_kensh Qiita https://qiita.com/_kensh