A global load balancer doesn’t actually "balance" traffic in the way you’re probably thinking; it hands off traffic to the closest healthy backend, making it a global anycast service first and a load balancer second.
Let’s see how this plays out. Imagine you have a web application deployed across multiple Google Cloud regions. You want to serve users from all over the world, and you want low latency for everyone.
Here’s a simplified setup in action. We’ve got a global external HTTP(S) load balancer with backends in us-central1 (Iowa) and europe-west1 (Belgium).
# Global External HTTP(S) Load Balancer setup
resource "google_compute_global_forwarding_rule" "default" {
name = "global-lb-forwarding-rule"
ip_protocol = "TCP"
port_range = "443"
target = google_compute_url_map.default.id
ip_address = google_compute_global_address.default.address
}
resource "google_compute_global_address" "default" {
name = "global-lb-static-ip"
}
resource "google_compute_url_map" "default" {
name = "global-lb-url-map"
default_service = google_compute_backend_service.default.id
}
resource "google_compute_backend_service" "default" {
name = "global-lb-backend-service"
protocol = "HTTP"
port_name = "http"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL"
enable_cdn = false
backend {
group = google_compute_instance_group.us_central1.id
}
backend {
group = google_compute_instance_group.europe_west1.id
}
# Health check configuration
health_checks = [google_compute_health_check.default.id]
}
resource "google_compute_health_check" "default" {
name = "global-lb-health-check"
check_interval_sec = 5
timeout_sec = 5
healthy_threshold = 2
unhealthy_threshold = 2
http_health_check {
port = 80
request_path = "/"
}
}
# Instance Group in us-central1
resource "google_compute_instance_group" "us_central1" {
name = "ig-us-central1"
zone = "us-central1-a"
# ... instance configuration ...
}
# Instance Group in europe-west1
resource "google_compute_instance_group" "europe_west1" {
name = "ig-europe-west1"
zone = "europe-west1-b"
# ... instance configuration ...
}
When a user in Tokyo requests your-app.com, the request doesn’t go to Iowa or Belgium directly. Instead, it hits Google’s global network edge closest to Tokyo. This edge location, using Border Gateway Protocol (BGP) anycast, routes the request to the nearest healthy backend instance group. If the Iowa instance group is healthy and closer to Tokyo than Belgium, the traffic goes there. If Belgium becomes healthier or closer due to network conditions, traffic might shift.
The core problem this solves is global low-latency access to your application. Instead of users in Asia hitting a load balancer in Europe, they hit an edge point near them and get routed to the best available backend.
Here’s the mental model:
- Global Anycast IP: The load balancer has a single IP address that is announced from multiple Google Cloud edge locations worldwide.
- Edge Routing: When a user makes a request, their traffic is routed by BGP to the Google network edge geographically closest to them.
- Backend Selection: From that edge, the request is then forwarded to the closest healthy backend service instance across all your configured regions. This isn’t a simple round-robin; it’s determined by network proximity and backend health.
- Health Checks: Google constantly monitors the health of your backends in each region. If a backend in one region fails, traffic is automatically rerouted to healthy backends in other regions.
- Regional Load Balancers: If you don’t need global reach and only serve users within a specific continent or country, a regional load balancer is more appropriate. It has a single IP address within a specific region and distributes traffic only to backends within that region.
The magic of the global load balancer is its ability to abstract away the complexity of global routing. You point to backends in different regions, and Google’s network fabric handles the rest, ensuring users connect to the nearest healthy endpoint. It’s not about distributing load across regions; it’s about distributing users to the closest available capacity.
What most people miss is that the "load balancing" part is secondary to the "global network edge" part. The primary function is providing a single, highly available IP address that’s accessible with low latency from anywhere, with the backend selection being an intelligent routing decision based on proximity and health, not a primary distribution mechanism across geographically distant resources.
The next concept to explore is how to configure advanced traffic management rules within the global load balancer, like URL rewrites or header-based routing.