AWS - Auto Scaling group with demo

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
auto-scaling is one of the coolest features of Amazon Web Services auto-scaling really helps our infrastructure to adjust according to the throughput needs so when they say high-throughput accordingly it adds service when the traffic goes down it automatically terminates a few instances there it is a cost-effective way of scaling applications in cloud this video let's see each and every aspect of auto scaling with a demo before getting into the demo first let's understand the concepts of auto scaling group and the terminology of it auto scaling group is a logical group of ec2 instances which participates in auto scaling auto scaling group has certain attributes like minimum size when we go and create a group they can specify minimum size which is minimum number of ec2 instances the group should always have you can have a maximum size there is a maximum limit upto which auto scaling can scale our instances less we also have desired capacity so this decide capacity value is decided at runtime based on the load put on this environment desired capacity changes based on the scaling policies they said we're going to tell auto scaling when to add servers and then to remove servers we do that with help of a scaling policies that scaling policy decides what should be the desired capacity according to the desired capacity or the scaling make sure the group has a desired number of ec2 instances to serve the load the next important concept to discuss is launch configuration launch configuration is a template which is used by outer scaling group for adding new instances to the group see for example just adding a simple ec2 instance may not be helpful for us why because the ec2 must contain all our applications and the package is required for serving the client serving the clients so that is where launch configuration comes into picture we need to tell auto scaling group that this is a launch configuration and if you want to add a new instance get the details from this configuration and accordingly add that new instance to the group and in our case read this launch configuration is going to have certain details like this this configuration will contain the a my details Amazon machine image that needs to be used for launching new instance we also need to specify the security groups then we have to mention what should be the volume type and what should be the volume size of that new instance even I am role sometimes your ec2 is talking to let's say yes three so easy to might need permissions to talk to s3 in such cases we create role and assign them even that should be mentioned in case of launch configuration and the private key for SSH into the servers we need private key those details we need to mention part of the launch configuration auto scaling group uses this launch configuration for launching a new instance into the group which is kind of a instance which has our web application and all its dependencies required to serve the customers let's login to edibles management console and see the demo offer setting up launch configuration and creating a auto scaling group this is our head of list management console let me show the options from where we can set up launch configuration and auto scaling group let's open this so under ec2 dashboard we have this auto scaling group son launch configurations so here we should go and create a launch configuration just to give you idea what exactly launch configuration contains that let's quickly go and see that see when you go and setup a launch configuration it expects the ami probably your ami should contain your application then that type obviously the name for demo purpose I'm just giving it as demo it also must have I am role correct and you can put some advanced details like if you want to have some user data scripts and so on you can put that also then as right we need to mention the size of volume and type of volume the secretary groups and so on so this is what basically large configuration contains this is used by auto scaling group for adding instances into the into the group let's first go and set up a custom Amazon machine image which contains our application let's cancel this go to instances launch instance I'm going with Amazon machine image there t2 micro I am I need one instance in this case go to advanced details and I'm just pasting a small shell script which is going to install Apache and which is going to just create a simple index dot HTML file on this Apache this is going to be our application which is behind that auto scaling group and we are enabling this Apache on reboot this is very important why because then auto scaling launches noon stands this Apache should come automatically otherwise health checks can fail and it can terminate your instance and it can start a new one terminate this can go ahead like this after that we are making sure that Apache server is coming up go to storage I'm just leaving all defaults here let's add few tags name let me call this one asked for a sequel is auto scaling group this one I am going with accept all traffic let me cross check that yeah so review launch it key pair is hurry their launch sign stands so I launch this instance to take a custom Amazon machine image our ec2 server is up and running let's verify our user data script is properly executed without any issues let's grab this public IP there and hit it yeah it says welcome to Java home crowd okay this image we are going to use part of launch configuration so come back the very first step next one is to setup launch configuration let me delete this hold one not required for us okay let's go and create a fresh launch configuration this time ok sorry we didn't take the image right let's take the am i from this ec2 instance so actions nature IM calling it as java home cloud ami let me put the same description there create image so here create it the request has taken and this image is created a synchronously in the background to go and check a mice yeah see that let's wait for some time once it's available we can use it for our launch configuration the image is available now ok so let's go ahead and create a launch configuration so come back to this screen so let me do it from scratch see we are in auto scaling group dashboard where we have launch configuration so from there I am saying create auto scaling group so when you say create auto scaling group it is of two steps here the very first step is create launch configuration launch configuration is that template as I said earlier also which contains the details about how to launch a new instance when there is a need of adding new instances to the group so let's go and say create launch configuration first now I don't want to go with existing image because that may not have my application installed for that I created one custom ami in my case so go to this my am ice so this is a one which we just created so select that this has our application installed and the type of ec2 instance we wanna use name it I'm calling it as a Java home cloud launch configuration I don't have any I am role to set now so I'm leaving it empty even I don't want to set anything in advance details go to storage I am fine with all default values here that's already group I want to go with a security group which accepts all all traffic so review it and finally create the launch configuration we are done with launch configuration the next step is to create the auto scaling group itself let's name it I'm calling it as Java home cloud auto scaling group it's a group size as I said write auto scaling group has minimum and maximum so let me put two as minimum instances and also decide the network where you wanna set up all your ec2 instances so basically in real time we have to create a custom repeater and subnets so in this demo I am going with default EPC which is kind of ready to work VPC and also select the subnets where your auto scaling is going to add instances I want to spread my instances across multiple zones and multiple subnets because of high availability it's always good to have minimum two zones and select advanced details in this case auto scaling can be integrated with load balancing we can easily integrate dr. scaling group with load balancer if you see this illustration so this is the auto scaling group and this auto scaling group can be integrated with a load balancer whenever there's a new instance added to the group that is automatically added to this load balancer now I want to integrate that load balancer in this case let's select receive traffic from one or more load balancers so I have already created a load balancer to want to know how to create load balancer you can check my other video on elastic load balancer I'll add that link to the description page in the YouTube this is the one I'm interested in if you have application load balancer or other network load balancer then this is option we should go of it and coming to health checks right so health checks are again very important in auto scaling group as well because if any instance is unhealthy auto scaling will terminate that instance and it replaces that instance with a brand new instance using that launch configuration so health check type we have couple of options when you say easy to if it will check directly the health of ec2 if the ec2 is up and running it assumes that it is healthy but in our case I don't want to check my ec2 is healthy or not I want to check my application is healthy or not and I want to do that will help of ELB so in LB we already configured health checks this auto scaling group uses same health checks for making sure the applications are healthy if not it terminates that let me go and show you what kind of health checks reconfigured in load balancer so go to load balancers this is a load balancer we're integrating with if you go and check the health details the ping target is this so we are pinging HTTP protocol 80 as a port number and this is the path we are pinging on that ec2 instance if you guys remember we added user data baby we created one index dot HTML we're sending a request to that index dot HTML if it responds back then it is treated as healthy otherwise it is treated as not healthy okay now he'll check grace period so what exactly does is your ec2 instance might take a couple of minutes to initialize your application so before that we should not perform any kind of health checks if we do so health checks fails and there is a risk of terminating that instance even before your application is up and running so because of that we need to set this healthy a grace period a default is 300 seconds which is 5 minutes in our case probably we need a 10 20 seconds for Apache server to come up and this helps a grace period right it starts after your ec2 becomes running let's change this one as 20 seconds let's say you were in your case your application takes 5 minutes for initialization and make sure you're given that time and you're blocking health checks until that so these things I am ignoring so instance protection we can enable this where auto scaling will not terminate all new instances which is added to the group but I am leaving it now let's go to the next one maybe configure scaling policies auto scaling can be used for two use cases one is to keep your group with a fixed size let's say I want a group with 10 ec2 instances always then we also can use of the scaling group for that incase out of that ten if couple of instances becomes unhealthy auto scaling will automatically replace those two instances with brand new instances that is one use case the other use case is scale adjust the capacity based on your traffic needs so we want to scale between this is the minimum size this is a maximum size so I'm keeping it as five as a maximum size and I want to use a simple scaling policies like this one says increase the size one says decrease the size so using this tell your auto scaling group when to increase the size meant to add new instances and also tell when to decrease the size when to remove in situ instances and a sidenote auto scaling is free and if auto scaling is launching ec2 instances enable is charged for those resources and auto scaling itself is free let's go and set the scaling policies let's go and tell auto scaling then to increase the size these names you can change coming to this execute policy we need to create alarms for this we need to set an alarm and when that alarm fires it takes this particular action let's go and add new alarm for this one the also can say notifications when alarm fires but I am NOT doing that right now so we can choose different metrics here you can set alarms based on average CPU maximum minimum sum and so on even not only CPU utilization you can set up these things on disk reads disk writes and discrete operations and so on our example I am going with average CPU utilization so whenever average CPU utilization goes above let's say 50% I want to fire this alarm and when this alarm fires I want to add in answers to the group so there is at least one consecutive predefined minutes in sense right if average CPU is above 50% above or equals to 50% continuously for five minutes then this alarm fires these things you can adjust according to your need you also can give a different name here but I am going with the default name created then this alarm fires so what action we want to take so I want to say add three more instances to that we also can have step scaling policies like we can say add step when CPU goes above 70% add two more 90 percent to more likewise we can scale the instances in steps but I'm going with simple scaling policy in this case so likewise let's go and set up a decrease group size let's tell when to decrease the group size let's create an alarm for this as well and whenever average sleep utilization is less than let's say 30 percent for one consecutive build of five minutes or whatever according to your need that's alarm II created so in this case I'd I want to remove the instances let's say I want to remove a couple of instances in this case again scaling down can be done in steps but to keep this example simple I'm going with simple scaling policies here so next go and configure notifications if you want to receive notifications for certain events in auto-scaling you can do that serious we can say add notifications and tell the SNS topic using which we want to get alerts select the events you wanna listen for accordingly you'll get notifications but I'm not going with that also in this case next one is tags let's call this one as Java home AC outer scaling group this is the tag we're adding and there's one more extra field called as a tag new instances when you select this one these tags are applied for ec2 instances which are launched by outer scaling group it would be nice to select this option because our instances gets tags by doing this selection review if you want to change anything in this go and change it otherwise let's go and create it the auto scaling group is created for us let's close this and let's go and check this auto scaling group see that minimum you said two and maximum we said there five so minimum is to immediate desired capacities - it has to go and launched two instances there let's go and see that see that it launched automatically two instances for us according to this decide capacity then there is say a scale out policy executed for example when CPU goes above 50% for constantly five minutes the desired capacity changes when the desired capacity changes auto scaling group automatically launches new instances to meet the desired capacity and when the scaling happens again same same thing it removes the issued instances to meet the decide capacity let's go and verify our application is working so to test it we need to grab the DNS record of load balancer so go there so this is our load balancer integrated with auto scaling let's grab this so open a new tab here put that link yeah so this is what we deployed on our custom ami which is part of launch configuration now let's go and check our scaling policies for actually working so let's go back to auto scaling group here under auto scaling group let's select our auto scaling group and you can check scaling policies we have a couple of policies which says decrease group size other one says increase group size so there is a straight option to test this increase group size and decrease group size by getting into this actions we can execute and that metric value let me put it as 70 so above 50% right it's going to fire this alarm let's execute that see that so according to that policy execution it is adding the DI means changing the desired capacity and when the when the desired capacity changes it automatically adds new instances for us you can go and check this activity history let's refresh that let's wait for a while you can see this they say auto scaling activity happened which is launching new instance and once it is healthy available that is automatically added to the group to handle that extra throughput coming from the clients ok let's refresh yeah so this is coming up so along with this kind of auto scaling we also can do scaling based on a schedule so there is option called as scheduled actions so maybe let's say you always have high traffic incident schedules that would be a good option to go and set up that schedule here and make sure what is a desired capacity and according to the schedule auto scaling will adjust your capacity for handling that exit throughput so thank you let's see the remaining concepts in other videos
Info
Channel: Java Home Cloud
Views: 31,949
Rating: undefined out of 5
Keywords: java home cloud, aws, aws tutorial, aws by javahome, aws autoscaling, aws autoscaling tutorial, aws autoscaling demo, aws autoscaling step by step, aws autoscaling with elb, aws auto scaling explained, aws auto scaling introduction, aws auto scaling group, aws auto scaling group health check, aws auto scaling group configuration, aws by javahomecloud, autoscaling by javahome
Id: JM1hfA9xBAc
Channel Id: undefined
Length: 23min 16sec (1396 seconds)
Published: Fri May 25 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.