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

2025年8月から始まるAWS Lambda INITフェーズ課金/AWS Lambda IN...

Avatar for quiver quiver
May 09, 2025

2025年8月から始まるAWS Lambda INITフェーズ課金/AWS Lambda INIT phase billing changes

.zipファイルアーカイブのAWS Lambda関数をオンデマンド実行する場合、2025年8月からINITフェーズの時間も課金されるようになります。

解説ブログ

https://dev.classmethod.jp/articles/aws-lambda-zip-ondemand-init-billing-change/

AWS公式案内

https://aws.amazon.com/blogs/compute/aws-lambda-standardizes-billing-for-init-phase/

登壇イベント

Serverless Meetup Fukuoka #5
https://serverless.connpass.com/event/348712/

Avatar for quiver

quiver

May 09, 2025
Tweet

More Decks by quiver

Other Decks in Technology

Transcript

  1. ⾃⼰紹介 2 • 名前 ◦ George Yoshida • ブログ ◦

    https://dev.classmethod.jp/author/quiver/ • 部署 ◦ クラスメソッド福岡オフィス ソリューションアーキテクト • AWS Community Builder 2025 : Serverless https://dev.classmethod.jp/articles/aws-lambda-zip-ondemand-init-billing-change/
  2. 2025年8⽉からのZipオンデマンド実⾏の課⾦仕様変更 5 • 前提 ◦ Lambdaの実⾏はメモリスペックx時間で課⾦される(GB-Second) ※ • 変更内容 ◦

    Lambda関数の初期化(INITフェーズ)時間も課⾦対象となる • 影響を調査 ◦ プロダクション環境のINITは1%未満(AWS談)で影響は軽微なはず ◦ CloudWatch Logs InsightsクエリでLambdaのログから念のため調査 • 改善策 ◦ コールドスタート対策と同様 ※ リクエスト数などでも課⾦されます
  3. CloudWatch Logsのログ出⼒から新旧課⾦仕様を計算 11 Billed Duration =切り上げ(Duration) REPORT RequestId: xxxxx Duration:

    250.06 ms Billed Duration: 251 ms Memory Size: 1024 MB Max Memory Used: 350 MB Init Duration: 100.77 ms Billed Duration = 切り上げ(Init Duration + Duration) REPORT RequestId: xxxxx Duration: 250.06 ms Billed Duration: 351 ms Memory Size: 1024 MB Max Memory Used: 350 MB Init Duration: 100.77 ms 現在の仕様 新しい仕様
  4. CloudWatch Logs Insightsクエリ:INITフェーズ発⽣率 13 INITフェーズの発生率(Ratio)を次のクエリで確認 filter @type = "REPORT" |

    stats count(*) as totalInvocation, count(@initDuration) as coldInvocation, coldInvocation/totalInvocation as Ratio • totalInvocation : 呼び出された回数 • coldInvocation : INITフェーズが発⽣した回数 • Ratio : INITフェーズの発⽣率(0.0〜1.0)
  5. CloudWatch Logs Insightsクエリ:利⽤費の増加率 14 可変な呼び出し時のメモリサイズを考慮してGB-secondを計算 filter @type = "REPORT" |

    stats sum((@memorySize/1000000/1024) * (@billedDuration/1000)) as oldBilledGBs, sum((@memorySize/1000000/1024) * (@initDuration/1000)) as newBilledGBs, (oldBilledGBs + newBilledGBs)/oldBilledGBs as billedRatio • oldBilledGBs : 旧仕様で課⾦されるINVOKEフェーズだけの GB-second • newBilledGBs : 新仕様で課⾦されるINITフェーズだけのGB-second • billedRatio : 新仕様での課⾦額増加率
  6. CloudWatch Logs Insightsクエリ:1クエリにまとめる 15 INITの発生率と新旧の金額の違いを1クエリにまとめる filter @type = "REPORT" |

    stats sum((@memorySize/1000000/1024) * (@billedDuration/1000)) as oldBilledGBs, sum((@memorySize/1000000/1024) * (@initDuration/1000)) as newBilledGBs, (oldBilledGBs + newBilledGBs)/oldBilledGBs as billedRatio, count(*) as totalInvocation, count(@initDuration) as coldInvocation, coldInvocation/totalInvocation as Ratio
  7. 2025年8⽉からのZipオンデマンド実⾏の課⾦仕様変更 19 • 前提 ◦ Lambdaの実⾏はメモリスペックx時間で課⾦ • 変更内容 ◦ Lambda関数の初期化時間も課⾦対象

    • 影響を調査 ◦ 多くの環境で初期化の発⽣率は低く、AWS利 ⽤費全体へのインパクトは軽微なはず ◦ CloudWatch Logs Insightsで念のため調査 • 改善策 ◦ コールドスタート対策を参考にする 解説ブログ https://dev.classmethod.jp/articles/aws-lambda-zip-ondemand-init-billing-change/