‫Okay, so now let's talk about AWS Lambda.
‫So if we use an EC2 instance,
‫we have a virtual server in the cloud
‫but we are bounded by the amount of memory
‫and CPU power we give it.
‫It is continuously running
‫even though sometimes we don't use it.
‫And if we want to scale we can use an autoscaling group,
‫but that means that we need to add
‫or remove servers over time.
‫That may be a little slow
‫or there may be sometimes very complicated to implement.
‫With Lambda this is a new way to think about it.
‫In this case, we don't have servers,
‫we just have virtual functions
‫and these functions are limited by time.
‫So they're intended for shorter type of executions.
‫They will run on demand.
‫So that means that whenever we run a function,
‫it will be there to be run.
‫But whenever we don't need a function,
‫it will not be run and we will not be built for it.
‫And in case we need scaling, it's already automated
‫as part of the Lambda service
‫and this is why Lambda is a very popular service from AWS.
‫So the benefits of using AWS Lambda
‫is that the pricing is first of all super easy.
‫You're going to pay per request and per compute time.
‫And the free tier is also very generous.
‫So you get every month one million Lambda invocations
‫and 400,000 gigabytes seconds of compute time.
‫What this means is that you can run on Lambda
‫some pretty good services for free.
‫Now it is integrated with the whole AWS suite of services.
‫So we have integration with so many of the services
‫we've seen so far and it is very important event-driven.
‫So the functions will only get invoked by AWS
‫when something happens,
‫when an event happens or when needed.
‫So that makes Lambda the reactive type of service
‫which is important going into the exam.
‫It is fully integrated with many programming languages.
‫You get easy monitoring through CloudWatch.
‫We haven't seen what a CloudWatch is
‫but it will be the monitoring solution in AWS.
‫And finally, it's easy to get more resources per function.
‫We can get up to 10 gigabytes of RAM per function.
‫And if you do increase the RAM, it will also improve the CPU
‫and the network quality, so all in all very good.
‫Lambda can run many languages.
‫It can run JavaScript through Node.js,
‫Python, Java, C#, Golang, C# PowerShell, Ruby
‫and any language you want through the Custom Runtime API.
‫And one last runtime is called the Lambda Container Image
‫and this allows you to run actual Docker containers
‫on top of Lambda but these container images must implement
‫the Lambda runtime API,
‫which is not the case for every single Docker image.
‫So they are very very specific Docker images
‫that you can run on Lambda.
‫And so coming from an exam perspective,
‫you don't have to remember all the languages up there
‫but still is good for you to have a list.
‫But if it comes to running Docker images on AWS,
‫ECS and Fargate is going to be a preferred way
‫of running these arbitrary Docker images
‫so any kind of Docker images
‫but the Lambda Container Image does exist
‫if the Docker image is compliant
‫with the Lambda runtime API.
‫They maybe too specific for the exam
‫but I wanted to let you know of this detail.
‫Here is a very common use case of Lambda
‫which is to create a serverless thumbnail creation service.
‫So say we have an S3 buckets and we add images in it.
‫So our users are uploading a beach image into S3 buckets.
‫The S3 buckets will trigger a Lambda function
‫once the image is uploaded
‫and that Lambda function will take that image
‫and will change it to create a thumbnail.
‫It will push the thumbnail back into Amazon S3.
‫So the thumbnail is a smaller version of the image
‫or it will also push some metadata
‫about the thumbnail into DynamoDB.
‫That includes the image size, the image name,
‫the creation dates, etc, etc.
‫And all of this is fully event-driven and fully serverless.
‫With S3 we don't provision servers.
‫With Lambda we don't provision servers
‫and we've been in with Dynamo DB as well
‫we don't provision any servers.
‫So that is a great pattern because this serverless
‫thumbnail creation will scale it really, really well.
‫And we will be able to not worry
‫about provisioning servers to make it scale.
‫Now there's another very common use case for Lambda
‫which is to create a serverless CRON Job.
‫So CRON allows you to define a schedule
‫for example, every hour, every day or every Monday
‫and based on that schedule to run a script.
‫And by default, a CRON Job is run on an Linux AMI
‫so on a Linux machine.
‫But we are serverless
‫so we cannot provision an EC2 instance.
‫So instead we'll be using something
‫called CloudWatch Events or EvenBridge
‫and this service that we'll see later on in this course
‫will be triggering every one hour our Lambda function
‫to perform a task and effectively we have no servers in this
‫because CloudWatch events is serverless
‫and Lambda is serverless.
‫And so effectively we are launching a script
‫every hour through a Lambda function.
‫So I hope you can see now the trigger of it
‫the Lambda functions is really for serverless
‫functions in the cloud.
‫Now let's just talk about the pricing.
‫So you can find the Lambda pricing at this URL,
‫but it's very simple.
‫You pay per call.
‫So that means the first one million Lambda invocations
‫are free and then it's also very, very cheap.
‫You're going to pay $0.20 per 1 million requests thereafter.
‫You also going to pay for the duration.
‫So the free tier as I said is 400,000 gigabytes
‫seconds of compute time for free.
‫And that means it's 400,000 seconds
‫if the function has one gigabyte of RAM
‫or 3.2 million seconds
‫if the function has 120th megabyte of RAM.
‫After that you're going to pay $1
‫for 600,000 gigabyte seconds.
‫So all in all the bottom line
‫is that it's going to be very cheap to run Lambda on AWS.
‫And so it's a very popular service
‫to run your serverless applications and websites.
‫And going into the CCP exam,
‫you need to remember that Lambda pricing
‫is based on calls and duration.
‫So that's it for this lecture, I hope your liked it
‫and I will see you in the next lecture.