Global Traffic Distribution with Google Cloud Load Balancer:Configuration,Set up and Pricing

Reading Time: 5 minutes

In this article, you’ll learn features, Configuration set up and pricing details of Google Cloud Load Balancer.

Google cloud load balancer is fully distributed software defined managed service use to distribute user traffic across instances of an application in single region or multiple regions.

Prerequisites: This would be hands on tutorial, and you can follow along with free Google Cloud credits. Learn more about google free tier account here Google Cloud Free Credits – Google Cloud Tutorials .

Features of GCP Load Balancer

  • Health check: Cloud load balancer supports health checks. Any load balancer you create you would need to configure health checks. This is the only way load balancer can understand if an instance is healthy or not and would route traffic to only healthy instances.
  • Auto Scaling: Based on the number of incoming requests load balancer will automatically scale in or scale out instances.
  • Single anycast IP: GCP load balancer provides you will single any cast IP. This IP is used to receive traffic from multiple regions around the world.You can serve global traffic using this IP.

Cloud load balancer supports High Availability. Even if virtual machines instances go down and comes up there will be no down time and end user does not face any issues as traffic would be routed only to healthy instances.

Google load balancer enables us to create a loosely coupled architecture.

Learn more about different types of load balancers supported by google cloud refer Explore Types Of Load Balancer In GCP – Building Resilient And Highly Available Applications – Google Cloud Tutorials

Create a Load Balancer in GCP

Search “load balancing” in google cloud search console.

Load balancer create

In this demo we will create layer 7 HTTPS load balancer.

The first question to answer you need to ask yourself while create a load balancer is to create an Internet facing load balancer or to create internal load balancer to manager internal traffic in google managed traffic.

In this demo we will create Internet facing load balancer.

Next important choice is regarding load balancer traffic management.

The recommended load balancer for external HTTP workloads with globally dispersed users or backend services in multiple regions. This load balancer contains advanced traffic management features providing additional capabilities over the classic Application Load Balancer, enabling fine-grained control over how traffic is handled.

The classic Application Load Balancer is the earlier version of the global external Application Load Balancer and does not support features such as advanced traffic management.

The recommended regional external Application Load Balancer for serving content from only one geolocation (for example, to meet compliance regulations).

Inside load balancer you would need to configure 3 important steps.

  • Backend configuration: Backend is where the incoming traffic is redirected to. In our case it is Managed Instance Group. We will be sending all the traffic to MIG.
  • Host and Path Rules: In host and path rules you would configure how to redirect traffic to Backend. This is important configuration for microservices based architecture which has multiple MIG’s in Backend.
  • Frontend Configuration: Frontend is load balancer URL accessed directly by end user.

Global Load Balancer Backend Configuration

The backend we will use in this demo is managed instance group.

Click on backend configuration and select create a Backend service.

Enter a valid Name for your backend service.

Select backend type as Instance Group and protocol as HTTP.

Under Backend select your Managed instance group name and specify port number as 80.

Read more about Google Cloud Managed instance group here Google Cloud Managed Instance Group – Google Cloud Tutorials .

Next step is to configure balancing mode. It decides how the load balancer distributes requests among backend instance groups. When a backend has reached a configured maximum utilization or rate, the load balancer will direct new requests to other backends that have not reached their configured maximums. If all backends have reached their configured maximums, the load balancer will exceed them.

Google cloud supports cloud CDN. Cloud CDN caches static content closer to your users so content delivery is faster while also reducing serving costs.

Health check configuration ensures requests are redirected to only healthy instances.

Configure new health check using create a health check option. Enter valid name and description for health check.

Select protocol and TCP and port number 80.

health check configuration

Health check criteria determines how health is determined: how often to check, how long to wait for a response, and how many successful or failed attempts are decisive.

  • Check Interval:How often (in seconds) to send a health check.
  • Timeout: How long to wait (in seconds) before a request is considered a failure.
  • Healthy Threshold: How many consecutive successes must occur to mark a VM instance healthy.
  • Unhealthy Threshold: How many consecutive failures must occur to mark a VM instance unhealth.

Take defaults for other configurations and click on create.

Once the backend service is configured next step is to configure Host and path rules.

Global Load Balancer Host and Path Rules

Host and path rules decides how traffic would be redirected to backends.

In this demo all incoming requests would be redirected to managed instance group (Since we have only 1 service and 1 MIG).

In case of micro services, we can configure multiple host and path rules and redirected to multiple backends.

Host and Path rule configuration

Global Load Balancer Frontend Configuration

Last step is to configure front end for load balancer.

Enter valid name and description for front end configuration.

Select protocol as HTTP and port number as 80.

load balancer front end rules

Review all 3 steps and enter valid name for load balancer and click on create.

It will take around 10 minutes for gcp load balancer to set up.

Once the load balancer service is ready it can be accessed using IP Address.

Load balancer screen

Google Cloud Load Balancer Pricing

To estimate load balancing charges:

  • Go to the Pricing Calculator.
  • On the Cloud Load Balancing tab.
  • From the dropdown menu, select a region.
  • Enter your estimated number of forwarding rules.
  • Enter your monthly estimated amount of network traffic processed.

For most load balancing use cases, you need only one forwarding rule per load balancer.

FAQ

What types of load balancers does Google Cloud offer?

Google cloud offers HTTP(S) Load Balancing, TCP/UDP Load Balancing, and Internal TCP/UDP Load Balancing. Learn more about load balancers type Explore Types Of Load Balancer In GCP – Building Resilient And Highly Available Applications – Google Cloud Tutorials

Can Google Cloud Load Balancer handle global traffic distribution?

Yes, Google cloud supports global routing using premium tier configuration.

What is the difference between TCP/UDP Load Balancing and HTTP(S) Load Balancing?

TCP/UDP is layer 4 load balancing.ayer 4 load balancing is used to handle traffic at transport layer and network layer. Supported protocols at this layer are TCP, TLS,UDP,ICMP,ICMPV6.
Layer 7 load balancer works at application layer and used to handle traffic for Web requests/API requests.
Protocols supported at this layer includes HTTP, HTTPS

What are the health check mechanisms in Google Cloud Load Balancer?

GCP load balancer supports health checks which ensures traffic is directed to only healthy instances.

Scroll to Top