Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create multiple web server instances
/ 40
Configure the load balancing service
/ 30
Create the target pool and forwarding rule
/ 30
In this hands-on lab you learn how to set up a passthrough network load balancer (NLB) running on Compute Engine virtual machines (VMs). A Layer 4 (L4) NLB handles traffic based on network-level information like IP addresses and port numbers, and does not inspect the content of the traffic.
There are several ways you can load balance on Google Cloud. This lab takes you through the setup of the following load balancers:
You are encouraged to type the commands yourself, which can help you learn the core concepts. Many labs include a code block that contains the required commands. You can easily copy and paste the commands from the code block into the appropriate places during the lab.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Set the default region:
In Cloud Shell, set the default zone:
Learn more about choosing zones and regions in Compute Engine's Regions and zones documentation.
For this load balancing scenario, you create three Compute Engine VM instances and install Apache on them, then add a firewall rule that allows HTTP traffic to reach the instances.
The code provided sets the zone to tags
field lets you reference these instances all at once, such as with a firewall rule.
These commands also install Apache on each instance and give each instance a unique home page.
Create a virtual machine, www1
, in your default zone using the following code:
Create a virtual machine, www2
, in your default zone using the following code:
Create a virtual machine, www3
, in your default zone.
Create a firewall rule to allow external traffic to the VM instances:
Now you need to get the external IP addresses of your instances and verify that they are running.
Run the following to list your instances. You'll see their IP addresses in the EXTERNAL_IP
column:
Verify that each instance is running with curl
, replacing [IP_ADDRESS] with the external IP address for each of your VMs:
Click Check my progress to verify that you've created a group of web servers.
When you configure the load balancing service, your virtual machine instances receives packets that are destined for the static external IP address you configure. Instances made with a Compute Engine image are automatically configured to handle this IP address.
Create a static external IP address for your load balancer:
Output:
Add a legacy HTTP health check resource:
Click Check my progress to verify that you've created an L4 Network Load Balancer that points to the web servers.
A target pool is a group of backend instances that receive incoming traffic from external passthrough NLBs. All backend instances of a target pool must reside in the same Google Cloud region.
Run the following to create the target pool and use the health check, which is required for the service to function:
Add the instances you created earlier to the pool:
Next you'll make the forwarding rule. A forwarding rule specifies how to route network traffic to the backend services of a load balancer.
Add a forwarding rule:
Click Check my progress to verify that you've created the target pool and a forwarding rule.
Now that the load balancing service is configured, you can start sending traffic to the forwarding rule and watch the traffic be dispersed to different instances.
Enter the following command to view the external IP address of the www-rule forwarding rule used by the load balancer:
Access the external IP address:
Show the external IP address:
Use the curl
command to access the external IP address, replacing IP_ADDRESS
with an external IP address from the previous command:
The response from the curl
command alternates randomly among the three instances.
If your response is initially unsuccessful, wait approximately 30 seconds for the configuration to be fully loaded and for your instances to be marked healthy before trying again.
Use Ctrl + C to stop running the command.
In this lab, you have built a Network Load Balancer and practiced sending traffic to a forwarding rule and watched the traffic get distributed to different instances.
Refer to the following guides to learn more:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated July 17, 2025
Lab Last Tested July 17, 2025
Copyright 2025 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one