Previous Lecture Complete and continue  

  Benefits and Use Cases for Serverless with AWS Lambda

Congratulations, you almost made it. There is one final module, and one final lab. We will discuss Serverless, and, when we talk Serverless with AWS, we're talking AWS Lambda. The benefits of AWS Lambda are multiple. There is no servers to manage, because it's Serverless. There is continuous scaling. It's very easy to scale, just ramp up the slider, and your function will perform faster and better. There is subsecond Metering, so you don't have to pay for hours as you do with EC2. You pay for sub-seconds.

Here's the use case. You upload your code to AWS Lambda and save it in the Cloud. You can use CLI, or you can use Web Console, or you can use some of the frameworks, such as APEX or Serverless framework. Then you set up your code to trigger from other AWS services, or maybe HTTP Endpoints, or some in-app activity. So those events, typically they're HTTP requests, they are going to Lambda. And Lambda would be exposed the API gateway by having an endpoint.

Then Lambda could run the code that you saved in the first step, and that code can execute whatever task you need to execute. And you pay only for the time that this function, this tiny, bitty, small function, has run. So Lambdas are ideal, they're perfect for infrequent and fast operations, and also operations that, which do not require constant 24/7 run time. Because most likely, if you're using your Lambda 24/7, having an EC2 would be cheaper than having a Lambda that is always, constantly being triggered and always executing.

But for some event driven operations where you don't need to run it all the time, you don't need to run that function all the time, Lambdas are great because they would allow you to save money. Some of the use cases, creating a RESTfull API and/or mobile backend. There's no need to create an EC2 instance, there's no need to create Elastic Beanstalk application, just a Lambda function and expose it via the API gateway. You can build Internet of Things backend and integrate with AWS Kinesis. You can use for Extract Transform Load operations, such as getting data to Redshift from S3. You can set up real-time file and stream processing. You can listen to multiple events from other AWS services, such as S3, or EC2, or CloudWatch.

And then those events would be streaming to Lambdas, and in Lambdas you can do anything. And then, what's most interesting, lately I've seen more and more companies switching to Serverless for their entire web applications. So in addition to AWS Lambdas and REST full APIs or GraphQL APIs, those companies, those teams, they would also leverage AWS S3 to host their static resources, such as HTML, CSS, and JavaScript. And for the backend, they would be using Serverless. This is another use case and an example. Let's say you're building a weather application. So you put your front-end files, HTML, CSS, make it responsive, put some JavaScript to make AJAX requests.

So you put them in your S3 bucket, then user goes to a URL, sees your webpage, and then you have some browser JavaScript, which will make a request to a special RESTfull API via API Gateway that could be authenticated or it could be public. That triggers Lambda, executes whatever you need to execute to get your weather information, maybe quick look up in a DynamoDB database or call to other weather API providers, third party services, to get an aggregate. And the data goes back to API Gateway, and it goes back to the client. Here are some of the resources to work with Lambda. You can check out the latest documentations and also the "Hello World" example. It's very straight forward.

0 comments