Google Cloud (GCP)

8 Mins Read

Spotlight: All That You Have to Know About GCP Load Balancer

User traffic is divided across several instances of your applications using a load balancer. Load balancing lowers the possibility that your apps will encounter performance problems by distributing the load.

Features of GCP Load Balancer

  • Global with single anycast IP

Offers automated multi-region failover in addition to cross-region load balancing. In response to variations in user numbers, network traffic, backend health, and other relevant factors, cloud load balancing responds instantly.

  • Software-defined with flexibility

A fully distributed, software-defined, managed solution for all of your traffic is called cloud load balancing. Enable Cloud Load Balancing for all of your UDP, TCP/SSL, and HTTP(S) traffic.

 

  • Seamless autoscaling

As your user base and traffic increase, scale easily manages massive, unforeseen, and sudden spikes in traffic by rerouting it to other parts of the globe that have enough capacity. In seconds, go from zero to full throttle.

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Types of GCP Load Balancer

  • Application Load Balancer

You can run and scale your services with the Application Load Balancer, a proxy-based Layer 7 load balancer. The Application Load Balancer distributes HTTP and HTTPS traffic to external backends connected via the internet or hybrid connectivity, as well as backends hosted on a range of Google Cloud platforms, including Compute Engine, Google Kubernetes Engine (GKE), Cloud Storage, and Cloud Run.

 

 

  • Proxy Network Load Balancer

Layer 4 reverse proxy load balancers, also known as proxy network load balancers, are used to distribute TCP traffic to backends in other cloud environments or within your Google Cloud Virtual Private Cloud (VPC) network. TCP is used to forward traffic to the closest backend after it is terminated at the load balancing layer.

With or without SSL, proxy network load balancers are only meant to handle TCP traffic. We advise using an Application Load Balancer in place of HTTP(S) traffic.

  • Passthrough Network Load Balancer

Regional Layer 4 passthrough load balancers are known as passthrough network load balancers. Traffic is divided among backends in the load balancer’s region by these load balancers. Passthrough Network Load Balancers are not proxies, despite their name. Backend virtual machines (VMs) receive load-balanced packets with their source and destination IP addresses, protocol, and, if port-based, source and destination ports unaltered. At the backends, load-balanced connections are closed. Instead of passing via the load balancer, responses from the backend virtual machines reach the clients directly. This is known as a direct server return (DSR) in the industry.

  • Choose a Load Balancer

You must first decide what kind of traffic your load balancers must handle before choosing which Cloud Load Balancing product to utilize. Generally speaking, if your applications require a flexible feature set and handle HTTP(S) traffic, you should select an application load balancer. To implement TLS offload, TCP proxy, or support for external load balancing to backends in several regions, you would select a proxy Network Load Balancer. In order to maintain client source IP addresses, eliminate proxy overhead, and handle more protocols like UDP, ESP, and ICMP, you would also select a passthrough network load balancer.

Traffic Type in GCP Load Balancer

Another thing to take into account when choosing a load balancer is the kind of traffic your load balancer must manage.

 

Load balancer type Traffic type
Application Load Balancers HTTP or HTTPS
Passthrough Network Load Balancers TCP or UDP

 

ESP, GRE, ICMP, and ICMPv6 are among the additional IP protocol traffic that the external load balancers support.

Proxy Network Load Balancers TCP with optional SSL offload

 

Internal Load Balancing Versus External Load balancing

Load balancers from Google Cloud can be set up internally or externally:

External load balancers: Traffic from the internet is distributed to your Google Cloud Virtual Private Cloud (VPC) network via external load balancers.

Internal load balancers disperse traffic from clients connected to your VPC network via Cloud VPN, Cloud Interconnect, or VPC Network Peering or from clients in the same VPC network as the load balancer.

Global versus Regional Load balancing

  • A global load balancer or Cross-region load balancer

If you want your load balancer to be distributed across multiple regions or globally, go for a cross-region load balancer or a global load balancer. When your application or content is dispersed across multiple regions or when you want the flexibility to add multi-region backends as your application expands into new geographies, these load balancers are ideal. They can also distribute traffic to backends across multiple regions.

  • Regional load balancer

When you only need backends in one region, when IPv4 termination is all that is needed (rather than IPv6), or when traffic must remain in a specific region due to jurisdictional compliance, go with a regional load balancer.

Steps for creating Instance Group, Instance Template, Health check and GCP Load balancer

Create Instance Template

Log in to the console and first create an instance template, which we will require while creating the instance group and load balancer.

  • Go to the Menu and search for Compute engine. Under the compute engine, select instance template. Then click on CREATE INSTANCE TEMPLATE.

GCP Load Balancer: Step 1

Give the template name, then select the following options:

  1. Location – Global
  2. Machine Configuration – N1
  3. Firewall – Allow HTTP traffic and Allow HTTPS traffic
  4. Keep the rest as it is.
  5. And then click on CREATE

GCP Load balancer Step-2

GCP Load balancer: Step 3

GCP Load Balancer Step -4

Create Instance Group

Go to the Menu and search for Compute engine. Under the compute engine, select instance group.

Click the CREATE INSTANCE GROUP.

Please fill in the details below:

  1. Name: Instancegroup
  2. Instance template – Select the instance template that we have created.
  3. Location – Single Zone and select the region
  4. Autoscaling – ON: add and remove instances to the group
  5. Maximum number of instances – 2
  6. Minimum number of instances – 5

We can keep the rest as it is. Now go to self-healing and create the health check as below –

Create health check

Once you click on Create a health check,  give the name of the health check and keep the rest as it is. Click on SAVE. This will create a health check. Select the same from the health check dropdown.

Once you select the health check, then click on the CREATE button for instance group.

You will get the below page. We must wait for some for the instance group to get created.

Once the instance group is created, you will find two instances created. To check the same, go to the Menu -> Compute Engine -> VM instances.

Creating Load Balancer

Click on CREATE LOAD BALANCER

Click on Application Load Balancer – Start Configuration.

In the next step, select the options shown below and click on continue

Select the Frontend configuration and give the name. Please keep the rest as it is. Select the Backend configuration.

Click on Backend configuration and then click on CREATE a BACKEND SERVICE.

Once you click on Create a backend service, you need to fill in the below details:

  1. Name: demobc
  2. under Backends – Instance Group
  3. – Select the instance group that you have created.
  4. Port number – 80
  5. Health check – Select the health check we created.
  6. then click on Create

Once you click on Create, you will get the backend service name. Please select that and click on ok.

You will get the following page –

Now Click on the routing policy and keep it as it is. We are not supposed to take any action on this section.

Click on the next tab – Review and Finalize and then click on Create. Please also provide the name of the load balancer. This will require at least 5 mins to create the Load balancer.

After creating the load balancer, it will show the following page –

Now, we must check whether all the instances in the instance group are healthy. So, we have to follow the below steps.
1.         Click on the Load balancer name as shown above. A page will open.
2.         Click on the instance group. This will show the status of the instances, whether they are healthy or unhealthy.

To make all the instances healthy, we must install some servers on them, such as nginx or Apache2.

We will install nginx on instancegroup-fcmj and Apache2 on instancegroup-r285. This will make both instances healthy and also help us check whether our Load balancer works or not.

So, we must follow the below steps.

Go to the Menu, select Compute Engine, and select VM instances. Screenshot is below –

You will get the below page –

 

Install Nginx and Apache2 server.

Select the first instance – instancegroup-fcmj and install nginx on it. Please click on SSH on the said instance and run the below commands to install nginx.

Now, to check whether the load balancer is working properly or not, we will copy the IP address from the front end and paste it into the browser. This will show the nginx page and Apache2 page when you refresh the same.

Go to the load balancers and click on the load balancer we created.

Copy the IP address as shown below – Do not copy 80.

We must paste the same in the browser for this IP to check the results.

Hope this blog on GCP Load Balancer is beneficial for all Cloud Enthusiasts.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, Microsoft Gold Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, and many more.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.

WRITTEN BY Babajan Tamboli

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!