Description
An Application Load Balancer (ALB) in Google Cloud Platform (GCP) intelligently distributes HTTP(S) traffic across multiple backend instances, ensuring high availability, scalability, and fault tolerance for your applications.
In this guided lab, you will build a global external HTTP load balancer that routes traffic between two VM instances running Nginx web servers. By the end, you’ll see how GCP’s load balancing service automatically balances requests and maintains service reliability.
Prerequisites
To ensure the successful completion of this lab, we highly recommend taking the following guided labs to gain the necessary understanding:
- Guided Lab: How to Launch a GCP Compute Engine Linux Instance
- Guided Lab: Setting up a Web Server on a VM Instance
- Guided Lab: Using Startup Scripts in GCP VM Instances
- Guided Lab: Reserving or Promoting a Static IP Address for a VM Instance
- Guided Lab: Creating and Managing Instance Groups in Compute Engine
Objectives
In this lab, you will:
- Launch two Compute Engine VM instances with Nginx installed via startup scripts.
- Serve unique custom HTML pages from each VM.
- Group the VMs into an Unmanaged Instance Group.
- Configure a global external HTTP load balancer with a frontend and backend service.
- Create and apply an HTTP health check to monitor backend availability.
- Verify that traffic alternates between the two web servers when accessing the load balancer’s IP.
Lab Steps
Create a Compute Engine VM Instance
1. Navigate to Compute Engine → VM instances → Create Instance.
2. Configure:
- Name: webserver-1 and webserver-2
- Machine type: e2-micro
- Boot disk: Ubuntu 24.04 LTS Minimal (x86/64, amd64 noble minimal image built on 2025‑12‑17)

- Firewall: Check Allow HTTP traffic

3. Navigate to the Advanced section.
4. Add a startup script to install Nginx and serve a unique page:
# Update system
sudo apt update -y
# Install Nginx
sudo apt install nginx -y
# Start Nginx
sudo systemctl start nginx
# Create a custom HTML page in the HTML directory
echo '<h1>Hello from Webserver-1</h1>' | sudo tee /usr/share/nginx/html/mypage.html > /dev/null
# Add the configuration directly
echo 'server {
listen 80 default_server;
server_name _;
root /usr/share/nginx/html;
location / {
index mypage.html;
}
}' | sudo tee /etc/nginx/conf.d/server.conf > /dev/null
# Remove the default site to avoid duplicate default_server errors:
sudo unlink /etc/nginx/sites-enabled/default
# Test and Reload Nginx for the changes to take effect
sudo nginx -t && sudo service nginx reload
# Enable Nginx at boot
sudo systemctl enable nginx
(Change the message for webserver-2 to “Hello from Webserver-2”)
5. Once done, click the Create button.
Wait for the VMs to finish provisioning.

Verify the Setup
1. Once the VM is running, copy its External IP address.
2. Open a browser and navigate to http://<EXTERNAL_IP>.
3. You should see the custom page: “Hello from Webserver-1” and “Hello from Webserver-2“


If the page does not load:
- Try refreshing the browser multiple times — the startup script is still running in the background and may take a moment to complete.
- Ensure the firewall rule Allow HTTP traffic is enabled.
- SSH into the VM and run:
systemctl status nginxto confirm Nginx is running.
Create an Unmanaged Instance Group
1. Go to Compute Engine → Instance groups → Create Instance Group.
2. Select Unmanaged instance group.
3. Name the group (e.g., instance-group-1).
4. Under Location, change the Zone to us-central1-c

5. Add both VM instances (webserver-1 and webserver-2) to the group.

6. Click the Create button.
Create the Load Balancer
1. Navigate to Network services → Load balancing → Create Load Balancer.
2. Choose HTTP(S) Load Balancing → Click Next → Leave other configurations at their default values → Start configuration.

Configure the Frontend and the Backend
1. Frontend configuration:
- Protocol: HTTP
- IP: Create a new static IP (recommended).

- Port: 80

2. Backend configuration:
- Backend type: Instance group

- Health check: Create a new HTTP health check (port 80).

- Select the unmanaged instance group (instance-group-1).
- Port numbers: 80

- Disable the CDN.

Review and Create
1. Review the configuration summary.
2. Add the desired Load Balancer name:

3. Click Create to provision the load balancer.

Verify the Load Balancer
1. Once provisioning completes, copy the frontend IP address.

2. Open a browser and navigate to http://<LOAD_BALANCER_IP>.
3. Refresh several times—you should see responses alternating between:
- Hello from Webserver-1
- Hello from Webserver-2

Congratulations! You have successfully created an Application Load Balancer in GCP using an Unmanaged Instance Group. This setup ensures high availability and scalability by distributing traffic across multiple VM instances. You also learned how to verify backend health and confirm traffic distribution.