Chapters

Load balancing 1: the family and how to choose

The fundamentals course (ch 33) explained what a load balancer does and put one in front of Kadé. GCP offers about ten kinds, with names that look random. They are not: each name is four separate choices. This chapter decodes the names, explains the one choice that really changes behaviour, and confirms which load balancer Kadé should have.

The front door · chapter 14 of 26 · 7 min read

Four choices make every name

Builds on33. Proxies and load balancers

#ChoiceOptionsThe question it answers
1ReachExternal · InternalWhere does the traffic come from?
2SpreadGlobal · RegionalHow widely is the load balancer distributed?
3LayerApplication (L7) · Network (L4)How much does it understand about the traffic?
4ModeProxy · PassthroughDoes it end the client's connection and open its own?

Read a name word by word and it explains itself. "Global external Application Load Balancer" is one IP worldwide, on the internet, that understands HTTP (and so must be a proxy). "Regional internal passthrough Network Load Balancer" is one region, private IP, L4 only, and does not end the connection. Not every combination exists.

GlobalspreadexternalreachApplicationlayerLoad Balancerno mode word: an Applicationload balancer is always a proxyRegionalspreadinternalreachpassthroughmodeNetworklayerLoad Balancer

Wide by design - scroll it sideways.

Try it:

1 · Reach
2 · Spread
3 · Layer
4 · Mode

Global external Application Load Balancer. Kadé's choice. One anycast IP on Google Front Ends, HTTP routing, TLS, Cloud Armor, Cloud CDN. Premium tier only.

External or internal

Shopperon the internetexternal LB34.120.88.10kade-vpcbackendskade-apia callerin the VPCinternal LB10.10.1.50workers3 VMs✕no route to a private IP
  • Run by Google
  • Your VPC
  • Allowed traffic and replies

Wide by design - scroll it sideways.

#Reached fromIPTypical use
1ExternalThe internetPublicThe front door: a public website or API. Kadé's api.kade.lk
2InternalInside your VPC, and networks connected to it (VPN, peering)Private, from a subnetService to service, such as an API spreading calls across several payment workers, never exposed to the internet

Global or regional

A global load balancer has one IP announced from Google's edge locations all over the world (anycast, Fundamentals ch 33). A regional one has an IP that belongs to one region and serves backends in that region.

GLOBAL · one anycast IP, many entry pointsREGIONAL · the IP lives in one regionShopper, ColomboVisitor, LondonPartner, SydneyGoogleedge, eachannouncing34.120.88.10backbonebackendnearesthealthyregionShopper, ColomboVisitor, LondonPartner, Sydneyasia-southeast1regional IP34.87.x.xeveryone travelsto this one region

Global: every user enters Google's network nearby and rides the backbone. Regional: every user travels to the region, over Premium or Standard tier (chapter 3).

#Choose global whenChoose regional when
1Users are in several countriesThe service and its users are in one region
2You want routing to the nearest healthy region and failover between regions from one IPA rule says traffic must stay in one region, including TLS termination
3You want Cloud CDN, or Cloud Armor edge policiesYou want Standard network tier (chapter 3), or a simpler model
For public web traffic, the global external Application Load Balancer is GCP's normal default. Pick regional on purpose, for a reason.

Application (L7) or Network (L4)

Builds on24. HTTP

L7 · reads the requestURL map rulebackendHTTPS requestHost: www.kade.lkGET /images/rice.jpgCookie: session=…L7 LBends TLSpicks by host and path/api/*kade-api-backend/images/*kade-static bucketeverything elseweb backendL4 · sees only addresses and portsbackendTCP connection203.0.113.99:51022→ 34.87.x.x:443contents: unreadableL4 LBforwardspicks by connection onlybackend abackend bbackend cno rules here:the path is insidebytes it cannot read.Any healthy one will do.
#UnderstandsCan doUsed for
1Application (L7)HTTP and HTTPS: host, path, headers, cookiesRoute by host and path, end TLS, change headers, run a WAF, cacheAnything web
2Network (L4)IP addresses, protocol, portsSpread connections across backends. That is allNon-HTTP protocols (a database, a game server, a custom TCP or UDP service), or when the load balancer should stay out of the way

Proxy or passthrough: the choice that changes behaviour

Does the load balancer end the client's connection and open a new one to the backend, or let the original connection pass straight through? Everything else follows from that.

TWO SEPARATE CONNECTIONSShopper203.0.113.99Google Front End34.120.88.10connection 1 ENDS herebackend VM10.10.1.10connection 1 (TLS)connection 2 (new)replyreply

What the backend sees

TCP source
35.191.8.20 ← Google's front end, not the client
X-Forwarded-For
203.0.113.99, 34.120.88.10 ← the real client is here
TLS
ended at the load balancer; HTTP inside
Possible here
host/path routing · Cloud Armor · header changes · CDN

The client's TCP and TLS connection ends at Google's front end. A second, separate connection goes to the backend. Because the front end holds the decrypted request, it can route it, run Cloud Armor and add headers. The backend sees the front end's address as the source, and the client's address only in X-Forwarded-For.

Show as config
client ──connection 1──▶ load balancer ──connection 2──▶ backend
backend sees: source 35.191.8.20, X-Forwarded-For: 203.0.113.99, 34.120.88.10
#ProxyPassthrough
1ConnectionsTwo: client to load balancer, load balancer to backendOne: client to backend; the load balancer only steers packets
2Source IP the backend seesThe load balancer's (35.191.x.x or a proxy-only subnet address). Real client in X-Forwarded-ForThe real client's
3HTTP routing, TLS termination, WAF, header changes, cachingPossible, because it has ended the connection and can read itImpossible: it never reads the traffic
4RepliesGo back through the load balancerGo straight from the backend to the client (direct server return)
5ProtocolsTCP (and HTTP on top)TCP, UDP, and others such as ESP and ICMP
6LayerL7 or L4Always L4: you cannot read HTTP without ending the connection
#You needUse
1HTTP routing, a WAF, TLS termination at the load balancerProxy (an Application Load Balancer)
2The backend to see the real client IP at the network levelPassthrough
3UDP or another non-TCP protocolPassthrough
4The load balancer to stay out of the connection (end-to-end TLS the backend handles)Passthrough
If you need a WAF in front of a web app, you must use a proxy, and accept that the app reads client IPs from a header (chapter 12 section 06).

Where it runs, and what your backends see

The four choices also decide where the load balancer runs. That matters for one practical reason: it sets the source address your backends see, and so the firewall rule they need.

kade-vpcGlobal external proxiesclient203.0.113.99backendsource: 35.191.x.xGoogle Front Endsoutside your VPCRegional and internal proxiesclient203.0.113.99backendsource: proxy subnetproxy-only subnetEnvoy proxiesPassthroughclient203.0.113.99backendsource: the clienthost data planesteers, never ends it
  • Run by Google
  • Your VPC
  • Allowed traffic and replies

Wide by design - scroll it sideways.

#KindRuns onBackend firewall must allow
1Global external proxiesGoogle Front Ends, outside your VPC35.191.0.0/16 and 130.211.0.0/22, for traffic and health checks
2Regional and internal proxiesEnvoy in a proxy-only subnet, inside your VPCThe proxy-only subnet's range for traffic, plus Google's health check ranges
3PassthroughThe data plane on each backend's host (chapter 1.2)The real clients' addresses, plus Google's health check ranges
A Cloud Run backend needs none of these: it is not in your VPC, so no firewall rule applies (chapter 10). Health checks and their ranges are chapter 12.1.

The whole family, and how to choose

Put the four choices together and these are the load balancers that exist today:

ExternalglobalExternalregionalInternalcross-regionInternalregionalApplicationL7 · proxyGoogle Front EndsKadé'sEnvoy · proxy subnetEnvoy · proxy subnetEnvoy · proxy subnetProxy NetworkL4 · proxyGoogle Front EndsEnvoy · proxy subnetEnvoy · proxy subnetEnvoy · proxy subnetPassthrough NetworkL4 · passthroughdoes not existhost data planedoes not existhost data plane
  • Run by Google

Wide by design - scroll it sideways.

#Load balancerReachSpreadModeRuns on
1Global external Application LBExternalGlobalProxy, L7Google Front Ends; also a "classic" version with fewer routing features
2Regional external Application LBExternalRegionalProxy, L7Envoy in a proxy-only subnet
3Cross-region internal Application LBInternalGlobalProxy, L7Envoy in a proxy-only subnet
4Regional internal Application LBInternalRegionalProxy, L7Envoy in a proxy-only subnet
5Global external proxy Network LBExternalGlobalProxy, L4 (TCP, optional TLS)Google Front Ends
6Regional external proxy Network LBExternalRegionalProxy, L4Envoy in a proxy-only subnet
7Internal proxy Network LB (regional or cross-region)InternalEitherProxy, L4Envoy in a proxy-only subnet
8External passthrough Network LBExternalRegionalPassthrough, L4The data plane on each host (chapter 1.2)
9Internal passthrough Network LBInternalRegionalPassthrough, L4The data plane; can also be a route's next hop (chapter 4)
Passthrough load balancers are always regional, and Application load balancers are always proxies. Those two rules explain every combination that does not exist.

Choosing is a short walk down four questions:

1 · Is it HTTP or HTTPS?2 · From the internet?2 · TCP, and want a proxy?yesno3 · Global or regional?Internal Application LBregional, or cross-regionyesnoGlobal external Application LBKadé · CDN · anycastRegional external Application LBone region, Standard tier OKglobalregionalProxy Network LBexternal or internalPassthrough Network LBUDP · real client IPyesnoPassthrough: external or internal,always regional. Internal passthroughcan be a route next hop (chapter 4).

Back to Kadé

Commands in this chapter

All read-only.

List forwarding rules (the front of every load balancer)

  • What it shows: Every load balancer's IP, port, scope and scheme.
  • What to look for: EXTERNAL_MANAGED (the newer global or regional external Application LB), EXTERNAL (classic or passthrough), INTERNAL or INTERNAL_MANAGED.
gcloud compute forwarding-rules list \  --format="table(name,region.basename(),IPAddress,portRange,loadBalancingScheme,target.basename())"

List backend services

  • What it shows: Each backend service with its scheme, protocol and whether it is global.
  • What to look for: The protocol (HTTP, HTTPS, TCP, UDP) tells you L7 or L4.
gcloud compute backend-services list \  --format="table(name,region.basename(),loadBalancingScheme,protocol)"

List proxy-only subnets

  • What it shows: Subnets reserved for Envoy-based load balancers.
  • What to look for: None for Kadé. One per region is needed before creating a regional or internal Application LB.
gcloud compute networks subnets list \  --filter="purpose~MANAGED_PROXY" --format="table(name,region.basename(),ipCidrRange,purpose,role)"

Spotted a mistake, or something unclear? Suggest an edit on GitHub