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
サーバーレス環境における生成AI活用の可能性
Search
S.Akiyama
January 22, 2025
Technology
3
340
サーバーレス環境における生成AI活用の可能性
2024 にアップデートのあった Lambda SnapStart の紹介、ならびに生成 AI ユースケースへの実際の適用についてポイントを紹介します
S.Akiyama
January 22, 2025
Tweet
Share
Other Decks in Technology
See All in Technology
LLMの開発と社会実装の今と未来 / AI Builders' Community (ABC) vol.2
pfn
PRO
2
220
VitePress & MCPでアプリ仕様のオープン化に挑戦する
hal_spidernight
0
130
encoding/json v2を予習しよう!
yuyu_hf
PRO
1
220
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
150
スイッチのBMC、つかってますか?
sonic
0
380
木を見て森も見る-モジュールが織りなすプロダクトの森
kworkdev
PRO
0
270
Terraform にコントリビュートしていたら Azure のコストをやらかした話 / How I Messed Up Azure Costs While Contributing to Terraform
nnstt1
1
570
Azure × MCP 入門
ry0y4n
8
2k
既存の開発資産を活かしながら、 《新規開発コスト抑制》と《開発体験向上》 を両立する拡張アーキテクチャ事例
kubell_hr
0
270
正解のない未知(インボイス制度対応)をフルサイクル開発で乗り越える方法 / How to overcome the unknown invoice system with full cycle development
carta_engineering
0
160
Vibe Coding Tools
ijin
1
290
ユーザーコミュニティが海外スタートアップのDevRelを補完する瞬間
nagauta
1
200
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Thoughts on Productivity
jonyablonski
69
4.6k
How GitHub (no longer) Works
holman
314
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
The Cost Of JavaScript in 2023
addyosmani
49
7.8k
How to Ace a Technical Interview
jacobian
276
23k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
720
Music & Morning Musume
bryan
47
6.5k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
The Cult of Friendly URLs
andyhume
78
6.4k
Transcript
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. サーバーレス環境における ⽣成AI活⽤の可能性 秋⼭ 周平 (Shuhei Akiyama) Solutions Architect 2024/01/22 Serverless Meetup Tokyo #20 1
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. ⾃⼰紹介 Shuhei Akiyama Amazon Web Services Japan Solutions Architect ゲーム業界のお客様を中⼼にご⽀援しています 以前は AWS Support に所属していました 思い⼊れのある AWS サービスや OSS (AWS Lambda はこれから…!) Amazon GameLift Amazon Cognito Cloudscape Design System 2
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. アジェンダ 1. AWS Lambda SnapStart 概要 2. ⽣成AIユースケースに対する AWS Lambda SnapStart の活⽤例 1. ⽣成AI ユースケースと課題の説明 2. AWS Lambda SnapStart を適⽤した効果の紹介 3
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda SnapStart 概要 4
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda SnapStart の概要 5 通常の Lambda 関数の起動 関数の実⾏ 初期化フェーズ 呼び出し フェーズ 関数の実⾏ (実⾏環境の再利⽤) 呼び出し フェーズ 初期化フェーズ 呼び出し フェーズ 呼び出し フェーズ 最⼤10秒 AWS re:Invent 2022 - AWS Lambda SnapStart: Fast cold starts for your Java functions (SVS320) https://www.youtube.com/watch?v=ZbnAithBNYY
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda SnapStart の概要 6 初期化フェーズ Snapshot 保存 関数のバージョン発⾏ 関数の実⾏ リストア 呼び出し フェーズ 関数の実⾏ (実⾏環境の再利⽤) 呼び出し フェーズ リストア 呼び出し フェーズ 呼び出し フェーズ 通常の Lambda 関数の起動 関数の実⾏ 初期化フェーズ 呼び出し フェーズ 関数の実⾏ (実⾏環境の再利⽤) 呼び出し フェーズ 初期化フェーズ 呼び出し フェーズ 呼び出し フェーズ SnapStart 活⽤時のフロー 最⼤10秒 最⼤900秒
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda SnapStart で追加で発⽣するコスト 7 • Snapshot 保持期間 (GB-秒) § Snapshot サイズに依存 • リストアした Snapshot サイズの合計 (GB ~ リストアを利⽤する回数) § 起動回数と起動に対するリストアの割合に依存
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda SnapStart が Python および .NET に対応 (2024 update) • ユースケース § Python において依存関係のロードやフレームワークの使⽤に時間がかかる場合 § .NET や Java など実⾏環境の準備に時間がかかる場合 8 ランタイムごとの ColdStart にかかる時間についての参考情報 (AWS re:Invent 2023 で紹介) https://maxday.github.io/lambda-perf/ https://www.youtube.com/watch?v=bGMEPI-va-Q
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. ⽣成AIユースケースに対する AWS Lambda SnapStart の活⽤例 9
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. FAISS (Facebook AI Similarity Search) Vector Engine OSS ⼀般的な RAG 構成 • ⾼機能(⾼可⽤性、⾼耐久性、⾼スケーラビリティ) • 最⼩料⾦が⾼め Serverless RAG • 限定された機能 • 最⼩料⾦が低く費⽤はほぼ使⽤量に⽐例 10 現 在 S ER VER L ES S R AG と い う ソ リ ュ ー シ ョ ン を 開 発 し て い ま す (公 開 準 備 中 ) ⽣成 AI ユースケースの紹介 Amazon S3 Vector Data (file) User Amazon Bedrock 常駐する 外部 DB Amazon Aurora Amazon Kendra Amazon OpenSearch Lambda Function 検索 プロンプト拡張 回答⽣成 User Amazon Bedrock Lambda Function 検索 プロンプト拡張 回答⽣成
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. ⽣成 AI ユースケースの紹介 11 質問/応答 User ベクトル データ取得 RAG 関数 回答⽣成 実⾏環境⽣成 初期化フェーズ S3 から /tmp へ ベクトルデータの ダウンロード /tmp からメモリへ のベクトルデータの ロード Faiss ライブラリ のロード 呼び出しフェーズ メモリ上ベクトル 空間に対する ベクトル検索 検索結果を使い Bedrock で質問に対 する回答を⽣成
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. ⽣成 AI ユースケースの紹介 12 質問/応答 User ベクトル データ取得 RAG 関数 回答⽣成 実⾏環境⽣成 初期化フェーズ S3 から /tmp へ ベクトルデータの ダウンロード /tmp からメモリへ のベクトルデータの ロード Faiss ライブラリ のロード 呼び出しフェーズ メモリ上ベクトル 空間に対する ベクトル検索 検索結果を使い Bedrock で質問に対 する回答を⽣成 Cold Start 時間が⻑い (4 ~ 10 sec) 検索と外部 API 呼び出しのみ SnapStart との相性が良いと予想
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda SnapStart の有効化に伴う実作業 Lambda Container からの移⾏ 現在 Lambda Container に対応し ていないため、移⾏にあたって Layer を作成 Lambda Layer サイズクォータの回避 Gen-AI 関連の Python ライブラリ は組み合わせると Layer サイズの 上限に抵触する可能性がある 効果測定 の難しさ Duration CloudWatch Metrics は Cold Start 時間を含まない ColdStart を意図的に起こす⼯夫 (Appendix) 13 SnapStart の有効化 は Config を有効化しバージョンを発⾏するだけ https://aws.amazon.com/jp/blogs/news/aws-lambda-snapstart-for-python-and-net-functions-is-now- generally-available/ > Python 関数の場合、 ~ 依存関係のロード (LangChain、Numpy、Pandas、DuckDB など) やフレームワーク の使⽤ (Flask や Django など) が含まれます。
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Demo 14
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Demo 16
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. 性能評価 – Vectorサイズと ColdStart の関係 17 Vector 数 (百万) Init Duration Duration 293 8147.1864 3402.666 117 5913.4612 2751.9588 80 5643.5648 2585.2688 32 4681.4212 2795.372 20 4550.5572 3388.9044 4.5 4322.1192 2457.5632 0 2000 4000 6000 8000 10000 0 50 100 150 200 250 300 350 時間(秒) ベクトル数(百万) 初期化フェーズ(SnapStart 無効) リストア(SnapStart 有効) Vector 数 (百万) Restore Duration Duration 293 1210.6816 3522.088 117 940.8468 2801.1768 80 1019.6988 3315.0096 32 785.336 2958.0572 20 739.2616 3879.9724 4.5 726.58843 2839.4548 SnapStart なし SnapStart 有効化
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. 性能評価 – Vectorサイズと関数全体の実⾏時間の関係 18 0 5000 10000 15000 50 100 150 200 250 300 350 時間(秒) ベクトル数(百万) SnapStart 無効 SnapStart有効 SnapStart なし SnapStart 有効化 Vector 数 (百万) Init Duration Duration 293 8147.1864 3402.666 117 5913.4612 2751.9588 80 5643.5648 2585.2688 32 4681.4212 2795.372 20 4550.5572 3388.9044 4.5 4322.1192 2457.5632 Vector 数 (百万) Restore Duration Duration 293 1210.6816 3522.088 117 940.8468 2801.1768 80 1019.6988 3315.0096 32 785.336 2958.0572 20 739.2616 3879.9724 4.5 726.58843 2839.4548
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. コスト評価 19 Lambda (2GB RAM) Costs (USD) 3 sec / invoke 0.0001 / invoke 30,000 requests 3 / month Bedrock Costs (USD) 400 Input tokens 0.0001 / invoke 200 Output tokens 0.00025 / invoke 30,000 requests 10.5 / month Lambda SnapStart Costs (USD) Cache (※1) 8.05 / month Restore (10%) 0.83 USD / month ⽉当たり合計リクエスト量 30000 requests / month 20 User RAG 50 times per day ※1. ただし、「スナップショットのキャッシュ」は GB~秒単位の課⾦のため、関数バージョン1つであれば、 最⼤でも 40 USD / monthであることに留意。⼀⽅ Restore はアクセス頻度に⼤きく左右される点に注意 ColdStart / Restore 発⽣分(10%) 3000 requests / month
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Thank you! 20
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Appendix:性能評価の様⼦ 21 Amazon S3 output bucket Amazon CloudWatch Logs Insights Lambda function Logs Lambda function Logs Lambda function Logs Lambda function Logs
© 2025, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Appendix:性能評価の様⼦ 22