This lab walks you through GCP Autoscaling based on CPU Utilization.
You will be creating an Instance Template defining the instance configuration.
You will be creating an Instance Group defining the Autoscaling Policy.
Duration: 45 minutes
Let's understand Auto Scaling with the help of an example, imagine you being a web developer and you have developed a web application, now you are ready to go live on a single front end server. You have different layers in your applications like the web layer (front end), business layer, and database layer. On day 1, you are assuming 10 concurrent users which will ideally use 50% of your CPU Utilization but as the demand increase, you might see an increase in users from 10 to 20 or maybe more during peak time, also at some point in time, you might see a very fewer user. If you add some front end server manually then it can be a huge overhead if your application is big and again you have to decrease the server manually. To overcome the scenario, AutoScaler came to the rescue, where you just define the instance template means the configuration of every server and instance groups where you define your scaling policy. Here we are going to show you CPU Utilization over 80% policy. Autoscaling mostly used with Load Balancer to have a single IP of all the running instances. We will cover about Load Balancer in the next lab.
Compute Engine offers both managed and unmanaged instance groups, only managed instance groups can be used for Autoscaling.
While creating an Instance group, you must specify which autoscaling policy and utilization level that the Autoscaler should use to determine when to scale the group. There are three policies:
Average CPU utilization.
HTTP load balancing.
Cloud Monitoring metrics.
The Autoscaler keeps on collecting usage details based on the chosen policy, and then compares actual utilization to your target utilization, and uses this information to determine whether the instance group needs to remove instances or add instances.
For example, if you choose CPU utilization policy, you can set your target utilization level at 80%, so once the CPU Utilization cross or equals 80%, the autoscaler will add more instances to the group.
The Autoscaler keeps on collecting usage details but while your instance is spinning up, its metrics information might be irrelevant to be considered for the autoscaling policies. To avoid that scenario, always set a Cool Down period so that Autoscaler waits till cool down period finish before collecting the metrics information from the instances.
Login into GCP Console.
Creating an Instance Template
Creating an Instance Group
Checking the running Instance