Articles → AWS → Concurrency In AWS Lambda Function
Concurrency In AWS Lambda Function
What Is Concurrency In Lambda Function?
- Init → In this phase, the execution environment got initialized
- Invoke → In this phase, your lambda function is invoked
Click to Enlarge
Concurrency Request Lifecycle
Click to Enlarge
How To Calculate Concurrency?
Concurrency = Average request per second * Average request duration in seconds
Types Of Concurrencies
- Reserved concurrency → A portion of your account’s concurrency is reserved for a function. All other functions use the available unreserved concurrency.
- Provisioned concurrency → Several pre-initialized environments are allocated to the function
Difference Between The Reserved And Provisioned Concurrency
|Reserved Concurrency||Provisioned Concurrency|
|In reserved concurrency, the allocated execution environments are not initialized. Every time, the lambda function initializes the execution environment and then uses it for function invocation. When the execution environment takes a long time than expected then it is called a Cold Start||In provisioned concurrency, the execution environments are pre-initialized|
|Lambda terminates the environment in case of inactivity||Lambda recycles the environment in the background|
|Function throttled when concurrency limit is reached||The function uses unreserved concurrency (other than the reserved instance) in case the concurrency limit is reached|
|No additional charges||Additional charges are incurred|
- Account level → As mentioned earlier, the concurrency quota at the account level is 1000
- Function level → For all functions, you can reserve the maximum concurrency of 900. Pending 100; units are always reserved for the function that does not explicitly reserve concurrency