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
360
サーバーレス環境における生成AI活用の可能性
2024 にアップデートのあった Lambda SnapStart の紹介、ならびに生成 AI ユースケースへの実際の適用についてポイントを紹介します
S.Akiyama
January 22, 2025
Tweet
Share
Other Decks in Technology
See All in Technology
今からでも間に合う! 生成AI「RAG」再入門 / Re-introduction to RAG in Generative AI
hideakiaoyagi
1
170
vLLM meetup Tokyo
jpishikawa
1
220
型システムを知りたい人のための型検査器作成入門
mame
15
3.8k
生成AIをテストプロセスに活用し"よう"としている話 #jasstnano
makky_tyuyan
0
160
白金鉱業Meetup_Vol.19_PoCはデモで語れ!顧客の本音とインサイトを引き出すソリューション構築
brainpadpr
2
340
(新URLに移行しました)FASTと向き合うことで見えた、大規模アジャイルの難しさと楽しさ
wooootack
0
700
In Praise of "Normal" Engineers (LDX3)
charity
2
880
AWS全冠したので振りかえってみる
tajimon
0
140
Nonaka Sensei
kawaguti
PRO
3
680
VCpp Link and Library - C++ breaktime 2025 Summer
harukasao
0
170
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
38k
ユーザーのプロフィールデータを活用した推薦精度向上の取り組み
yudai00
0
320
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
Scaling GitHub
holman
459
140k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
GraphQLとの向き合い方2022年版
quramy
46
14k
Thoughts on Productivity
jonyablonski
69
4.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The World Runs on Bad Software
bkeepers
PRO
68
11k
How to Think Like a Performance Engineer
csswizardry
24
1.7k
Rails Girls Zürich Keynote
gr2m
94
14k
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