Autoscaling with Instance Group and Load Balancing using Google Cloud
Today, I’ll build an autoscaling system based on multiple instance groups in two regions. One instance group will be in Singapore, with a maximum number of instances of 2, and another will be in Belgium. Both instance groups have the exact specification based on the same instance template.
The instance template, as its name, is a template to make a new instance. We define the specification of an instance template so that the instance group can replicate the same machine with the same specs, configuration, and things such as startup script.
After that, I’ll go to the instance group. An instance group is a group of VM that can replicate based on the specification of the instance group. It can replicate (autoscale) itself based on parameters such as the average CPU usage of the first VM. For example, if the first VM’s average CPU reaches 80%, the instance group will make one more new VM based on the instance template we just defined.
I’ll create another instance group in Europe (Belgium) with the same configuration as Southeast Asia (Singapore).
After both instance groups are successfully deployed, I’ll create the load balancer. A load balancer is a reverse proxy for distributing load (traffic) to an instance, and also points traffic to the nearest region where I deployed my instance group.
Since my web application in every instance uses HTTP in port 80, I’ll use an HTTPS load balancer, so this load balancer also acts as an HTTPS (port 443) endpoint. Since it has a single endpoint, I would only need one SSL certificate which is located on the frontend side of the load balancer.
After I configured the frontend and backend sides of the load balancer, I’ll access my web application via my domain.
The HTTPS load balancer has successfully been deployed. To make sure that the load balancer points to the closest region, test it with VPN within the Europe region. To make sure that the autoscaling works, test it with multiple connections and look for the instance group panel. After a few minutes, look for the number of instances.
References