Hi, everyone, and welcome back.
Now, in today's video, we are going to discuss about the reserved and the provision concurrency.
Now, at this stage, one important part to remember is that the default concurrency limit per region
is 1000 invocation at a given time.
So this is something that is configurable.
However, note that depending upon the account, this might not always be the case, so the default
concurrency limit might be much more lesser and you will be able to raise it through the service quotas.
So at this stage, let's assume that you have a concurrency limit of 1000 invocation.
So this would mean that the functions share this pool of 1000 concurrency on an on demand basis.
So let's assume that there are ten functions.
So ten functions cannot use 1000 invocation each.
So this 1000 invocation is shared between all of those ten functions in a way that they will be able
to use maximum of 1000 invocation at any given time.
And post this, your function can experience throttling.
That is it starts to drop the request if you run out of the available concurrency in the region.
Now, in fact, before we proceed further, let's also look into the overall limits.
So in the service quota service, if you go to Lambda.
Within a year, you have a concurrent execution.
And at this stage you see that the applied quota value is 1000.
So this is the applied value after I had raised the limit.
So if you see, I had raised the limit of concurrent execution to 1000, and after this has been increased,
I get the 1000 concurrent invocations.
So this is at a regional level.
For example, let's switch from Singapore region to Mumbai region.
And if you look into the concurrent execution limit, it is just ten.
The US default quota value is 1000.
So you will be able to go ahead and raise this specific limit from 10 to 1000 in case if you'd like,
so you can request for the quota increase.
So you can say I need 1000 and you can request your.
And this request is currently pending.
And at a later stage, after verification, the team will go ahead and increase the specific quarter
limit.
Now, from a practical point of view, one important part to remember is that some of your functions
might always be more critical than others.
And this is the reason why it is important that you configure the concurrency setting to ensure that
critical functions get the concurrency that they need.
For example, let's assume that there are three Lambda functions in a specific region.
You have a lambda function, you have the key and you have the broad lambda function.
Now, at this stage we can understand that the broad lambda function would be the most critical among
all of this.
Now let's assume that the lambda function is using the concurrency of 200.
The lambda function is using the concurrency of 600.
So there are a lot of requests that are going to the dev and the lambda function.
So based on this, only 200 concurrency is left for the production lambda function and this can create
a lot of issues for you.
So what you want is that for a critical set of Lambda functions, you want to reserve certain set of
concurrency settings so that they can always utilize that.
Let's assume that the broad lambda functions always require the concurrency of 500 to be available for
it.
Now, in a region where you have the concurrency limit of 1000 and other Lambda functions are also taking
a certain amount of concurrency.
This can create the issue for the broad lambda function, and this is where you can reserve the concurrency
for a lambda.
Now, when we discuss about the overall concurrency controls, there are two types.
One is the reserved concurrency and second one is the provisioned concurrency.
Reserved concurrency.
It reserves a portion of your account's concurrency for a function.
So for a broad lambda function, we can reserve 500 concurrency.
So those 500 will always be available for broad lambda function.
So this reserve concurrency is useful if you don't want other functions taking up the available and
reserved concurrency in a similar way, you have the provision concurrency.
The benefit here is that it pre initializes the number of environment instances for a function and it
is useful for reducing the cold start latencies.
So let's go ahead and understand both of them in more detail.
The first one is the reserved concurrency.
So if you want to guarantee that a certain amount of concurrency is always available for your critical
functions, you can make use of the reserved concurrency.
Now, one important point to note here is that when you dedicate a reserved concurrency to a specific
lambda function, no other function can use that concurrency.
This is quite important.
So let's also look into it from the diagrammatic perspective.
So you see you have a concurrency of 1000.
Now for the function of orange, you have reserved 400 for the function of blue, you have reserved
400.
So total of 800 concurrency is resolved between two functions.
Now you only have one reserved of 200.
So all of the other functions that are part of the region will have to use only 200 after this request
will start to throttle for those functions.
However, for blue and orange, you always have this reserved capacity in place.
Now, with this base set on reserved concurrency, let's look into the challenges that you might face
with this.
So one important part, which is a base prerequisite learning, is that we know that we use the reserve
concurrency to define the maximum number of execution environments reserved for Lambda function.
Now, at this stage we have already discussed about the execution environments in the Lambda concurrency
video.
Now, although these set of execution environments are always reserved, but these are not pre initialized
and this is the reason why your function invocation may take long time because Lambda must first initialize
the new environment before it can invoke your function.
And when the initialization is taking longer than expected, this is known as a cold start and to mitigate
the cold start you make use of the provision concurrency.
So at a high level overview provision, concurrency is the number of pre initialized execution environments
that you want to allocate to your function.
So if you set the provision concurrency on function, Lambda initializes the execution environment and
keeps it ready, and these execution environments can respond immediately to the request that are being
received.
So if we look into it from the diagrammatic perspective, you have reserved concurrency, you have the
provision concurrency.
Now in the reserved concurrency, you will see that once the request number one is received, then you
have the initialization stage and then the invoke stage that takes place.
So this initialization stage can also take a little amount of time.
However, when we discuss about the provision concurrency, the initialization of the environment is
already done.
And when the.
A request comes, it can directly be invoked.
No need of the initialization to take place.
And this is the reason why the provision concurrency allows a much more faster response times as well.
So let's do one thing.
Let's go ahead and look into where can we set the reserved and the provision concurrency.
Now for today's demo, I have a sample lambda function that is available.
Now.
If you look into the overall configuration under the concurrency, you have a specific and reserved
account concurrency of 930 that is left now for this specific function.
There is no reserved concurrency that is available.
However, if you want to set a reserved concurrency, you can select the reserved concurrency here.
Let's set a specific, reserved concurrency.
You see, the more the number of reserved concurrency that you add, the less the unreserved concurrency
becomes.
So for example, at this stage, if you set the reserve, concurrency of 30, other functions will have
to utilize the concurrency, which is 900.
So they'll have to share this or they can reserve it for themselves as well.
So let's set the reserve concurrency here.
At this stage you have the reserve concurrency of 30.
Apart from that, as we're discussing, you can also set up provision concurrency where the number of
pre initialized environments would be ready.
So let's quickly look into it.
So when you add a provision concurrency.
Within year.
You can associate it with either an alias or the version.
So two types are available and within.
You can specify the provision concurrency.
Again, note that the provision concurrency, since the number of environments are already pre initialized
for you, you will have to pay for the provision concurrency.
Now, if we look from a practical point of view, in a real world scenario, you could use the provision
concurrency to set the baseline amount of environments to handle the request during weekdays and use
the reserved concurrency to handle the weekend spikes.
For example, if you look into this diagram for a lambda function orange, here you have a provision
concurrency of 200 and then you have the reserved concurrency of 400 for weekends in case more requests
come and out of 1000, the other 600 concurrency goes to the other set of functions.
So you can use together both the provision and reserved concurrency to achieve your use case.
Now, before we conclude, I have also added a comparison chart between the reserved and the provision,
concurrency and the benefits and the appropriate points to note.
Again, here the important part is the pricing reserve concurrency.
You don't have to pay any additional charge for the provision concurrency.
You do have to pay the available charges based on the number that you define.
So that's the high level overview.
And with this will conclude today's video.