Reserved And Provisioned Concurrency in Serverless

2 min read

In this article, I explained what are reserved and provisioned concurrency and how they differs.

Reserved And Provisioned Concurrency in Serverless

There are many serverless services in AWS, and in this article I am going to explain what reserved concurrency and provisioned concurrency are in serverless, and I will explain these two topics in terms of Lambda functions.

What is Reserved Concurrency

In AWS, we set up Lambda maximum capacity so that Lambda functions can't run concurrently more than the defined capacity.

For example:

There are four functions:

  • Lambda Function A
  • Lambda Function B
  • Lambda Function C
  • Lambda Function D

And the maximum capacity is 400, and you did not set reserved concurrency for any Lambda function.

Now what happens: the first three functions A, B, and C get 400 requests, and in this case all the capacity is occupied. Now requests come to Function D, but there is no capacity, and that's why Function D will not execute and will return an error.

So, to solve this problem we can set reserved concurrency for Lambda Function D. Let's assume 100. Now the rest of the functions can have a maximum unreserved capacity of 300.

So even if they get more than 300 requests, those 100 reserved capacities will remain reserved, and they will not be able to use that reserved capacity. But Function D can use that reserved capacity from 0 to 100. Because 100 is fixed for Function D, and 300 is unreserved, function D can not use more than 100 concurrent requests.

Reserved Concurrency means:

  • Guaranteed Capacity
  • Maximum Limit

What is Provisioned Concurrency

In Lambda functions, execution environments are created per invocation when scaling is needed, and the execution environment takes time to create before the Lambda function executes.

Execution environments have two states: warm and cold. So for the first time when it is created, it comes from the cold state to the warm state, and then the function executes.

You can set Provisioned Concurrency for each function. For example, if a function frequently receives about 10 concurrent requests, then you can set the provisioned concurrency to 10 so that 10 execution environments will always remain warm, and the function will execute faster. Basically, it improves performance.

Conclusion

Reserved Concurrency gives guaranteed capacity, and on the other hand Provisioned Concurrency keeps the execution environment in a warm state.