I understand that Lambda is serverless and it will create an Execution Environment (MicroVMs) on event invocations.
So, when an event is invoked, Lambda will spin up an execution environment that will have selected programming language runtime inside it.
So far, it is clear that these Execution Environments (MicroVMs) are created on demand, and terminated if found idle for long.
Now, original question comes.
My understanding is that, Lambda have a Runtime API. So, whenever we create a Lambda resource in AWS, it can be accessed by Lambda Runtime API. And these API end-points are invoked by Event Sources such as SQS, SNS, etc.
My question is that, is there any compute that run all the time, just to host these Lambda Runtime APIs. And if it is there, why there is not much detail about that, and why are not we charged for that?
Please correct my understanding here.
CodePudding user response:
In a very simplified explanation, Lambda should be considered as a service with two components:
- Data Plane: EC2 instances where the functions are executed.
- Control Plane: Service that contains all the metadata related to each Lambda deployed, including event mapping.
When an event occurs, it will be processed by the control plane. The control plane will validate the security and check if there is an available copy of the function already instantiated.
If one is available, it will forward the event to the Lambda and pass instructions to send back the result. If there is no function available the control plane will download the function code, together with its runtime, instantiate a new function in the data plane and forward the event.
At all times, there will be control plane and data plane machines online. The AWS Lambda service will increase or decrease the number of each based on usage.