We will look a the step by step procedure to setup and configure the auto-scaling and load balancing feature on the Google cloud. Once configured we will see how the http load balancer is scaling the instances based on the network traffic.

Let’s begin.

Step 1 – Build an instance template with apache installed configured with demo page.

a) Go to Compute Engine > Instance Templates and click on “Create Instance Template”

Then create the template with below configurations.

Also, make sure to enter the below script under the startup script box comes under the Management tab.

#! /bin/bash

apt-get update
apt-get install -y apache2
cat <<EOF > /var/www/html/index.html
<html><body><h1>Hello from $(hostname)</h1>



Once the above configuration complete click on Create to create the template.


Step 2 – Create a Managed Instance Group

a) Go to Compute Engine>Instance Groups 

b) Configure the Instance group parameters are below.

c) When it reaches the health check configuration select “Create a Health Check” option and create a health check as below. Once it is created select this health check and proceed to create the


d) Finally, let’s verify the settings and click on Create button to create the instance group.

e) Now you will see a warning as below.

f) Once it shows the group click on the Web01 link to see more details. There you will see minimum 2 instances created as below.


g) When you click on the public displayed on each node will open up the default web page created by mentioning the hostname (last 4 letters)


Step 03 – Create an HTTP Load-Balancer 


a) Click on the Networking services>Load balancing Then click on “Create load balancer”

b) Now select the HTTP(S) Load Balancing and click on “Start Configuration”

c) First name the Load balancer according to your standard. Here I have used webapphttploadbalancer

d) Then click on the Backend Configuration, then Create or select a backend service and select Create a backend service then configure the parameters as below.

e) Upon Successful you will see a blue check mark. Then you can proceed with the Host and path rules option. You will not make any changes here and can be proceeded to Frontend configuration.

f) Set the frontend configuration parameters as below and proceed further to review the configuration and create the load balancer.


Step 04 – Testing the Auto scaling and load balancing

a) Now go back to Compute Engine>Instance Groups> Click on Web01 link and verify the configuration.

You will see something like below.

“The autoscaler is configured to scale based on a load balancing signal but the instance group has not received any queries from the load balancer. Check that the load balancing configuration is working.”


b) Now let’s check the Load balancer configuration and note down the public IP Try browsing this URL and see what reply you get. If you try from different browsers you will see you are getting a reply from different nodes.

c) Now we will generate some load and see how it behaves. For that, we need to install a package named “hey”. Follow instructions to install the same. Run below commands in the GCloud Shell.

d) Now, let’s wait for a couple of minutes and check the load balancing page, under the Monitoring tab to see stats.

Meantime if you check the Instance group Web-01, you will see more instances are being deployed.


Since 10 connections didn’t give much stress to the environment. I have decided to increase the connections.

Now the results have been changed as below.


That’s all. Feel free to post your comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *