- Lab
- A Cloud Guru
Creating a Load Balancer to Distribute Application Network Traffic to an Application
Your team needs you to create an environment with two servers in a target pool to serve up application traffic that is being distributed through a load balancer. Your task, once you set up your environment, is to use the load balancer's IP address to make sure that both servers in your target pool are serving the application traffic. Good luck!
Path Info
Table of Contents
-
Challenge
Create Two Instances to Serve as Your Target Pool
INSTANCE 1
- Go to Compute Engine to create instance:
- Name: acloud-1
- Region: us-central1
- Zone: us-central1-b
- OS image Debian GNU/Linux
- Add a networking tag of acloud-tag.
- Paste this startup script:
#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo '<!doctypehtml><html><body><h1>acloud1</h1></body></html>' | tee /var/www/html/index.html
INSTANCE 2
- Go to Compute Engine to create instance:
- Name: acloud-2
- Region: us-central1
- Zone: us-central1-b
- OS image Debian GNU/Linux
- Add a networking tag of acloud-tag.
- Paste this startup script:
#! /bin/bash sudo apt-get update sudo apt-get install apache2 -y sudo service apache2 restart echo '<!doctypehtml><html><body><h1>acloud2</h1></body></html>' | tee /var/www/html/index.html
- Go to Compute Engine to create instance:
-
Challenge
Add Firewall Rule
-
Create firewall rule:
-
Name: acloud-firewall Targets: Specified target tags Target tags: acloud-tag Source filter: IPv4 ranges
-
Set the Source IPv4 ranges to 0.0.0.0/0, which allows traffic from any source.
-
For specified protocols and ports, select TCP and enter 80.
NOTE: It may take a few minutes for the Console to display the new firewall rule or refresh to see the rule.
-
-
Challenge
Create the Load Balancer
- Click the Navigation menu, located in the top left-hand side.
- Select Network services > Load balancing.
- Click Create Load Balancer.
- Click Start Configuration for the TCP Load Balancing option.
- Select From Internet to my VMs.
- Select Single region only.
- Select Target Pool or Target Instance.
- Click Continue.
- Enter the following information: Name: acloud-lb Region: us-central1 (Iowa)
- Select Backend configuration.
- Click Select Existing Instances.
- For VM instances, select acloud-1(us-central1-b) and acloud-2(us-central1-b). Click OK.
- Select Frontend configuration.
- For Name, enter acloud-fe.
- For IP address, select Create IP Address.
- In the Reserve a new static IP address dialog, enter acloud-ip for the Name.
- Click Reserve.
- For Port, enter 80.
- Click Done.
- Click Review and finalize (optional).
- Click Create.
- Click the acloud-lb, then choose EDIT.
- Under the Backend configuration in the Health check section, choose CREATE A HEALTH CHECK.
- Enter the following information: Name: health Protocol: HTTP Port: 80.
- Keep the given defaults for Health criteria.
- Click Save.
- Click UPDATE.
- Click UPDATE LOAD BALANCER
-
Challenge
Send Traffic to Your Instances
- Copy the IP address and place it in the URL, you will then see either acloud-1 or acloud-2 displayed. This will confirm your traffic is being served the instance webpages.
- Open Cloud Shell and execute command
while true; do curl -m1 IP_ADDRESS; done
. This will show that both of your servers are serving the application traffic to your end users.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.