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
300
サーバーレス環境における生成AI活用の可能性
2024 にアップデートのあった Lambda SnapStart の紹介、ならびに生成 AI ユースケースへの実際の適用についてポイントを紹介します
S.Akiyama
January 22, 2025
Tweet
Share
Other Decks in Technology
See All in Technology
AIエージェント元年
shukob
0
150
遷移の高速化 ヤフートップの試行錯誤
narirou
6
1.1k
Snowflakeの開発・運用コストをApache Icebergで効率化しよう!~機能と活用例のご紹介~
sagara
1
400
AI Agent時代なのでAWSのLLMs.txtが欲しい!
watany
2
200
ESXi で仮想化した ARM 環境で LLM を動作させてみるぞ
unnowataru
0
160
ExaDB-XSで利用されているExadata Exascaleについて
oracle4engineer
PRO
3
220
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
8
2.1k
入門 PEAK Threat Hunting @SECCON
odorusatoshi
0
140
Apache Iceberg Case Study in LY Corporation
lycorptech_jp
PRO
0
290
"TEAM"を導入したら最高のエンジニア"Team"を実現できた / Deploying "TEAM" and Building the Best Engineering "Team"
yuj1osm
1
100
Amazon Aurora のバージョンアップ手法について
smt7174
2
130
Potential EM 制度を始めた理由、そして2年後にやめた理由 - EMConf JP 2025
hoyo
2
2.4k
Featured
See All Featured
BBQ
matthewcrist
87
9.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Why Our Code Smells
bkeepers
PRO
336
57k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
570
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
A Tale of Four Properties
chriscoyier
158
23k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Gamification - CAS2011
davidbonilla
80
5.2k
Being A Developer After 40
akosma
89
590k
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