Skip to main content

Gcloud Load Balancing

alt text

Load Balancing

Overview

Overview

  • Cloud Load Balancing receives client traffic
  • The backend can be backend service or a backend bucket

Backend configuration defines:

  • How traffic is distributed.
  • Which health check to use.
  • If session affinity is use.
  • Which other services are used (such as Cloud CDN or Identity Aware Proxy)

Cloud Load Balancing can route traffic to:

  • Backend services: Managed instance groups, Network endpoint groups, Cloud Storage backend buckets

Types of load balancers

Application Load Balancer (HTTP / HTTPS)

Works as reverse proxy

alt text

Network Load Balancer (TCP/UDP/ other IP protocols)

alt text

Hybrid Load Balancing & Traffic Management

  • A hybrid strategy lets you extend Cloud Load Balancing to workloads that run on your existing infrastructure outside of Google Cloud.

The strategy could be:

  • Permanent to provide multiple platforms for your workloads
  • Temporary as you prepare to migrate your internal or external workload to Google Cloud

Usecases

alt text

alt text

alt text

Types of load balancers that support hybrid load balancing

alt text

Caveats

alt text

Traffic Management

  • Not all load balancers support traffic management
  • Wildcards are supported, but only after a forward slash. Eg: /videos/_ (valid) - /videos_ (invalid)
  • Substring matching and regular expressions are not supported.

Usecase: Distribute traffic by using URL map

alt text

alt text

alt text

Terminologies

Network endpoint groups (NEGs)

alt text

  • A configuration object that specifies a group of backend endpoints or services

  • A common use case for this configuration is deploying services in GKE.

There are 5 types of NEGs:

  • Zonal
  • Internet
  • Serverless
  • Private Service Connect
  • Hybrid connectivity

Identity Aware Proxy

alt text

  • Identity-Aware Proxy (IAP) is a cloud-native alternative to traditional VPNs that manages access to applications running in Cloud Run, App Engine, Compute Engine, and GKE.

  • IAP verifies identity and enforces authorization at the application level, eliminating broad network access and perimeter-based security. Every request is evaluated in real time, ensuring only authenticated, authorized users can reach protected resources.

  • You can configure context-aware access policies using user identity, group membership, device security, and contextual signals like location or IP address. Unlike VPNs, IAP requires no client software or network tunneling. Users access applications directly through Chrome, while IT teams centrally define and enforce access policies in one place.

Labs

Blue Green Deployment

Blue: current version of your application Green: new version of your application

In this lab, you create a regional internal Application Load Balancer with two backends. Each backend will be an instance group. You will configure the load balancer to create a blue-green deployment.

The blue deployment refers to the current version of your application, and the green deployment refers to a new application version. You configure the load balancer to send 70% of the traffic to the blue deployment and 30% to the green deployment. When you’re finished, the environment will look like this:

alt text

Steps

  1. Create VPC Network and its subnets

alt text

alt text

  1. Config firewall

alt text

alt text

  1. Create instance groups

alt text

alt text

  1. Configure load balancer

alt text

alt text

alt text

alt text

alt text

alt text

Create backend service, health check

alt text

Routes

defaultService: regions/us-west1/backendServices/blue-service
name: matcher1
routeRules:
- matchRules:
- prefixMatch: /
priority: 0
routeAction:
weightedBackendServices:
- backendService: regions/us-west1/backendServices/blue-service
weight: 70
- backendService: regions/us-west1/backendServices/green-service
weight: 30

Caching and Optimizing Load Balancing

Internal Network Load Balancers are fast

alt text

Usecases

alt text

Next hop

alt text

Next hop to a NAT gateway

alt text

Using a hub and spoke topology

alt text

Load balancing to multiple NICs

alt text

Cloud CDN ( content delivery network )

Cache Mode

alt text

CDN Interconnect

alt text

alt text

Google Cloud Armor

alt text

Cost optimized

  • Dynamically adjust resources
  • Define scaling threshold
  • Utilize custom metrics

alt text

alt text

alt text

References