Application Load Balancer (ALB) Vs API Gateway // Pros Cons Comparison

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and girls raj here back with another video in this video we are going to compare application load balancer versus api gateway we'll start with introduction to each of this service and then we are going to dive deep comparing each other their future differences pros cons and also the price differences and then we are going to end the video with the conclusion as always timestamps are given in the description also please let me know what you thought of this video or if you have any questions put it down in the comment section like and subscribe all that good stuff it really makes me look like a better youtuber than i am and it really really helps the channel all right without further ado let's jump into the video so what is application load balancer it automatically distributes incoming traffic across multiple backend targets uh alb is a layer 7 load balancer so it works on the application layer the underlying infrastructure is managed by aws the underlying infrastructure is highly available and elastic so if the traffic goes up your load balancer should scale up as well to accommodate the increased rate of traffic so some typical lb integration would be your website uh sending requests to the application load balancer and you will configure different route in the load balancer so if the incoming path has slash browse or slash insert maybe they will forward to target groups with aws lambda if the path has slash delete then they're gonna forward to a wscc2 okay moving on to api gateway api gateway is fully managed and serverless api service from aws this also automatically scales up and down with traffic and also for api gateway infrastructure is managed by aws it is highly available and it is also elastic so typical pattern of api gateway integration will be your website calling different apis all those apis will be hosted in amazon api gateway and for different http methods such as slash get slash post slash delete it can go to different lambda or awscc to endpoints so which brings us to the topic of today's discussion is what is difference between lb and api gateway all right so let's take a look so for api gateway you can implement rate limiting bursting for apis if you want to control like hey this client can only call these apis 10 000 times a month with this much burst limit you can do all that for api gateway lb doesn't offer any such feature so even though the next point is not a difference but i wanted to mention it because it's important one both api gateway and application load balancer integrate with aws web application firewall for protection out of the box you just have to click a button that's it api gateway it is not possible to get a static ip address uh for endpoint you will always have the url uh lb it is possible to get a static ip address for load balancer endpoint are using a global accelerator api gateway only accepts https traffic lb accepts both http and https traffic api gateway this is a big feature of api gateway it is able to do request validation request response mapping you use a template called apache velocity template and you could check if some particular fields are present in the input api request and if let's say you are expecting a field called account number in the input api request and if it is not there you can reject it straight away from api gateway you do not have to go to the back end and code all that stuff similarly for request response mapping let's say some particular value is coming in as a field and then you want to move it to a different field before you send it to back end you could do that for example let's say a get api is sending an account number in a field called account underscore number but the back end is expecting the field to be scct and all so you could do that you can move the value from that account underscore number field to acct and now before you call the backend not able to do that in application load balancer so api gateway able to handle spikey traffic so both can auto scale up and scale down that's not a problem but if the traffic goes up super fast api gateway is little faster to respond because the nature nature of the underlying infrastructure the default rate is uh 10 000 rps rate per second and it can uh immediately allocate up to 5000 bus rate lb if the traffic is super spiky there could be little delay however you can pre-allocate lcu's we're gonna take a look at the lcu's this is like the capacity unit for alb like you can pre-worm underlying ec2's uh for albs and then even when the traffic spikes you won't face a delay however you have to pay extra for this because you are keeping things pre-warmed uh next api gateway able to integrate with the lambda i'm just showing it for one service it is able to integrate with lambda from different region even different aws accounts so if you have your lambda in a different aws account but your api gateway in another account your api will be able to integrate with that lambda lb is a regional service so even within an account a lb can only talk to services the backend services let's say lambda or ec2 running within that region i don't be able to go across region and cross account so going next api gateway you can able to export to import apis from cross api platforms using swagger or open api spec 3 uh so basically this is very very popular uh let's say you are running your api today in uh apigee right or some other api platform like kong api mulesoft etc and you want to test out api gateway so you can export those apis from those platforms using swagger and you can import it in api gateway and your api will be defined very little infrastructures coding required similarly if you don't want to get locked down in api gateway you can export out swagger for an api gateway and then define it in other api management platforms lb there is no direct method to import export rules for class platforms like if you have coded bunch of routing rules in application load balancer typically you will do that using cloudformation so if you want to move to another load balancer from another cloud or another company uh you probably you have to code that stuff again you cannot just import export easily api gateway have extensive authentication and authorization authentic integration as out of the box it integrates with api key im cognito user pool cognito identity pool and external identity provider actually this this is like a little bit of confusing because of five different methods so if you want to take a look at this i want to dive deep i have a separate video talking about this so i'm going to put a link up top either this side or this side you can take a look uh lb it integrates with any ydc compliant identity provider such as cognito ldap etc but it doesn't have uh integration with like api key because api key is api concept api gateway able to cache the responses um so for a specific method if you think it is going to return repetitive value you can cache it lb you are not able to cache any responses api gateway however the timeout limit for api execution is 30 seconds and application load balancer timeout limit is 4000 seconds so way longer timeout limit api gateway integrates with almost all aws services if you go to api gateway console click the backend integration you will see a lot of aws services in there lb integrates with ec2 lambdas and ip addresses as backend it cannot integrate directly with all different services that api gateway can do api gateway there is no health check like it's not gonna periodically go and check if the back end service is up and running if you want to implement it you have to do it yourself like you can let's say you have a lambda as a back end you can create a cloud watch scheduled rule which is gonna go ping the lambda and see if the responses are coming as expected lb health check is available it can ping the backend services and see if it is working okay that's how it determines whether the target is healthy or not right if it is not healthy it routes to a different target so api gateway is a serverless service so what that means it's it's pay per use so if the api gateway is idle if there are no api traffic at all then you don't pay anything for api gateway unless you enable caching then you pay for the caching capacity but let's say you don't have caching enabled then you don't pay anything for idle api gateway lb think of it like ec2 so to run a application load balancer for you underlying there is a ec2 running so you have to pay for a charge even if lb is idle so this calculation is little bit complicated so i'm just gonna show you the pages and you can you can take a look at it okay so this is the page for amazon api gateway uh pricing you can just google it it will come up so api gateway has a generous free tier the free tier includes one million api calls received for rest apis one million api calls received for http api and there are some other stuff uh so if you are trying to do a proof of concept api gateway will pro probably cover you in free tier beyond that so http api is the new uh flavor of api for api gateway i'm making another separate video on http api deep dive demo all that stuff but if you are able to use http api always use http api no need to use rest api uh so for http api the price is cheaper than rest api you can see first 300 million after the free tier is one dollar per million and after 300 plus million for 90 cents per million and http apis are metered in 512 kilobyte increments based on the payload rest api a little bit more expensive uh first 333 million price is 350 and then next 366 6667 price is 280 and then you can see the prices go down as the volume goes up the caching is only available for rest api but you can see depending on the amount of cashing you allocate the price changes but again if you can use http api you should always use http api okay now going back to load balancing so load balancing pricing is a little bit more complex so there are three different load balancers that aws offers application load balancer network load balancer and classic so we are talking about the application load balancer so you could see it has two component to it one is 0.0225 per application load balancer hour or partial hour and 0.008 per lcu hour so then it goes into detail on what is lcu so lcu is measured by new connections active connections process bytes rule evaluation so it's not really that straightforward and then you can go down and there is a pricing example so this is the rule of thumb do not think that one solution is cheaper than the other if your workload is spiky and then idle for a long time api gate will probably come out cheaper but if you are using consistently high volume uh the pricing may differ like aob might be cheaper but you're gonna do that calculation so don't assume that uh aob will be always be cheaper or api gateway will always be cheaper so as you can see it's not a simple straightforward alb or api gateway decision it will vary based on your use case so depending on your project and application uh check what features you need go through the lists do the price calculation based on the nature of the traffic of your application and then decide all right if you like the video please click the like button smash it if that's something you are into uh subscribe and again please comment it really helps this channel grow also i have created a facebook page where i share upcoming videos uh behind the scenes pictures and occasionally picture of my dog all right that's the video guys and girls hopefully you guys and girls enjoyed it i'll see you in the next lecture bye
Info
Channel: Cloud With Raj
Views: 53,768
Rating: undefined out of 5
Keywords: agent of change
Id: YKT9bWvy_PI
Channel Id: undefined
Length: 14min 4sec (844 seconds)
Published: Sat Sep 19 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.