1
00:00:00,420 --> 00:00:06,840
In this video, we are going to learn a lot the execution environment and lambda lifecycle.

2
00:00:07,740 --> 00:00:10,140
One least lambda invokes our function.

3
00:00:10,140 --> 00:00:13,890
It creates an execution environment in order to isolate it.

4
00:00:13,890 --> 00:00:15,210
Runtime environment.

5
00:00:15,750 --> 00:00:20,430
The execution environment provides the required resources for running our function.

6
00:00:20,430 --> 00:00:26,730
The execution environment also provides lifecycle support for the functions, runtime and any external

7
00:00:26,730 --> 00:00:29,280
extensions associated with our function.

8
00:00:29,940 --> 00:00:35,160
You can find the image in the slide, which is an example invocation to lambda function and see how

9
00:00:35,160 --> 00:00:38,230
execution environment created and managed by the ADA is.

10
00:00:39,320 --> 00:00:43,670
Basically the function communicates with lambda runtime using the runtime API.

11
00:00:43,970 --> 00:00:50,480
Extensions communicate with Lambda using the extensions API and extensions can also receive log messages

12
00:00:50,480 --> 00:00:58,430
from the function by subscribing to logs using the logs API before lambda creates execution environments,

13
00:00:58,430 --> 00:01:04,790
it is looking to lambda configurations like amount of memory, CPU usage and maximum execution time

14
00:01:04,790 --> 00:01:05,570
settings.

15
00:01:05,900 --> 00:01:11,030
According to these settings and configurations, lambda creates an execution environment.

16
00:01:12,570 --> 00:01:13,740
So Lambda.

17
00:01:13,980 --> 00:01:19,800
If you locate the lambda execution movement lifecycle, there are several phases when Lambda Invocation

18
00:01:19,800 --> 00:01:20,560
performs.

19
00:01:20,580 --> 00:01:22,200
You can find the image in the slide.

20
00:01:22,230 --> 00:01:30,210
There are three main phases which are init invoke and shutdown process in the init phase.

21
00:01:30,240 --> 00:01:32,320
Lambda performs three tasks.

22
00:01:32,340 --> 00:01:38,340
Start all extensions, bootstrap the runtime and run the function static code.

23
00:01:38,610 --> 00:01:44,340
The init phase ends when the runtime and all extensions are ready by sending a next API request.

24
00:01:44,670 --> 00:01:47,010
The interface is limited to ten second.

25
00:01:47,040 --> 00:01:51,390
If all three tasks don't complete within the three second ten second.

26
00:01:51,630 --> 00:01:58,560
Lambda retries the init phase at the time of the first function invocation and the second phase is invoke

27
00:01:58,560 --> 00:01:59,190
phase.

28
00:01:59,580 --> 00:02:04,930
In this phase, Lambda invokes the function handler after the function runs to completion.

29
00:02:04,950 --> 00:02:07,800
Lambda prepares to handle another function invocation.

30
00:02:08,220 --> 00:02:12,370
The functions timeout setting limits the duration of the entire invoke phase.

31
00:02:12,390 --> 00:02:18,600
For example, if you set the function timeout as 5 minutes, the function and all extensions need to

32
00:02:18,600 --> 00:02:20,160
complete within the five minute.

33
00:02:20,940 --> 00:02:21,750
119.

34
00:02:21,750 --> 00:02:23,010
The function is invoked.

35
00:02:23,040 --> 00:02:28,140
After that, it goes to the next API request in order to invoke another function execution.

36
00:02:29,080 --> 00:02:31,390
And the last phase is the shutdown phase.

37
00:02:31,570 --> 00:02:38,080
In this phase is triggered if lambda function doesn't receive any invocation for a period of time in

38
00:02:38,080 --> 00:02:44,950
the shutdown phase, lambda down the runtime and that's the extension to let them stop cleanly and then

39
00:02:44,950 --> 00:02:46,810
removes the entire environment.

40
00:02:46,840 --> 00:02:51,700
Lambda sends a shutdown event to each extension, which tells the extension that the environment is

41
00:02:51,700 --> 00:02:52,870
about to shutdown.

42
00:02:53,500 --> 00:02:59,680
As you can see that we have understand the lambda execution environment and how Lambda Lifecycle works.
