AWS Builder Center

Learning Notes: Reserved vs Provisioned Concurrency in AWS Lambda

Study notes on how Lambda concurrency works, what reserved concurrency guarantees and limits, and when provisioned concurrency is worth paying for.

These are my study notes on how AWS Lambda handles concurrency, based on the AWS documentation. I am writing them to check my own understanding, so corrections are welcome.

Concurrency basics

Concurrency is the number of function instances serving requests at the same moment. Each simultaneous request needs its own execution environment, so a traffic spike means more environments, and every new environment pays a cold start. All functions in a Region share an account-level concurrency quota, which can be raised through a quota request.

Reserved concurrency

Reserved concurrency sets aside part of the account quota for one function. It does two things at once:
  • It guarantees that the function can scale up to that number, because other functions cannot consume the reserved portion.
  • It caps the function at that number, so extra requests are throttled.
The cap is the interesting part. It can protect a downstream database from too many simultaneous connections, or stop one busy function from starving the rest. Setting it to 0 effectively stops all invocations. As far as I understand, there is no extra charge for reserved concurrency.

Provisioned concurrency

Provisioned concurrency keeps a chosen number of execution environments initialized and ready, so requests that land on them avoid a cold start. It is configured on a published version or an alias, not on $LATEST, and it is billed for as long as it is enabled, in addition to normal invocation charges. Requests above the provisioned amount are served by on-demand environments and can still cold start.

How I would choose

  • Use reserved concurrency when the goal is protection: isolating a function or limiting load on a dependency.
  • Use provisioned concurrency when the goal is predictable latency, for example a user-facing API where cold starts are noticeable.
  • Use both when a latency-sensitive function also needs a ceiling.

Things to check before enabling either

  • Compare the cost of provisioned concurrency with how often cold starts actually hurt, using the Init Duration shown in the REPORT lines of CloudWatch Logs.
  • Remember that reserved concurrency reduces what is left for every other function in the account.
  • Provisioned concurrency can be scaled on a schedule or by target tracking through Application Auto Scaling, which I still need to try in a test account.

Open questions

How do you decide between paying for provisioned concurrency and simply reducing cold start time with a smaller package or a different runtime? I would like to understand how others weigh that trade-off.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article