AWS Lambda Vs EC2 | Serverless Vs EC2 | EC2 Alternatives

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
lambda or ec2 this is a very common question asked during design discussion this is also a hot topic in intervals so in this video we are going to go over the differences between EC 2 and lambda look at some use cases also we are going to discuss some of the alternatives of using ec2 hi guys and gals Roger your friendly neighborhood cloud architect alright let's jump into the video all right let's start from beginning so what is selfless coeruleus has these four properties no servers to provisional manage either physical or virtual it automatically scales with usage you do not have to define auto scaling group auto scaling policy etc if the traffic goes up it will scale up when the traffic goes down it will scale down you pay for what you use you never pay for idle and lastly it is inherently highly available in the backend it's automatically deployed in more than one availability zone so what are some of the several services so folks have this misconception that a lambda is the only sovereign a service which is not true so any AWS service which satisfies this fault criteria is actually part of the sulfur logical system so what are some of the services we are Amazon DynamoDB FBI gateway a table step functions and Amazon SQL and there are many more however for this video we are going to talk about the crown jewel of server less which is AWS lambda AWS lambda is a computer service that lets you run code without provisioning or managing servers now let's take a look at what is ec2 so easy tools are servers in AWS provision with few clicks and within few minutes it supports variety of operating systems and easy to is actually backbone of multiple an WS services such as Amazon Elastic container service Amazon Elastic container service for kuba it is also known as he cares amazon ideas there are many more however for this video we are going to talk about vanilla Amazon ec2 alright now that we understand what is lambda and what is ec2 let's take a look at an environment difference between these two so for lambda underline infrastructure is managed by Anna Bluest so it scales automatically and since you don't manage any server you don't have to patch anything for ec2 you control the underlying infrastructure such as VM size operating system MI etc however what that means is you need to handle the scalability if you want your ec2 x' to be scalable you need to setup the auto scaling group auto scaling policy etc and beyond that since you are managing the server you have to patch it you have to do the AMIA addition etc so this requires some management and orchestration so lambda has significantly less maintenance overhead in this area since you don't have access to any server with lambda you cannot install any software such as web server app server in the underlying environment however you can install code libraries whatever code library your lambda code is using you can install you can zip them all up and then you can deploy them with your lambda so easy to shine in this area since it's the server you can install almost any software and there are a lot of prepackaged a mice with different software's already available for lambda there is the easy selection of compute power let's say you have a lambda running and then at any point you want to go change your lambda all you have to do is go change the slider bar for memory and timeout and they will be changed you can change the memory from 128 megabyte to 3 gigabyte and timeout from one second to 15 minutes and as you increase the allocated memory to the lambda under the hood lambda will allocate more CPU to it as well easy to you can see differently to size and types as you change the size and type of a running ec2 instance it might briefly be interrupted for lambda there is no attached hard disks or EBS and the deployment packet size is limited you can attach one or multiple hard disks or EBS to ec2 so you can pretty much deploy any package of any size lambda is inherently highly available so under the hood it deploys the lambda into multiple availability zone so even if one is he goes down your lambda will be still up and running for a c2 user need to establish high availability so if you want your ec2 to be highly available you have to deploy the same ec2 in two different daisies and then create a lot balancer and all that stuff so what is one of the super power of lambda since you don't have to manage any server and it's inherently scalable and highly available it is much easier to onboard into lambda and you can focus on solving the business problem rather than doing the maintenance and orchestration and what is one of the super power of ec2 you have complete control of environment and it is a rich ecosystem of different AM eyes with different prepackaged software you can literally run anything on ec2 okay now let's take a closer look at use case differences between lambda and ec2 so lambda shines at event-driven architectures it has native integration with other services let's say anytime you put an object in an s3 bucket you want to process something so you can trigger lambda from the rs3 bucket directly for ec2 it enables faster migration to cloud with other software's let's say you want to run a web server an app server with some other third party software you can install all of that in AC 2 lambda is suited when traffic is unpredictable why because it scales automatically and you pay-as-you-go easy tools best cost case is when traffic is predictable because you pay for the underlying virtual machine regard and hornets kills it scales an entire VM so we are going to take a look at this in detail in the next slide solace is good to implement micro-services because lambda has API gateway integration the code is modular without software dependencies for example Python api's and it is easier to migrate cloud native Greenfields apps to several sec2 is good for micro services as well because it is easy to move api with dependencies for example spring boot however you have to consider cost and complexity for greenfield applications so in the last slide we went through couple superpowers so what is a kryptonite for lambda for brownfield monoliths to lambda major refactoring might be needed for ec2 the kryptonite is more day to operational overhead dance RLS and also there is a generally underutilized CPU memory leading to cast waste so now let's take a look at scaling of lambda versus container so for lambda as traffic increases lambda will scale itself automatically and the great parties you only pay for what you use let's say your lambda ran 1,000 times a month so you only pay for that 1,000 times if next month the same lambda around hundred times then you only have to pay for that hundred times so now let's take a look at the scaling of easy to generally in production you have elastic load balancer pointing to your auto scaling group and inside there auto scaling group that is a ec2 running now let's say we have a traffic coming and hitting that elasti load balancer and let's assume this brings the CPU of ec2 to 50 percent as marked by this half green box inside that easy to then let's say that traffic increased so then the CPU increased to hundred percent for that easy to traffic keeps increasing it is gonna spin up another ec2 and in that easy to the CPU used will be 50% but take a note even though the second ec2 at 50% utilization you have to pay for the entire ec2 so even the 50% of this ec2 is idle it doesn't matter you are charged for the entire ec2 wait before you make up your mind let's take a look at couple use cases in the next slide so let's say one of your lambda is running three million times a month and the lambda has 512 megabyte of memory and each execution lasts around 300 millisecond and the traffic is unpredictable so using the lambda cost calculator you are going to pay dollar rate per month for this lambda now the same traffic to accommodate this you need a t3 small and you need two of them to make it highly available so you're gonna pay around $29 per month however remember that traffic is unpredictable so cost will increase during higher spike because of scaling because the entire VM will scale and you have to pay for that entire ec2 doesn't matter how much CPU is being utilized now let's look at another scenario let's say now the traffic is a 90 million per month the memory 512 megabyte each execution is 250 millisecond traffic is predictable so in that case lambda you're gonna pay a $260 a month for ec2 so this traffic can be accommodated using a t3 medium and you need 2 of those to make it a CH a you only gonna pay $58 per month so what is the big difference here because a predictable traffic it makes it possible to select proper VM and higher CPU utilization so in this case if the traffic is steady the ec2 don't need to scale you can keep these two to three mediums and it's going to process all the traffic and the CPU will probably in the high end which is good because you don't want to pay for idle resources with ec2 and that's why that cost is lower so the conclusion is one is not cheaper or pricier than the other it all depends on the use case so now that we know the differences between lambda and ec2 and let's take a look at some of the other receipt alternatives also if you are liking the content please feel free smash that like button and click subscribe that helps this channel a lot and that kind of motivates me to make more videos alright let's look into the alternatives now so let's say you have a micro service running on ec2 alternative is you move that code to lambda and use API gateway for the API web server running on ec2 so you can do website hosting using s3 and you can use lambda API gateway for the dynamic content databases on ec2 you should always a migrate to cloud native service when you can so you should migrate to Amazon IDs and Amazon Arora especially if you are running something like Oracle on ec2 you should look into migrating to Amazon Aurora which provides the security availability and reliability of commercial databases at one-tenth the cost and no sequel databases running on ec2 you should think about migrating to DynamoDB or manage Cassandra alright so next one self managed kubernetes cluster on ec2 you should look into migrating tree casts forget or even easy s running bunch of machine learning stuff on ec2 you should look into search maker in your project or even interview this comes up mentioned this and I guarantee you your team members or the interviewer will be impressed so what are my parting words so we started this video with lambda versus ec2 because we will have to compare in this current world however as we saw in some use cases lambda is more suitable and some other use cases ec2 is more suitable so always do your own analysis so pick and choose between lambda and ec2 based on your use case traffic pattern performance cost analysis etc so it's not really several as far as EC - it's more like several less and easy to our a dozen girls that is the video hopefully this video was useful I'll see you guys and girls in the next video bye
Info
Channel: Agent of Change
Views: 8,447
Rating: 4.9477124 out of 5
Keywords: lambda vs ec2, serverless vs ec2, ec2 alternatives, ec2 vs lambda, lambda ec2 comparison, aws lambda
Id: 1JsPIyqGqU4
Channel Id: undefined
Length: 13min 19sec (799 seconds)
Published: Sun Mar 01 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.