Overview and What You Will Learn
In this lab, you will create a Global External HTTP(S) Load Balancer with a health check and backend service, then compare its configuration against an internal load balancer meant only for traffic within the VPC - directly experiencing why "load balancer" in GCP is really a family of distinct products, not a single service.
Why This Matters in Production
A team builds an internal microservice meant to only ever be called by other services inside the same VPC, but configures it behind a Global External HTTP(S) Load Balancer - accidentally exposing an internal-only service to the public internet, discovered only during a security review months later. Choosing the correct load balancer type from the start is a security decision, not just a performance one.
Core Principles
GCP's load balancing products span from global, external, internet-facing options down to internal, VPC-only options - the right choice depends on traffic type, whether the backend needs to be reachable from outside the VPC at all, and whether traffic needs global or regional distribution.
+------------------------------------------+| Global External HTTP(S) Load Balancer || Public-facing, distributes globally || Single global IP address || Best for: public web applications |+------------------------------------------+| Regional External Load Balancer || Public-facing, but scoped to one region || Best for: regional compliance or latency || requirements |+------------------------------------------+| Internal Load Balancer || Reachable only from within the VPC || Best for: internal microservices, backend || tiers never meant to be public |+------------------------------------------+Detailed Step-by-Step Practical Lab
- Create a project and enable Compute Engine:
gcloud projects create gcp-lb-lab-2026 --name="Load Balancer Lab"gcloud config set project gcp-lb-lab-2026gcloud services enable compute.googleapis.com- Reserve a static global external IP for a public-facing load balancer:
gcloud compute addresses create lb-ip-public --global- Create a health check the load balancer will use to verify backend health:
gcloud compute health-checks create http health-check-web --port=80- Create a backend service and a global HTTP(S) load balancer using it:
gcloud compute backend-services create backend-web-public \ --protocol=HTTP \ --port-name=http \ --health-checks=health-check-web \ --global gcloud compute url-maps create lb-map-public \ --default-service=backend-web-public gcloud compute target-http-proxies create lb-proxy-public \ --url-map=lb-map-public gcloud compute forwarding-rules create lb-forwarding-public \ --address=lb-ip-public \ --global \ --target-http-proxy=lb-proxy-public \ --ports=80- Now create an Internal Load Balancer for a service meant to stay reachable only within the VPC:
gcloud compute health-checks create tcp health-check-internal --port=8080 gcloud compute backend-services create backend-internal-service \ --protocol=TCP \ --health-checks=health-check-internal \ --load-balancing-scheme=INTERNAL \ --region=asia-south1Note
--load-balancing-scheme=INTERNALis what specifically makes this an internal-only load balancer - there is no global IP, no public-facing proxy, and the resulting backend is reachable only from within the same VPC (or a peered/connected network), never from the public internet.
- Confirm the difference in reachability by checking each load balancer's forwarding configuration:
gcloud compute forwarding-rules list \ --filter="name~'lb-forwarding' OR name~'backend-internal'"- Clean up:
gcloud compute forwarding-rules delete lb-forwarding-public --global --quietgcloud compute target-http-proxies delete lb-proxy-public --quietgcloud compute url-maps delete lb-map-public --quietgcloud compute backend-services delete backend-web-public --global --quietgcloud compute backend-services delete backend-internal-service --region=asia-south1 --quietgcloud compute health-checks delete health-check-web health-check-internal --quietgcloud compute addresses delete lb-ip-public --global --quietgcloud projects delete gcp-lb-lab-2026 --quietProduction Best Practices & Common Pitfalls
Common MistakeConfiguring a backend service meant only for internal traffic behind a Global External Load Balancer by default, accidentally exposing it to the public internet. Always confirm
--load-balancing-scheme=INTERNAL(or the equivalent internal-only configuration) is used for any backend that should never be reachable from outside the VPC.
TipA Global External HTTP(S) Load Balancer is the right default for a public-facing web application needing traffic distributed across multiple regions - it uses a single global IP address and Google's own global network to route users to the nearest healthy backend, similar in concept to what Azure Front Door or AWS Global Accelerator provide, but natively built into GCP's core load balancing product.
- A Regional External Load Balancer trades global reach for staying within a single region - appropriate when a compliance requirement or a very region-specific latency need makes global distribution unnecessary or undesirable.
- Health checks differ by protocol and load balancer type. An HTTP health check (used for the public web load balancer) checks a specific path and expects an HTTP response; a TCP health check (used for the internal load balancer here) simply confirms a port accepts connections, a distinction worth matching to the actual backend protocol.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
gcloud compute addresses create --global |
Reserve a static global external IP |
gcloud compute backend-services create --load-balancing-scheme=INTERNAL |
Create an internal-only backend service |
gcloud compute health-checks create http |
Create an HTTP-based health check |
gcloud compute forwarding-rules list |
List active load balancer forwarding rules |