1
00:00:00,300 --> 00:00:06,300
In this video, we are going to learn a lot of the best practices and event driven architectures.

2
00:00:07,080 --> 00:00:12,180
So we will follow the design principles and the best practices when developing our lambda based, event

3
00:00:12,200 --> 00:00:13,980
driven serverless applications.

4
00:00:14,040 --> 00:00:19,920
Lambda is very good fit when we are working with the event driven architectures because the nature of

5
00:00:19,920 --> 00:00:22,650
the Lambda executions trigger from events.

6
00:00:23,010 --> 00:00:26,730
Events can come lots of resources and able to trigger lambda functions.

7
00:00:27,270 --> 00:00:33,420
So lambda is a complete service that runs custom function code and return response to the events.

8
00:00:33,750 --> 00:00:40,710
Most services generate events for communicating each other, and most of the services are event sources

9
00:00:40,710 --> 00:00:42,090
for a lambda.

10
00:00:42,990 --> 00:00:49,560
LAMDA always handle all interactions with the Lambda API and there is no direct invocation of functions

11
00:00:49,560 --> 00:00:51,390
from outside to the service.

12
00:00:51,570 --> 00:00:56,760
We can see the image on the slide Lambda Handle event with the Lambda API.

13
00:00:56,790 --> 00:01:02,970
The main purpose of lambda function is to handle events when a function is triggered by an event.

14
00:01:03,000 --> 00:01:04,720
This is called an invocation.

15
00:01:04,740 --> 00:01:10,920
Lambda function are limited to 15 minutes in duration, but on average most of the calls take less than

16
00:01:10,920 --> 00:01:16,260
a second across all the customers in some compute incentive operations.

17
00:01:16,260 --> 00:01:21,660
It may take several minutes to process a single event, but in most cases, the time is short.

18
00:01:22,840 --> 00:01:26,050
And even triggering a lambda function could be almost anything.

19
00:01:26,260 --> 00:01:29,590
You can see the image on the slide from the rest API.

20
00:01:29,620 --> 00:01:35,330
A HTTP request with Amazon API Gateway as scheduled task managed by the Amazon Event Breach Cloud Watch

21
00:01:35,380 --> 00:01:40,390
Logs Rule or an Amazon S3 notification like object uploaded into the bucket.

22
00:01:40,480 --> 00:01:44,500
Even the simplest lambda based application used at least one event.

23
00:01:44,500 --> 00:01:50,860
So that's why we said lambda is very good fit for the event driven architectures because the fuel of

24
00:01:50,860 --> 00:01:52,840
the lambda is immense.

25
00:01:54,660 --> 00:01:59,280
So the event is a JSON object that contains all information about what happened.

26
00:01:59,280 --> 00:02:03,990
Events are represents a change in the system state they are immutable.

27
00:02:04,020 --> 00:02:09,780
You can see the example event json to trigger a lambda function in the image of the slide.

28
00:02:09,810 --> 00:02:17,070
The first parameter of every lambda handed function contains the event JSON object so you can find the

29
00:02:17,070 --> 00:02:21,660
example event JSON object that triggered the lambda function and you can see the function image that

30
00:02:21,660 --> 00:02:24,690
takes event parameter into lambda handle method.

31
00:02:24,690 --> 00:02:29,880
So at that stage, the event parameter is very important when developing our lambda function.

32
00:02:29,880 --> 00:02:34,850
If you look at the Lambda Handle method, you will see that the first parameter is event into lambda

33
00:02:34,860 --> 00:02:35,700
handle method.

34
00:02:35,700 --> 00:02:42,780
So with using this event JSON object, we can access the event parameters into lambda function.

35
00:02:42,780 --> 00:02:46,440
For example, let's look at this slide image we have.

36
00:02:46,440 --> 00:02:49,350
We have a naive order event triggers to lambda function.

37
00:02:49,350 --> 00:02:55,260
So if I would like to get the order that details attribute value into lambda function, basically I

38
00:02:55,260 --> 00:03:00,900
can take the information with the event that source or event that detail into my Lambda 100 function

39
00:03:00,900 --> 00:03:06,180
because lambda triggered this event json object with passing parameters in the handle method.

40
00:03:07,550 --> 00:03:12,890
So an event could be custom generated from other microservices such as the Neve or the generated in

41
00:03:12,890 --> 00:03:14,490
an e-commerce application.

42
00:03:14,510 --> 00:03:19,010
We will have exactly the same use case into our serverless e-commerce application.

43
00:03:19,070 --> 00:03:26,000
The event also can be generated from the existing sources like Amazon in case when a new message is

44
00:03:26,000 --> 00:03:32,600
available in the queue, it can go to Lambda with pulling queue records from the Amazon queue.

45
00:03:33,410 --> 00:03:39,560
So even event architectures rely on the creating event into all the application state chains that are

46
00:03:39,560 --> 00:03:41,480
observable by other services.

47
00:03:41,480 --> 00:03:46,550
But the event publisher system is unaware of which consumers are subscribing that event.

48
00:03:46,580 --> 00:03:50,150
We call that there are loosely coupled services.

49
00:03:50,420 --> 00:03:56,900
Most lambda based applications use a combination of services for different requirements about storage,

50
00:03:56,900 --> 00:04:01,080
API management and integrating with the other systems and services.

51
00:04:01,100 --> 00:04:07,730
In these applications, Lambda is a connecting between services, providing the business logic to transform

52
00:04:07,730 --> 00:04:09,980
data that moves between the services.

53
00:04:11,420 --> 00:04:17,240
So now we can talk about design principles and the best practices by developing LAMDA based, event

54
00:04:17,240 --> 00:04:18,410
driven applications.

55
00:04:18,530 --> 00:04:25,310
So we set that solar applications mostly using a combination of services that integrated with the custom

56
00:04:25,310 --> 00:04:27,500
code run in the Lambda functions.

57
00:04:27,770 --> 00:04:34,910
So we can think we can find the most integrated services which using advanced lambda functions, you

58
00:04:34,910 --> 00:04:36,590
can see the image on the slide.

59
00:04:36,620 --> 00:04:42,230
These services are mostly commonly using in service application with a lambda function.

60
00:04:42,260 --> 00:04:46,120
You can see the category and also the services.

61
00:04:46,130 --> 00:04:50,990
We will also use these services into our service hands on projects.

62
00:04:51,020 --> 00:04:57,830
Also, there are some design patterns in distributed architectures that we will follow when we implement

63
00:04:57,830 --> 00:05:00,230
applications using the ADA services.

64
00:05:00,500 --> 00:05:05,780
ADA Services has already implement some of the distributed architecture design patterns that we can

65
00:05:05,780 --> 00:05:09,890
use easily without investing time to develop these patterns from scratch.

66
00:05:10,070 --> 00:05:16,970
When your application is using these patterns, we can basically use corresponding services.

67
00:05:16,970 --> 00:05:18,820
That is the table in the slide.

68
00:05:18,830 --> 00:05:24,290
So here you can see the patterns and here you can see the available services that we can use for that

69
00:05:24,290 --> 00:05:24,920
patterns.

70
00:05:24,950 --> 00:05:30,920
These services and patterns are designed to integrate with ADA Lambda functions, and we can also use

71
00:05:30,950 --> 00:05:35,690
infrastructure as code to create and destroy resources in the ADA services.

72
00:05:35,810 --> 00:05:42,980
We can use any of these services with using ADA SDK without needing to install applications or configure

73
00:05:42,980 --> 00:05:43,630
servers.

74
00:05:43,640 --> 00:05:49,670
So these are the best practices when designing well-designed serverless applications that we will follow

75
00:05:49,670 --> 00:05:51,050
when developing our services.

76
00:05:51,050 --> 00:05:51,860
Hands on labs.

77
00:05:51,980 --> 00:05:57,840
As a summary in serverless word, Lambda is core services for building any event based architectures.

78
00:05:57,860 --> 00:06:03,410
That means we will also follow these lambda design principles and the best practices when developing

79
00:06:03,410 --> 00:06:06,460
our Lambda Base event driven serverless applications.

80
00:06:06,470 --> 00:06:12,440
Basically, we will group these events as a bounded context in order to develop boundaries of our microservices

81
00:06:12,440 --> 00:06:13,970
in the service applications.

82
00:06:14,090 --> 00:06:20,060
That means we will develop lambda function as a microservices into our event driven microservice architectures

83
00:06:20,060 --> 00:06:21,830
in the service hands on labs.
