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
290
サーバーレス環境における生成AI活用の可能性
2024 にアップデートのあった Lambda SnapStart の紹介、ならびに生成 AI ユースケースへの実際の適用についてポイントを紹介します
S.Akiyama
January 22, 2025
Tweet
Share
Other Decks in Technology
See All in Technology
プロダクトエンジニア 360°フィードバックを実施した話
hacomono
PRO
0
120
Visualize, Visualize, Visualize and rclone
tomoaki0705
9
69k
【Developers Summit 2025】プロダクトエンジニアから学ぶ、 ユーザーにより高い価値を届ける技術
niwatakeru
2
1.6k
依存パッケージの更新はコツコツが勝つコツ! / phpcon_nagoya2025
blue_goheimochi
3
180
全文検索+セマンティックランカー+LLMの自然文検索サ−ビスで得られた知見
segavvy
2
130
偏光画像処理ライブラリを作った話
elerac
1
130
JEDAI Meetup! Databricks AI/BI概要
databricksjapan
0
280
短縮URLをお手軽に導入しよう
nakasho
0
110
【詳説】コンテンツ配信 システムの複数機能 基盤への拡張
hatena
0
120
プロダクトエンジニア構想を立ち上げ、プロダクト志向な組織への成長を続けている話 / grow into a product-oriented organization
hiro_torii
1
300
エンジニアが加速させるプロダクトディスカバリー 〜最速で価値ある機能を見つける方法〜 / product discovery accelerated by engineers
rince
4
490
NFV基盤のOpenStack更新 ~9世代バージョンアップへの挑戦~
vtj
0
280
Featured
See All Featured
How GitHub (no longer) Works
holman
314
140k
It's Worth the Effort
3n
184
28k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Bash Introduction
62gerente
611
210k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Side Projects
sachag
452
42k
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