Configure Load Balancer for High Availability
Set up a load balancer to distribute traffic across multiple VM instances.
Login to your google account.
Go to Compute Engine and create few virtual machines with default settings.

From left hand-side panel, select Instance Groups

- Click on “CREATE INSTANCE GROUPS”
Name the instance group
Create a new Instance Template

Name the instance template and leave the default settings

Click on save and continue
Leave the default settings and Click on create


Successfully created an instance group
Now search for load balancer

Click on Load Balancing
Now, select “CREATE LOAD BALANCER”

For now, go with “Application Load Balancer”
Click on Next
Select Public facing (it will routes requests from clients over the internet to targets)
Select Global Workloads (used when we want to deploy backends in multiple regions)
Select Global external Application Load Balancer (Load balancer with EXTERNAL_MANAGED load balancing scheme")
Click on CONFIGURE
Name your Load Balancer
For Frontend Configuration
Name your Frontend configuration

Leave the default settings
Click on Done and move to next part i.e. Backend Configuration
In Backend Configuration, we can either create a backend service or a backend bucket
- For now, I’m creating a backend service

Name the backend service
For instance group, select your previously created instance group
For port numbers, choose an unregistered port no.
For health check, create a new one

Name the health check
Leave the default settings

Click on save
Click on create
Click ok

Your backend part is done
Now move to Routing Rules
Here, our backend service is already attached so leave it as it is

Click on create
Your load balancer is ready

Try It Yourself: Go Beyond the Basics
Now that you've successfully set up a load balancer, here are a few extra steps you can try to deepen your learning:
Use Instance Templates: Instead of manually creating each virtual machine, try using an instance template to automate the creation of VMs. It saves time and ensures consistency across your instances.
Automate with Scripts: When creating virtual machines, add an automation script that prints a message like
"Hello from this server!". This way, after setting up the load balancer, you can refresh the frontend IP and see which specific instance is handling the traffic based on the message displayed. It's a fun way to visualize traffic distribution!Monitor Traffic Distribution: After setting up your load balancer, copy the frontend IP, open it in your browser, and see how traffic is routed. As you refresh, you'll notice different instances handling the traffic, showing the message you scripted earlier.
"Great work setting up your load balancer! Now, your VMs are primed to handle traffic like a pro. You’ve just boosted your cloud performance—stay tuned for even more ways to optimize and scale your GCP environment!"