Skip to main content

Choosing the Right Cloud Load Balancer Type

Learn how GCP external and internal load balancers differ, build one of each, and pick the right type for public, regional or VPC-only traffic.

38 Terms

Overview and What You Will Learn

Google Cloud does not have one load balancer, it has a family. To choose, answer three questions: who calls the service (the public internet or only your VPC), what protocol it speaks (HTTP(S) or raw TCP/UDP), and whether traffic should be served globally or inside one region. The wrong answer is a security problem as well as a performance one, because it can expose an internal service to the internet.

In this lab you will:

  • Run a small web tier and put a global external Application Load Balancer in front of it
  • Put an internal passthrough Network Load Balancer in front of a second copy of the tier
  • Prove from a client VM and from your laptop that one is public and one is private
  • Use a decision table to map any workload to the right type

Why This Matters in Production

A team builds an internal microservice that only other services should call, but puts it behind an external load balancer because that is the tutorial they followed. It sits on the public internet until a security review finds it months later. A platform team at a company like Shopify or Grab makes the load balancer type part of the design review, because the scheme (external or internal) is what decides who can reach the service.

Core Principles

GCP load balancers differ on two axes: the layer (Application load balancers work at HTTP(S), Network load balancers at TCP/UDP) and the reach (external to the internet, or internal to a VPC). Reach can be global or regional for external types, and is regional for internal types.

flowchart TD Q{Who calls
the service?} -->|Internet| E{Protocol?} Q -->|Only the VPC| I{Protocol?} E -->|HTTP or HTTPS| EA([External Application LB
global or regional]) E -->|TCP or UDP| EN([External Network LB]) I -->|HTTP or HTTPS| IA([Internal Application LB]) I -->|TCP or UDP| IN([Internal passthrough
Network LB]) classDef q fill:#DBEAFE,color:#1E293B classDef pub fill:#F97316,color:#FFFFFF classDef priv fill:#10B981,color:#FFFFFF class Q,E,I q class EA,EN pub class IA,IN priv
Type Best for
Global external Application LB Public web apps, one anycast IP, users routed to the nearest healthy region
Regional external Application LB Public web apps that must stay in one region for compliance or cost
External passthrough Network LB Public TCP or UDP services that need the original client IP
Internal Application LB Private HTTP(S) between microservices in a VPC
Internal passthrough Network LB Private TCP or UDP services in a VPC

Google has renamed these products over time. Older material calls them HTTP(S), TCP Proxy and Network load balancers, so match on the scheme (external or internal) and layer, not just the name. Global reach uses Premium Network Tier, and regional external load balancers can use Standard Tier.

Detailed Step-by-Step Practical Lab

Milestone 1: Create the Project and a Web Tier

You will build two identical managed instance groups from one template: one for the public load balancer and one for the internal one. Using separate groups avoids sharing a backend between incompatible load balancer types.

Bash
export PROJECT_ID=lb-lab-$(date +%s | tail -c 6)
export REGION=asia-south1
export ZONE=asia-south1-a
gcloud projects create $PROJECT_ID --name="Load Balancer Lab"
gcloud config set project $PROJECT_ID
gcloud billing projects link $PROJECT_ID --billing-account=0A1B2C-3D4E5F-6A7B8C
gcloud services enable compute.googleapis.com
gcloud compute instance-templates create web-template \
--machine-type=e2-small \
--image-family=debian-12 \
--image-project=debian-cloud \
--tags=web \
--metadata=startup-script='#! /bin/bash
apt-get update
apt-get install -y nginx
echo "served by $(hostname)" > /var/www/html/index.html'
gcloud compute instance-groups managed create web-mig-public \
--template=web-template --size=2 --zone=$ZONE
gcloud compute instance-groups managed create web-mig-internal \
--template=web-template --size=2 --zone=$ZONE
gcloud compute instance-groups set-named-ports web-mig-public \
--named-ports=http:80 --zone=$ZONE

The VMs install nginx at boot, so they need outbound internet access. Wait about two minutes for the startup script to finish.

Milestone 2: Allow Health Check Traffic

Load balancer health checkers come from Google ranges, and the default firewall blocks them. Without this rule the backends are reported unhealthy and the load balancer returns errors.

Bash
gcloud compute firewall-rules create allow-health-checks \
--network=default \
--direction=INGRESS \
--allow=tcp:80 \
--source-ranges=130.211.0.0/22,35.191.0.0/16 \
--target-tags=web
Milestone 3: Build a Global External Application Load Balancer

This public load balancer has a single global IP address, a health check, a backend service, a URL map, a proxy and a forwarding rule.

Bash
gcloud compute addresses create lb-ip-public --ip-version=IPV4 --global
gcloud compute health-checks create http hc-web --port=80 --request-path=/
gcloud compute backend-services create be-web-public \
--load-balancing-scheme=EXTERNAL_MANAGED \
--protocol=HTTP \
--port-name=http \
--health-checks=hc-web \
--global
gcloud compute backend-services add-backend be-web-public \
--instance-group=web-mig-public \
--instance-group-zone=$ZONE \
--global
gcloud compute url-maps create lb-map-public --default-service=be-web-public
gcloud compute target-http-proxies create lb-proxy-public --url-map=lb-map-public
gcloud compute forwarding-rules create fr-public \
--load-balancing-scheme=EXTERNAL_MANAGED \
--network-tier=PREMIUM \
--address=lb-ip-public \
--global \
--target-http-proxy=lb-proxy-public \
--ports=80
Bash
# Test from anywhere. Allow a few minutes for the load balancer to provision
export LB_IP=$(gcloud compute addresses describe lb-ip-public --global --format='value(address)')
curl -s http://$LB_IP
# served by web-mig-public-abcd
Tip

If you get a 502 or "no healthy upstream", check the health check firewall rule and the backend health with gcloud compute backend-services get-health be-web-public --global.

Milestone 4: Build an Internal Passthrough Network Load Balancer

An internal passthrough load balancer has no proxy and no public address. It gets a private IP from a subnet, and is reachable only from the VPC and networks connected to it.

Bash
gcloud compute health-checks create tcp hc-internal --port=80
gcloud compute backend-services create be-internal \
--load-balancing-scheme=INTERNAL \
--protocol=TCP \
--health-checks=hc-internal \
--region=$REGION
gcloud compute backend-services add-backend be-internal \
--instance-group=web-mig-internal \
--instance-group-zone=$ZONE \
--region=$REGION
gcloud compute forwarding-rules create fr-internal \
--load-balancing-scheme=INTERNAL \
--network=default \
--subnet=default \
--region=$REGION \
--ip-protocol=TCP \
--ports=80 \
--backend-service=be-internal \
--backend-service-region=$REGION

The key difference is --load-balancing-scheme=INTERNAL together with a subnet. Nothing about this setup has a public address.

Milestone 5: Prove the Difference in Reachability

Compare what each load balancer exposes, then call the internal one from inside and outside the VPC.

Bash
gcloud compute forwarding-rules list \
--format="table(name, IPAddress, loadBalancingScheme, region.basename())"
export ILB_IP=$(gcloud compute forwarding-rules describe fr-internal \
--region=$REGION --format='value(IPAddress)')
# From your laptop: this should time out, because the address is private
curl -s --max-time 5 http://$ILB_IP || echo "not reachable from the internet"
# From a client VM inside the VPC: this works
gcloud compute instances create client-vm \
--zone=$ZONE --machine-type=e2-micro \
--image-family=debian-12 --image-project=debian-cloud
gcloud compute ssh client-vm --zone=$ZONE \
--command="curl -s http://$ILB_IP"
# served by web-mig-internal-wxyz
Milestone 6: Clean Up

Forwarding rules and addresses cost money while they exist. Deleting the project removes everything created in this lab.

Bash
gcloud projects delete $PROJECT_ID --quiet

Production Best Practices & Common Pitfalls

  1. Decide reach before anything else. If a service must never be public, only use internal load balancer schemes for it.
  2. Use the global external Application LB for public web apps. One anycast IP, TLS termination and routing to the closest healthy backend.
  3. Use regional types when data must stay in a region. They trade global reach for locality.
  4. Use passthrough Network LBs when you need original client IPs or non-HTTP protocols.
  5. Always allow health check ranges. 130.211.0.0/22 and 35.191.0.0/16 must be allowed to reach backends on the health check port.
  6. Match health checks to the backend. Use HTTP checks on a path for web apps and TCP checks to confirm a port is open.
  7. Protect public endpoints. Put Cloud Armor and TLS in front of external load balancers.
Common Mistake

Putting an internal-only service behind an external load balancer. It becomes reachable from the internet. For anything that should stay private, confirm the forwarding rule uses the INTERNAL scheme and has no external address.

Tip

Name resources with their scope, such as fr-internal-mumbai or fr-public-global, so a review of gcloud compute forwarding-rules list shows exposure at a glance.

Remember

Internal means reachable from the VPC and anything connected to it by peering, VPN or Interconnect, not only from the same subnet.

Quick Reference & Troubleshooting Commands

Command Description
gcloud compute addresses create --global Reserve a global external IP
gcloud compute backend-services create --load-balancing-scheme=INTERNAL Create an internal backend service
gcloud compute health-checks create http Create an HTTP health check
gcloud compute forwarding-rules list Show every load balancer entry point
gcloud compute backend-services get-health NAME Show backend health
Symptom Likely cause and fix
502 from the external LB Backends unhealthy, allow health check ranges and check the app
Backends show UNHEALTHY Wrong port or path in the health check, or the firewall is blocking
Internal LB times out from another region Global access is off, enable it on the forwarding rule
Named port error on add-backend Instance group missing the named port, run set-named-ports

Resources

Artifact Registry

Google Cloud's current, unified package and container image storage service, the successor to the older Container Registry. It supports container images alongside language packages like npm, Maven, and Python packages in one service, and supports cleanup policies to automatically remove old, untagged image versions.

BigQuery

Google Cloud's serverless data warehouse for analytics, priced based on the volume of data a query actually scans rather than pre-provisioned compute capacity. Selecting only needed columns and querying a properly partitioned table's relevant date range are the two highest-impact levers for controlling BigQuery cost.

Bigtable (GCP)

A wide-column NoSQL database built for very high throughput at extremely low latency, suited to time-series data, IoT telemetry, and analytics workloads with massive write volume. It is a specialized tool distinct from Firestore's document model or Cloud SQL's relational model.

Billing Account (GCP)

A separate object from a Project that holds the actual payment method for Google Cloud usage. One Billing Account can be linked to many Projects, all of whose usage is billed to that same account, letting a company centralize payment while individual Projects retain their own separate IAM control over resources.

Cloud Armor

A security policy service attached to a Global External HTTP(S) Load Balancer, filtering malicious requests before they reach the backend. It supports rate-based rules blocking a single source IP exceeding a request threshold, and preconfigured WAF rules blocking common attack patterns like SQL injection, Google's equivalent of AWS WAF or Azure WAF.

Cloud Functions (GCP)

Google Cloud's event-driven, single-purpose compute service, the most granular and shortest-lived compute unit in GCP's compute spectrum. It fits a narrow niche compared to Cloud Run - a specific triggered action like resizing an uploaded image, rather than a full application with multiple routes and business logic.

Cloud Load Balancing

Google Cloud's family of load balancing products, spanning Global External HTTP(S) Load Balancers (public, distributed globally via a single IP), Regional External Load Balancers, and Internal Load Balancers reachable only from within the VPC. The right type depends on traffic type and whether the backend should ever be reachable from the public internet.

Cloud Logging

Google Cloud's service for collecting, storing, and querying log data from every GCP service and custom applications. Its query filter syntax lets logs be narrowed by resource, severity, and specific field values, and Log Sinks can route matching logs to BigQuery, Cloud Storage, or Pub/Sub for long-term retention beyond the default window.

Cloud Monitoring

Google Cloud's metrics, dashboards, and alerting service. An alert policy requires a Notification Channel explicitly attached to actually notify someone when it fires - without one, the policy still evaluates and logs its own firing history, but nobody is ever told, a common and easy-to-miss misconfiguration.

Cloud NAT

A service providing outbound-only internet connectivity for resources with no external IP address, GCP's equivalent of an AWS or Azure NAT Gateway. Cloud NAT requires a Cloud Router in the same region and provides zero inbound connectivity capability - a resource behind it remains completely unreachable from the internet.

Cloud Run

A fully managed, serverless platform for running containerized applications, scaling automatically to zero when idle and billing only for actual invocations. It combines the flexibility of running any container with zero OS management overhead, making it the right default for a standard stateless containerized web service.

Cloud SQL

Google Cloud's managed relational database service, supporting MySQL, PostgreSQL, and SQL Server. It is the right default for a traditional relational workload with moderate scale needs, handling patching, backups, and replication automatically without requiring OS-level access to the underlying database server.

Cloud Spanner

A globally distributed, strongly consistent relational database offering both SQL semantics and horizontal scalability beyond what a single Cloud SQL instance can provide. It is the right choice specifically when a workload needs both relational query capability and massive scale simultaneously, not simply because a workload feels large or important.

Cloud Storage Bucket

The top-level container for objects in Google Cloud Storage, GCP's object storage service equivalent to AWS S3 or Azure Blob Storage. Every object uploaded to Cloud Storage must belong to exactly one bucket, and bucket-level settings control default storage class, location, and access permissions for everything inside it.

Cloud VPN (GCP)

A service connecting an on-premises network to a GCP VPC over an encrypted tunnel, similar to VPN Gateway in Azure or a Site-to-Site VPN in AWS. It requires a Cloud Router as its foundation and is distinct from VPC Network Peering, which connects two GCP VPCs directly rather than an external network.

Compute Engine

Google Cloud's Infrastructure-as-a-Service offering, providing full virtual machines with complete OS-level control. It is the right choice specifically when a workload needs custom software, specific OS configurations, or hardware-level access that GKE and Cloud Run don't expose.

Error Reporting (GCP)

A Google Cloud operations service that automatically aggregates and groups application errors from logs and instrumented code, surfacing recurring error patterns and their frequency without requiring manual log searching for each individual occurrence.

Firestore

A serverless NoSQL document database built for mobile and web application data, flexible schemas, and real-time client synchronization. It is not a strong fit for workloads needing complex relational joins or multi-row transactions across unrelated entities, which point instead to Cloud SQL or Spanner.

GCP Audit Log

A specific category of Cloud Logging entry recording administrative actions and data access. Admin Activity logs (configuration changes) are always enabled and cannot be disabled; Data Access logs (who read or wrote actual data) are disabled by default for most services and must be explicitly enabled before that history exists.

GCP Firewall Rule

A rule defined at the VPC level controlling inbound or outbound traffic, applied using network tags or Service Accounts on instances rather than being tied to a specific subnet boundary. A firewall rule only affects VMs carrying the exact matching tag or identity - a VM without it is entirely unaffected, silently, with no error to flag the mismatch.

GCP Folder

An optional grouping node in the GCP resource hierarchy, sitting between the Organization and individual Projects. Folders are commonly used to group Projects by team, department, or environment, letting IAM permissions and Organization Policies be applied once at the Folder level rather than repeated across every Project inside it.

GCP IAM Role Types

Google Cloud IAM roles come in three types: Basic roles (Owner, Editor, Viewer) which are broad and legacy; Predefined roles curated by Google and scoped to a specific service's specific needs; and Custom roles built from individual permissions for access needs a predefined role doesn't precisely match.

GCP Organization

The top-level node in Google Cloud's resource hierarchy, tied to a Google Workspace or Cloud Identity domain. An Organization contains Folders and Projects, and policies or IAM permissions set at this level automatically apply to everything beneath it across the entire company.

GCP Project

The fundamental unit of organization in Google Cloud - every resource belongs to exactly one Project, which serves as the boundary for billing, IAM permissions, and API enablement. A Project has a permanent, globally unique Project ID chosen at creation and never changeable, distinct from its display name which can be updated freely.

GCP Quota

A default limit on how much of a specific resource (like VM CPUs or API calls) can be used per Project per region, designed to prevent runaway costs and protect shared infrastructure. Quotas can be checked and increased through the Console ahead of a known future need, such as a planned launch event.

GCP Storage Class

A pricing and access tier for Cloud Storage objects - Standard, Nearline, Coldline, or Archive - trading lower storage cost against higher retrieval cost and a longer minimum storage duration. Deleting or overwriting an object before its class's minimum duration elapses still bills as if it were stored the full minimum period.

GKE Autopilot

A mode of Google Kubernetes Engine where Google manages node provisioning, sizing, and patching entirely - you define workloads, and nodes appear automatically to run them, billed per pod resource request rather than per node. It is the lower-effort default for most containerized workloads, versus Standard mode's direct node pool control.

Managed Instance Group

A group of identical Compute Engine VMs created from an Instance Template and managed as a single unit, GCP's equivalent of an AWS Auto Scaling Group or Azure VM Scale Set. A Managed Instance Group can autoscale based on a metric like CPU utilization, adding or removing instances automatically within configured minimum and maximum bounds.

Network Tag (GCP)

A freeform string label attached to a Compute Engine VM at creation time, used to target firewall rules to specific VMs. Network tags are simple but can be forgotten or misspelled at scale, which is why Service Account-based targeting is often preferred for anything security-critical in a growing fleet.

OS Login

A Compute Engine feature that ties SSH access to a user's actual Google Identity and IAM permissions, rather than manually managing individual SSH public keys per VM. Enabling OS Login means revoking a departing employee's GCP access also immediately revokes their SSH access to every VM, with no separate key cleanup needed.

Organization Policy (GCP)

A constraint applied at the Organization, Folder, or Project level that restricts what resources are allowed to look like across everything beneath that level - for example, blocking external IP addresses on VMs or restricting allowed regions. Unlike IAM, which controls who can act, Organization Policy controls what configurations are permitted.

Persistent Disk (GCP)

The block storage attached to a Compute Engine VM, equivalent to an AWS EBS volume or Azure Managed Disk. Persistent Disks come in zonal (replicated within one zone, lower cost) and regional (synchronously replicated across two zones, survives a single zone failure) variants.

Security Command Center

Google Cloud's security posture management service, continuously scanning deployed resources against security best practices and surfacing specific, severity-ranked findings - like a publicly accessible storage bucket - rather than a single opaque score. Findings should be prioritized by actual severity, not treated as a count to minimize.

Service Account (GCP)

An identity used by applications, VMs, and automated processes to authenticate to Google Cloud APIs, rather than by a human user. A Service Account is itself also a resource with its own IAM permissions, and can be attached directly to a VM or impersonated temporarily, both safer alternatives to downloading its long-lived JSON key file.

Shared VPC

A configuration where one Project (the host) owns a VPC network, while other Projects (service projects) attach to it and deploy resources using its subnets. This centralizes network administration in the host Project while letting individual teams in service Projects still manage their own resources independently.

Spot VM (GCP)

A Compute Engine VM using Google's spare, unused capacity at a steep discount, with the trade-off that Google can reclaim the instance with short notice. Spot VMs are appropriate only for fault-tolerant, interruption-tolerant workloads like batch processing, never for customer-facing services needing reliable availability.

VPC (GCP)

A Virtual Private Cloud in Google Cloud is a global resource by default, unlike the regional VPC or VNet model in AWS or Azure - a single GCP VPC can span every region, with individual subnets defined per-region inside it. The default auto-mode VPC pre-creates a subnet in every region, while a custom-mode VPC starts empty until subnets are deliberately defined.

VPC Network Peering

A direct connection between two separate VPCs, potentially in different Projects or Organizations, with traffic never touching the public internet. Peering must be established from both sides to become active, and is explicitly non-transitive - if VPC A peers with B, and B peers with C, A cannot reach C without its own direct peering connection to C.

Explore More in GCP Networking and Connectivity

All 6 Topics

Frequently Asked Questions

Is Choosing the Right Cloud Load Balancer Type free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Choosing the Right Cloud Load Balancer Type topic cover?

Learn how GCP external and internal load balancers differ, build one of each, and pick the right type for public, regional or VPC-only traffic.

Found a mistake, an outdated step or a broken link?