0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Lambda の「予約済み同時実行」と「プロビジョニング済み同時実行」の使い分け

0
Last updated at Posted at 2026-03-29

Lambda の「予約済み同時実行」と「プロビジョニング済み同時実行」

AWS DVAを学習しているとよく出てくるので、
自分の中で腹落ちさせるためにまとめてみました。
本記事は初学者向けとなります。

前提

Lambda はリージョンごとにデフォルトで同時実行数の上限が 1,000 です。アカウント内の全関数がこのプールを共有しているので、何も設定しないとある関数がプールを食い潰して別の関数がスロットリング…ということが起きます。

予約済み同時実行(Reserved Concurrency)

同時実行の「枠」を確保する設定です。追加料金なし。

設定した数がその関数の上限かつ保証枠になります。他の関数からはその枠を使えなくなるし、逆にその数を超えてスケールすることもできません。

用途としては、重要な関数の枠確保や、DB のコネクション上限に合わせてスケールを制限したいときなどに使います。

aws lambda put-function-concurrency \
  --function-name order-api \
  --reserved-concurrent-executions 50

CloudFormation では ReservedConcurrentExecutions で設定します。

OrderApiFunction:
  Type: AWS::Lambda::Function
  Properties:
    FunctionName: order-api
    Runtime: nodejs20.x
    Handler: index.handler
    Role: !GetAtt LambdaRole.Arn
    Code:
      S3Bucket: my-bucket
      S3Key: function.zip
    ReservedConcurrentExecutions: 50

プロビジョニング済み同時実行(Provisioned Concurrency)

実行環境を事前に起動しておく設定です。追加料金あり。

指定した数のコンテナが初期化済みで待機するので、コールドスタートが発生しません。設定数を超えたリクエストは通常どおりオンデマンドでスケールします(その分はコールドスタートあり)。

$LATEST には設定できず、バージョンまたはエイリアスに対して設定する点に注意してください。

aws lambda put-provisioned-concurrency-config \
  --function-name order-api \
  --qualifier live \
  --provisioned-concurrent-executions 20

CloudFormation ではエイリアスの ProvisionedConcurrencyConfig で設定します。

OrderApiAlias:
  Type: AWS::Lambda::Alias
  Properties:
    FunctionName: !Ref OrderApiFunction
    FunctionVersion: !GetAtt OrderApiVersion.Version
    Name: live
    ProvisionedConcurrencyConfig:
      ProvisionedConcurrentExecutions: 20

違い

予約済み プロビジョニング済み
目的 枠の確保 & スケール上限 コールドスタート回避
追加料金 なし あり
スケール上限になるか
コールドスタート対策
設定対象 関数 バージョン / エイリアス

併用

実運用では両方設定するのが手堅いです。

# 枠を 100 確保
aws lambda put-function-concurrency \
  --function-name order-api \
  --reserved-concurrent-executions 100

# そのうち 30 を事前起動
aws lambda put-provisioned-concurrency-config \
  --function-name order-api \
  --qualifier live \
  --provisioned-concurrent-executions 30

この場合、リクエスト 1〜30 はプロビジョニング済み環境が即応し、31〜100 はオンデマンドでスケール(コールドスタートあり)、101 以降はスロットリングになります。

まとめ

  • 予約済み同時実行 → 枠を確保する。スケール上限にもなる。無料。
  • プロビジョニング済み同時実行 → コールドスタートをなくす。有料。
  • 片方だけでは片手落ちになりがちなので、本番では併用がおすすめ。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?