Server Autoscaling in GCP
Overview
This guides explains the design of tracking the application servers in an autoscaling group in GCP.
Autoscaling in Google Cloud platform is a feature of the managed instance groups. A managed instance group is a pool of homogenous instances, created from a common instance template.
For more information on managed instance groups, refer to Instance Groups.
For Avi Vantage, the simplest form of autoscaling is to scale based on the CPU utilization of a group of virtual machine instances.
Autoscale groups can be created for both single zone (with multi zone support) and multiple zone (regional).
An autoscaler adds or deletes instances from a managed instance group.
The following autoscaling policies can be used to scale instances:
-
Average CPU utilization
-
HTTP load balancing utilization
-
Stackdriver monitoring metrics
Creating Instance Groups
The following are the two types of instance groups:
-
Managed
-
Unmanaged
Managed Instance Group
You can create instances from an instance template. The managed instance supports autoscaling, autohealing, regional (multiple zone) deployment, and automatic updating.
-
The following are the two types of managed instance groups:
-
Zonal Instance Group — This deploys and manages instances in a single zone.
-
Regional Instance Group — This deploys and manages instances in multiple zones across the same region.
-
-
For autoscaling, you can attach an autoscaler to the instance group that scale instances up or down based on the autoscaling policy.
-
You can manually configure the number of instances without configuring the autoscaling for the group.
The following are the functionalities of the autoscaling modes:
-
Autoscale — Turn on autoscaling to add and remove the instances in the instance group.
-
Dont Autoscale — Turn off autoscaling and keep the autoscaling configuration.
-
Autoscale only up — Use autoscaling to only add instances in the instance group.
-
Do not configure autoscaling — Manually specify the number of instances for this instance group.
-
-
Auto healing recreates virtual machine instances if the health check an instance fails. If health check is not configured then instances will be recreated only when they are not running.
Unmanaged Instance Group
The unmanaged instance groups contains heterogeneous instances which are not created/managed by the instance group.
The unmanaged instance group does not offer autoscaling, multi-zone support, and use of instance templates to create new instances.
You need to manually add/remove instance from the group.
Autoscaling Groups in GCP using Instance Templates
An instance template is an API resource that you can use to create a virtual machine (VM) instances and managed instance groups. Instance templates define the machine type, boot disk image or container image, zone, labels, and other instance properties. You can use an instance template to create a managed instance group.
The managed instance groups allow autoscaling by automatically adding or removing instances based on the increase or decrease in the load.
Triggers in Instance Templates
Autoscaling is based on the following trigger types in instance templates:
-
CPU usage
-
Stackdriver monitoring metric
-
Multiple metrics
The autoscaler is created by specifying the autoscaling policy and a target utilization level. These are used by the autoscaler to scale the group. The autoscaler will collect information based on the policy configured on Avi Vantage. This information is compared with the desired target utilization and scaling is triggered accordingly.
Configuring Autoscaling Server
Pool Configuration
The following are the steps to configure pools:
-
You can add pools and configure external_autoscale_groups field in them. The external_autoscale_groups will list the GCP instance groups which are in InstanceGroupName@ProjectID format.
-
You can share the Instance Groups across the pools.
-
If they are shared across the pools of the same cloud, then the polling and sink creation will be done once per instance group.
-
If they are shared across clouds, then polling and sink creation will be done once per cloud and instance group. There will be redundant calls across cloud for same instance groups.
-
Cloud Configuration
The following are the steps to configure cloud:
-
You can configure the polling interval by using autoscale_polling_interval field in the cloud.
-
By default this will be set to 10 minutes for GCP cloud type.