Mastering Traffic: A Deep Dive into GCP Load Balancing
In the world of cloud architecture, high availability isn’t just a goal—it’s a requirement. Google Cloud Platform (GCP) offers a sophisticated suite of Load Balancing services designed to handle everything from a small internal microservice to a global web application serving millions of users. But with so many options—Global, Regional, External, Internal, L4, and L7—how do you choose the right one?
The fundamental distinction in GCP Load Balancing lies in the scope and the network layer. Global Load Balancers leverage Google’s premium global network fiber, using a single Anycast IP address to route users to the nearest healthy backend across the globe. This is the “magic” of Google’s infrastructure: a user in London and a user in Tokyo can hit the same IP, yet be served by data centers in their respective regions.
On the other hand, Regional Load Balancers are confined to a specific GCP region. These are often used for compliance (keeping data within a border), lower-cost networking (Standard Tier), or internal communication between services that don’t need to face the public internet. Understanding these nuances is the hallmark of a Professional Cloud Architect, ensuring your application is not only performant but also cost-optimized and resilient.
Study Guide: GCP Load Balancing Architecture
The Analogy: The Global Airport vs. The Local Bus Station
Think of Global Load Balancing like a massive international airline hub. No matter where you are in the world, you book a ticket through one central system (the Anycast IP). The airline then intelligently routes you through their private global network to the most efficient destination. Regional Load Balancing is like a local city bus system. It’s highly efficient and necessary, but it only operates within the city limits (the Region). If you want to go to another city, you need a different system.
Detailed Explanation
1. Global Load Balancers (Layer 7 & Layer 4 Proxy)
- HTTP(S) Load Balancing: Layer 7. Supports IPv4/IPv6, SSL termination, and URL-based routing. Perfect for web apps.
- SSL Proxy: Layer 4. For non-HTTP traffic with SSL (e.g., specific database protocols).
- TCP Proxy: Layer 4. For non-SSL TCP traffic.
- Key Feature: Uses Anycast IP. One IP to rule them all.
2. Regional Load Balancers
- External Network Load Balancing: Layer 4 (TCP/UDP). Pass-through (not a proxy). Traffic hits the backend directly with the source IP intact.
- Internal Load Balancing (L4 & L7): Private load balancing for internal microservices. Does not have a public IP.
Real-World Scenarios
- Scenario A: You are launching a global e-commerce site.
Solution: Global External HTTPS Load Balancer to ensure low latency for users worldwide and integrated Cloud CDN support. - Scenario B: A legacy application uses a custom TCP protocol that isn’t HTTP.
Solution: Global TCP Proxy (if global) or Regional Network LB (if traffic is localized). - Scenario C: A multi-tier app where the web front-end talks to a private API.
Solution: Internal HTTP(S) Load Balancer for the API tier to keep traffic within the VPC.
Comparison Table: GCP vs. AWS
| Feature | GCP Global (HTTPS) | GCP Regional (Network) | AWS Equivalent |
|---|---|---|---|
| OSI Layer | Layer 7 | Layer 4 | ALB (Regional) / Global Accelerator |
| IP Address | Single Global Anycast IP | Regional IP | Regional VIPs / Anycast via Global Accel |
| Proxy vs Pass-thru | Proxy | Pass-through | ALB (Proxy) / NLB (Pass-through) |
| SSL Termination | Yes, at the Edge | No (at backend) | ALB (Yes) / NLB (at backend) |
Interview Questions & Answers
- Q: What is the main benefit of Anycast IP in GCP?
A: It allows a single IP to be advertised globally, routing users to the nearest Google edge POP, reducing latency. - Q: When would you choose Network Load Balancing over HTTPS LB?
A: When you need to support non-TCP protocols (UDP), or when you need the backend to see the original client source IP (Pass-through). - Q: Does the Global HTTPS Load Balancer support WebSockets?
A: Yes, it supports WebSockets natively. - Q: What is the difference between Premium and Standard Network Tiers?
A: Premium uses Google’s global fiber; Standard uses the public internet to reach the region. Global LB requires Premium Tier. - Q: How does GCP handle session affinity?
A: Via Client IP, Cookie-based, or Generated Cookie affinity. - Q: Can an Internal Load Balancer span multiple regions?
A: No, Internal LBs are regional resources. - Q: What is a “Backend Service”?
A: A configuration resource that defines how the LB distributes traffic to backend groups (Instance Groups or NEGs). - Q: How do you perform a blue/green deployment with GCP LB?
A: By using Weighted Backend Groups or updating the URL map to point to different backend services. - Q: What is a NEG (Network Endpoint Group)?
A: A way to specify backends that aren’t just VMs, such as containers (GKE) or serverless (Cloud Run). - Q: Can the Global HTTPS LB protect against DDoS?
A: Yes, it has built-in infrastructure DDoS protection and integrates with Google Cloud Armor.
Interview Tips: Golden Nuggets
- The “Source IP” Gotcha: Remember that Global Load Balancers are Proxies. Your backend logs will show the LB’s IP, not the user’s, unless you check the
X-Forwarded-Forheader. Network LBs are pass-through, so the Source IP is preserved. - Health Checks: In GCP, health check traffic comes from specific IP ranges (
35.191.0.0/16and130.211.0.0/22). If you don’t open your firewall to these, your LB will mark all backends as unhealthy. - Certificates: Google-managed SSL certificates are only available for External HTTPS and SSL Proxy load balancers.
GCP Load Balancing Visual Decision Matrix
Figure 1: Traffic flow from Global Edge to Regional Backends.
Connects seamlessly with:
- Cloud Armor: WAF & DDoS protection.
- Cloud CDN: Cache content at the edge.
- Identity-Aware Proxy (IAP): Centralized auth.
- Cloud Storage: Serve static sites via buckets.
- Warm-up: No pre-warming required (scales instantly).
- Capacity: Millions of requests per second.
- Triggers: Autoscaling based on CPU or LB utilization.
- Ingress: Free.
- Egress: Charges based on data leaving the network.
- Rule Fees: Small hourly charge per forwarding rule.
- Tip: Use Standard Tier for Regional LBs to save on egress.
Decision Tree: When to use which?
- Is it HTTP(S) traffic?
- Yes -> External HTTPS Load Balancer (Global)
- No, it’s TCP/UDP -> Network Load Balancer (Regional)
- Is it for internal microservices only?
- Yes -> Internal Load Balancer (L4 or L7)
- Do you need SSL termination at the edge?
- Yes -> Global SSL Proxy or HTTPS LB