AWS : Elastic Load Balancer Deep Dive - With Demo

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's talk about Amazon elastic load balancer I'm going to do a deep dive into this session let's go and see let's go and set up a elastic load balancer with complete demo ELB is one of the important services in Amazon Web Services let's first go through the features and benefits of plb and followed by we'll have a demo on it this is a small illustration of elastic load balancer so in this diagram elby's load balancing the applications which are running on ec2 instances across two different zones the basic use cases for load balancer is we can horizontally scale our applications by adding more and more ec2 instances in this case we also can make our applications highly available because we are deploying our applications across different zones and in case of a zone failure your application will be still up and running and it won't there won't be any downtime for that that's the second use case of using elastic load balancer let's see the benefits of ELB particularly in Amazon Web Services primarily LD works it is bound to a specific V PC it can load balanced ec2 instances which are sitting in same BBC it can't load balanced easy to instances across multiple pcs even it can't load balanced ec2 instances across different regions actually so if you have a use case where you want to load balanced across different regions we can do that with help of route 53 and LB is fully managed service it is completely managed by Amazon Web Services it comes as a pass model platform as a service but we also can secure elastic load balancers using security groups while launching ELB we can assign security group and we can completely secure the elastic load balancer those things we'll be seeing in the demo elby's also performs health checks on ec2 instances it's load balancing to make sure tastes routing the traffic only to the healthy instances it also supports SSL terminations in sense when we configure HTTPS using SSL Certificates generally client sends a hesita PS equals to the server and the same request comes to ELB in ELB we can close that SSL connection we call this one as SSL termination we can close the connection we can decrypt the data and we can pass on that information to the web servers we also can do this SSL termination on web servers but SSL domination is a expensive process it can bring spikes and cpu so it is recommended to do SSL terminations on ELB not on your web servers where it's running on ec2 instances let's learn all these concepts with help of a demo I am in my edible astonishment console we can find elastic load balancers under ec2 let's go there before setting up elastic load balancers I want to prepare a couple of ec2 instances across different availability zones let's quickly go and launch instances there I am going with Amazon Linux to be under free limits I'm going with this t2 micro I want one instance and I'm keeping all the examples simple I am putting all my details into default V PC where default V PC has multiple public subnets and it's ready to work kind of subnet only PC for us so I want to install Apache server on this I want to use user data in this case I have prepared a small script which is going to install Apache on your Linux machine and also it is going to keep a small index for HTML file for our testing purpose let's grab the script this is a very simple shell script which is installing Apache on your line X mission and using this echo I'm sending this content to this index dot HTML this is the deployment directory for Apache I'm creating this new file with this content on that I am enabling sed PD on reboot in case you are a c2 instance reboots it automatically starts Apache server and finally I am starting this Apache server for us let's keep that script here I'm pasting that script as it is user data is a way to execute scripts at launch time and this script is executed when this ec2 instance launches now let's go and check the storage part ok so number of instances 0 let's make it 1 I can't keep - because right if I put 2 here both will be into a same availability zone ok so let me choose this also one I want that to be in one a other one let's keep it in 1b let's repeat this example one more time for a different ec2 instance there ok storage I'm just fine with 8gb of storage here tags better to add tags I'm calling this one as a webserver one safety group I want to choose a group which accepts all traffic I don't have any specific group requirements specific security rule requirements in this case review and launch it so I'm going with my own key pair launch it so let this machine come up before this mission comes up right I want to launch one more into a different zone it is in 1a let's launch one more in 1b because it will be highly available for us launching stands Amazon Linux so instance details I want one instance a default V PC and coming to subnet I want this one to be in one piece for high availability and to the end right let's copy-paste that user data script slightly changing this I want to say response from server to because when we put a load balancer in front of these two instances we can clearly see bit server is responding back to us and even don't forget to make sure the every ec2 has a public IP enabled so that's also required for this demo storage tags let's name it let's call this one as webserver to security group so I'm going with the previous one which allows all traffic for us review launch it come in two key pair I'm selecting say and key pair we launch the server let's go to instances there let me check are we able to access web server one with help of its public IP yes it says response from server one likewise let's also check the web server to I think it should work for web server to also grab its public IP here the way it's taking late while to come up it should work it should say response from the web server too so meanwhile let's go and set up elastic load balancer you can find elastic load balancer under AC 2 itself so this is the section go to load balancers let's go and create a new load balancer here so currently as of today amazon has three different types of load balancers one is application load balancer Network load balancer and the classic load balancer our demo is on classic load balancer let's create that let's also name it I am calling it as a um cloud ELB all my instances are kept in default with PC and we should make sure this ELB also sits in the same network as I said right ELB saban with vp c so it can load balanced is it instances only within that same EP c and the next option is create an internal load balancer when you say yes this load balancer is not exposed to internet it is going to be something intranet so it's great load balance applications which are which works within your network but in this demo I want to expose this to Internet I am NOT selecting this box if you uncheck it is going to be a internet based load balancer we can access it from our internet next one enable advanced view PC configuration please select this and coming to load balancer protocol I want to run my load balancer on HTTP if you have SSL certificate if you want to say here your HTTP connections then we should go with HTTPS for this demo I am going with HTTP because I don't have any SSL certificate in my case I want to run this on 80 port number so I am leaving it as 80 coming to instance protocol given my web server the one which we installed on ec2 instances they are listen in 280 port and has city to protocol so both the cases it's SCDP and 8080 and next we have subnet selections this option comes only when you enable this okay this reason we enabled it now tell what are the subnets you wanna use for adding your ec2 instances we kept easier instances in both the subnets I want both then go and say security groups as I said right we can secure ELB is using security groups now again I'm just going with hello all kind of stuff so configure security group settings this is empty because we didn't choose HTTPS as an option in case of load balancer protocol health checks lb is going to perform all sex on ec2 instances to make sure it is routing traffic only two healthy instances if there is a request coming from the client it cannot route traffic to unhealthy instance because the client might face errors with those instances the ping protocol so your application runs on ec2 that application right is running on Apache which is using HTTP protocol and the port number of Apache is 80 and the pink path and apache if you guys remember we kept index dot HTML so in your case said it might be a different file in my case it is index or HTML it can be any path where we use this path for making sure this particular application is healthy on this mission and coming to advanced details response time mod basically two seconds is say where application should respond within two seconds any click you do on the application that has respond within two seconds and health check intervals why because we have to do this health checks at regular intervals of time to make sure your your system is still healthy and if you reduce this it can increase a load on your server it all depends on your application nature I am going with 10 seconds unhealthy threshold if two consecutive checks fails the machine is marked as unhealthy and that machine is taken out of service and again when it becomes healthy red we should bring that is it instance into service that is the healthy threshold I am again bringing down to two if two consecutive checks succeeds right and LD instance comes into service saying it is healthy let's go and add is it instances so in our case we want to add webserver one web server - okay we see couple of options here enable cross Joan load balancing so what is this cross zone load balancing it works like this if cross Joan load balancing is enabled lb distributes the load across all the instances evenly so every instance across any zone gets same size of load if we uncheck this one how it works is it allowed 50 percent of traffic to zone 1 and 50 percent of traffic to zone 2 in sense let's a zone one has ten instances zone two has twenty instances zone one gets 50 percent many ten instances handling 50 percent of traffic and remaining twenty instances handling the remaining 50 percent of the traffic so in this case right there is a heavy load on the service in AZ one because ten servers handling fifty percent 20 servers in zone to handling 50 percent that is how that cross zone load balancing works so if you enable this one it evenly distributes load across each and every ec2 instance and coming to connection draining at cases your instance may be very slow not responding and your LB finds that instances unhealthy in such cases it should take this instance out of service before taking this instance out of service this instance might be having current open connections we should give some time for that machine to complete its current open connections then eventually we have to take this instance out of service that is called as connection training period sure so in this case default is 300 seconds which is five minutes we are giving five minutes of time for unhealthy mission to complete its spending work yeah when machine enters into connection draining period it won't accept new connections these things I am reducing these things again depends on your application let's add tax to this maybe some will be demo it's always good to add tax to be easy for you guys to track your resources and even it will be easy if I you guys to know why you created it so review page if you want to change anything in this case you can go and edit and change it otherwise go and create it the elastic load balancer is successfully created for us let's close this and these are the details about ELB this is the DNS name using which we can access our lb load balancer coming to instances we added a couple of instances currently it's statuses sort of service in the background lb is performing health checks once lb finds these two instances healthy it brings them into service and status becomes in service at any point of time we can edit this they can add new instances we also can remove the existing instances from the alb if you see the status now it is in service we can go to description tab grab this DNS record that's a URL that's the endpoint of elastic load balancer let's open a new tab here put it there and click enter see now the response is coming from server to alright we are hitting ELB and ELB is routing the traffic to server to let's try to refresh now sever one is responding refresh sour two is responding it's kind of doing round-robin phorus ELB as of today classic load balance as of today's supports only round-robin algorithm for example our one of our server stops still your customers won't face any downtime because ELB takes care of routing those requests to a healthy server let me go and stop web server one now for demo purpose your application won't become offline because still there is one more server which is up and running this server can handle all the requests coming from your client see now it is routing the traffic to only server two I am refreshing my page it is routing traffic only to server two because it is not routing traffic to server one it is unhealthy now once your server one becomes healthy like this so it keeps checking the health of your web server one when it finds this our healthy again it brings this server back to service and it starts routing traffic to server one as well see now web server 1 is in running state let's go to lb check instances see both are that will refresh and see that yeah both are in service now let's refresh yeah now see the second server I mean the server one early it was unhealthy now it has become healthy it is automatically brought into the service by your elastic load balancer we do have a concept of stickiness in ELB let me explain that for you let's go to description page now this one we have a stickiness disabled we can even enable the stickiness the basic idea is when you enable stickiness it occurs from a specific client is bound with same server I am repeating it when stickiness is enabled when a request is coming from a specific client all the requests from the client is routed to same web server may be a case where we are maintaining the state of client in the web server level and I want to route all my traffic from same client to same server in such cases we can go and enable the stickiness let me show that for you currently it's disabled I'm going with second option and expiration period let me keep it as 30 seconds what exactly it mean is in the background it is going to create a cookie cookie is a small information using which your il bit tracks the client details so based on that it routes all the traffic from that client to a same server save it so once we save it let's say I am a client sending first request to my web server to my ELB my first request is handled by serve one and all my subsequent request is also handled by someone so this is called as stickiness I am refreshing my page see everything is getting into serve one itself because my first week was handled by server one and all my subsequent requests will go to same server this is managed by your elastic load balancer if I go and disable this let me disable and come back to this and start refreshing a page see that now again it is routing the traffic across different ec2 instances so that is how stickiness works
Info
Channel: Java Home Cloud
Views: 25,757
Rating: undefined out of 5
Keywords: java home, devops, java home cloud, devops tutorial, devops by javahome, devops by java home cloud, aws, aws tutorial, aws by javahome, aws elb, aws elb tutorial, aws classic load balancer, aws elb deep dive, aws user data, aws elb configuration, elb aws tutorial, aws by java home, elb by java home, deploy website on aws, aws elb sticky session
Id: 4gnMyhyVIg4
Channel Id: undefined
Length: 20min 53sec (1253 seconds)
Published: Thu May 24 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.