Articles → AWS → Concurrency In AWS Lambda Function

Concurrency In AWS Lambda Function

What Is Concurrency In Lambda Function?

Execution Environment

  1. Init → In this phase, the execution environment got initialized
  2. Invoke → In this phase, your lambda function is invoked
Picture showing the different phases of the execution environment

Click to Enlarge

Concurrency Request Lifecycle

Picture showing the concurrency request life-cycle

Click to Enlarge

How To Calculate Concurrency?

Concurrency = Average request per second * Average request duration in seconds

Types Of Concurrencies

  1. Reserved concurrency → A portion of your account’s concurrency is reserved for a function. All other functions use the available unreserved concurrency.
  2. Provisioned concurrency → Several pre-initialized environments are allocated to the function

Difference Between The Reserved And Provisioned Concurrency

Reserved ConcurrencyProvisioned 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 StartIn provisioned concurrency, the execution environments are pre-initialized
Lambda terminates the environment in case of inactivityLambda recycles the environment in the background
Function throttled when concurrency limit is reachedThe function uses unreserved concurrency (other than the reserved instance) in case the concurrency limit is reached
No additional chargesAdditional charges are incurred

Concurrency Quotas

  1. Account level → As mentioned earlier, the concurrency quota at the account level is 1000
  2. 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

Posted By  -  Karan Gupta
Posted On  -  Thursday, January 26, 2023


Your Email Id  
Query/FeedbackCharacters remaining 250