Chapters

Regions, zones and Google's network

Before looking at how GCP's network works, this chapter looks at where it is: the data centres, the zones and regions they are grouped into, and the private network that joins them to each other and to the rest of the internet. Every GCP resource is tied to one of three scopes, global, regional or zonal, and the scope decides where it can be used, what it can connect to, and what an outage can take down.

Foundations · chapter 1 of 26 · 18 min read

From the planet to one host

Everything in GCP runs on hardware in real buildings. Google groups that hardware in levels, and each level is a boundary that matters later: for speed, for price, and for what fails together.

1Google's network: joins this region to every other region and to the internet (section 04)2region asia-southeast1 · Singaporezone aasia-southeast1-azone basia-southeast1-bzone casia-southeast1-c3hostkade-api-1+ other customershostother customershostkade-api-2+ other customershostkade-db+ other customershostother customershostother customers45fast private links between the zones of one region
  • Google's: the region, zones, hosts and network
  • Kadé's: VMs it created, each on one host

Wide by design - scroll it sideways.

#LevelWhat it isFor KadéWho picks it
1Google's networkGoogle's own fibre, joining every region and every edge location (section 04)Carries a shopper's request from Colombo to SingaporeGoogle
2RegionAn independent geographic area, usually one city, made of three or more zonesasia-southeast1, SingaporeYou, for every regional and zonal resource
3ZoneA deployment area inside a region, built so that it fails on its ownasia-southeast1-a and -bYou, for every zonal resource
4HostOne physical server in a zoneNever visible to youGoogle. It can move a VM to another host in the same zone without stopping it (live migration)
5VMYour machine, running on one hostkade-api-1You create it; Google places it

Regions: where in the world

A region is an independent geographic area, such as Singapore, Mumbai or London. Its name says where it is: asia-southeast1 is the first region in south-east Asia, and asia-southeast2 (Jakarta) is the second.

There is no region in Sri Lanka, so Kadé's two nearest choices are asia-south1 (Mumbai) and asia-southeast1 (Singapore). Kadé runs in Singapore. Mumbai would be just as reasonable. What matters is how a region scores on the questions below, not which one looks closer on a map:

#QuestionWhy it mattersFor Kadé
1How far is it from the users?Every request pays the round trip, and nothing makes light faster (section 07)Measure from Colombo; do not guess from a map
2Does it offer what you need?Not every product and machine type is in every region, and new ones reach some regions laterCloud Run, Cloud SQL and Cloud NAT are all in Singapore
3What does it cost?The same VM has a different price in different regionsCompare in Google's pricing calculator
4Must the data stay in one country?Some laws and contracts say where data may be storedNo such rule for Kadé today

A region is chosen per resource, not per project. Nothing stops kade-prod from holding resources in ten regions. It holds them in one, which keeps it simple and has a cost that section 08 makes visible.

Zones: failure domains inside a region

A zone is a deployment area inside a region. Google builds zones so that a power, cooling or network failure in one is unlikely to reach another. Google's advice is to treat each zone as a single failure domain: plan for a whole zone to go dark at once.

  • Three or more per region. Every general-purpose region has at least three zones. asia-southeast1 has a, b and c.
  • Named region plus letter. asia-southeast1-a is zone a of asia-southeast1. The letter means nothing about location or size.
  • A zone is not a building you can point at. Google calls zones and regions logical areas over physical hardware. A zone may be part of a building or span several. Google promises that zones fail independently. It does not publish where each zone is.
  • Joined by fast private links. The zones of one region are close enough for a round trip of about a millisecond, and far enough apart not to share a failure.

Kadé already uses this, half by accident. kade-api-1 and kade-api-2 are in different zones, so losing one zone leaves one API server. But kade-db exists only in zone b. Section 08 shows what that means.

Google's network: the backbone and the edge

Builds on12. Anycast33. Load balancers

Regions are joined to each other by Google's backbone: fibre that Google owns or leases, including undersea cables. Around the backbone sit Google's edge locations (also called points of presence), where Google's network meets ISPs. There are far more edge locations than regions, so most internet users are near one.

Two kinds of Kadé traffic ride this network:

shoppers elsewhere usetheir own nearest edgeAnother Google edgealso 34.120.88.10ShopperColomboShopper's ISPSri LankaNearest Google edge34.120.88.10 hereTLS ends hereGoogle'sbackboneasia-southeast1Singaporekade-vpckade-api-1zone akade-api-2zone b123asia-south1 · Mumbaisame VPC, internal IPs,over the backbone, no VPN1 · the ISP hands the request to the nearest edge announcing 34.120.88.102 · the edge ends TLS and carries the request on Google's own backbone3 · it reaches kade-api in Singapore without crossing the public internet
  • Google's: edges, backbone and regions
  • Kadé's: kade-vpc and its VMs

34.120.88.10 is an anycast address: every Google edge announces it, so each shopper's ISP delivers it to the nearest one. A shopper in Colombo and a shopper in Tokyo use the same IP and enter Google at different places.

Wide by design - scroll it sideways.

#TrafficWhere it enters GoogleHow it travelsChapter
1A shopper to the load balancer 34.120.88.10The edge nearest the shopper. The Google Front End there ends TLSGoogle's backbone, from that edge to the region12.1
2A VM to a VM in another region of the same VPCIt never leaves GoogleThe backbone, on internal IPs. No VPN, no NAT2

An edge location is not a small region. It is Google's network equipment in a shared building where many networks connect, often an internet exchange. The difference matters:

#RegionEdge location
1What is thereGoogle's own data centres, full of hostsGoogle's routers and front-end servers, inside a building shared with ISPs
2Can you run a VM there?Yes: VMs, disks, databases, Cloud RunNo. You never create anything in an edge location
3How manyA few dozen, in large citiesMany more, in many more cities
4What it does for KadéRuns kade-api and the databaseReceives shoppers' requests, ends TLS, and runs Cloud CDN and Cloud Armor (chapter 12.1)

Why entering Google at the nearest edge helps a shopper in Colombo, even though kade-api is in Singapore:

  • Less of the trip is on the public internet. The shopper's packets only cross their ISP to reach the edge. The rest of the way is Google's own backbone, which Google runs end to end, so the path is shorter and steadier.
  • Connecting is faster. Opening a connection takes round trips: one for TCP, more for TLS (Fundamentals ch 25). Those happen between the shopper and the nearby edge, so each one is short. Only the finished request makes the long trip to Singapore.
  • Some requests never reach Singapore. Cloud Armor can block a bad request at the edge, and Cloud CDN can answer a cached one there (chapter 12.1).

Three scopes: global, regional, zonal

Every GCP resource has one of three scopes. The scope tells you two things: where the resource can be used, and what an outage can take down. It is not a free choice Google made per product. It follows from what the resource is:

#ScopeMeaningWhy it has this scopeIf a zone fails
1ZonalPinned to one zoneIt is a physical thing: a VM runs on one host, a disk sits next to itDown until the zone is back
2RegionalLives in one region; Google spreads it over the zones insideIt is a range or a service that Google runs in several zones for you: a subnet, Cloud NAT, Cloud RunKeeps working from the other zones
3GlobalOne object for the whole planet, not a copy per regionIt is only configuration. The control plane (chapter 1.2) pushes it to every host that needs it: the VPC, its firewall rules, its routesNot affected
global · one object for the whole planetkade-vpcthe networkFirewall ruleskade-allow-*Routesbelong to kade-vpc34.120.88.10load balancer IPregional · asia-southeast1Cloud Router + Cloud NATlater · chapter 7NAT IP 34.87.200.7later · chapter 7zonal · zone azone bzone csn-app 10.10.1.0/24spans every zonekade-api-1kade-api-2sn-data 10.10.2.0/24spans every zonekade-dbasia-south1another regiona new subnet here ispart of the same kade-vpcits VMs reach Singaporeon internal IPs, overGoogle's backbone, no VPN
  • Google's: the region and the load balancer
  • Kadé's: what it creates in kade-vpc

A subnet is regional, so it stretches across every zone of its region. That only works because a subnet is a range of addresses and a set of rules, not a cable (chapter 1.2).

Wide by design - scroll it sideways.

Every resource Kadé uses in this course, by scope:

#ScopeResourceKadé'sChapter
1GlobalVPC network, routeskade-vpc, its subnet routes and default route2, 4
2GlobalFirewall rules, global firewall policieskade-allow-*5.1, 5.2
3GlobalGlobal external IP and the global load balancer's partskade-lb-ip 34.120.88.10, kade-https-rule, kade-url-map, kade-api-backend, kade-hc11, 12.1
4GlobalCloud DNS zones, Cloud Armor policieskade-lk, kade-internal, kade-edge-policy8, 12.1
5GlobalImages, snapshotsThe images VMs boot from12.2
6RegionalSubnetssn-app, sn-data, later sn-run2
7RegionalRegional external IPskade-nat-ip 34.87.200.73, 7
8RegionalCloud Router, Cloud NATkade-router, kade-nat7
9RegionalCloud Run services, Cloud SQL with high availabilityCloud Run kade-api, kade-sql9, 10
10RegionalRegional managed instance groups, HA VPNThe VM group behind the load balancer, kade-havpn12.2, 15
11ZonalVMs and their diskskade-api-1 (zone a), kade-api-2 and kade-db (zone b), kade-worker (zone a)0, 10
12ZonalZonal managed instance groups, machine typese2-small exists separately in each zone12.2
13ZonalCloud SQL without high availabilityNot used: kade-sql runs with high availability (row 9)9

Placement rules: what can use what

Scopes are not only labels. They decide which resources can be joined, and they are the reason behind many "not found" and "invalid" errors when you create something:

kade-api-1asia-southeast1-aIts boot diskzone a: same zone✓sn-appasia-southeast1: same region✓A static IPfrom asia-southeast1: same region✓kade-vpc, rules, routesglobal: usable anywhere✓A disk in zone banother zone✕A subnet in asia-south1another region✕A static IPfrom asia-south1: another region✕Global IP 34.120.88.10only global load balancers✕
  • The VM, in zone a
  • Can use it

Green: kade-api-1 can use it. Red: it cannot. The fourth red row is a different kind of mismatch: the address is global, but only a global load balancer can hold a global address.

Wide by design - scroll it sideways.

The same rule, for the joins you will make in this course:

#JoinRuleWhat goes wrong if you break it
1VM → subnetThe subnet must be in the VM's regionThe subnet is "not found": GCP looks for it in the VM's region
2VM → diskThe disk must be in the VM's zoneThe disk cannot be attached. Copy it with a snapshot (global) first
3VM or Cloud NAT → external IPA regional IP from the same regionA Mumbai IP cannot be given to a Singapore VM
4Cloud NAT → subnetsOnly subnets in Cloud NAT's own regionA future subnet in Mumbai would need its own Cloud NAT (chapter 7)
5Global load balancer → backendsBackends in any regionNothing: this is what "global" buys you (chapter 11)
6Any resource → VPC, firewall rules, routesAlways allowed; they are globalNothing: one rule protects VMs in every region

Speed and price across zones and regions

Builds on12. Where latency comes from

Inside one VPC, every VM can reach every other VM on internal IPs, whatever their zones and regions. What changes is how long a round trip takes and what each gigabyte costs:

#PathKadé's exampleRound tripPrice per GiB
1Same zonekade-api-2 → kade-db, both in zone bWell under 1 msFree, on internal IPs
2Another zone, same regionkade-api-1 (zone a) → kade-db (zone b)About 1 ms or less$0.01
3Another regionSingapore → MumbaiTens of millisecondsAbout $0.08 within Asia, more between continents

Row 3 is set by physics, not by Google. Light in fibre covers about 200 km per millisecond, and Singapore to Mumbai is about 3,900 km:

3,900 km × 2 ÷ 200 km per ms ≈ 39 ms at the very least

Every query kade-api-1 sends to kade-db crosses from zone a to zone b, so it pays the cross-zone price and up to a millisecond. That is the cost of keeping the two API servers in different zones, and it is almost always worth paying.

What an outage takes down

Pick a failure and see which of Kadé's pieces survive it, as the project is today and as it will be after the course:

Kadé's setup

What fails

ShoppersLoad balancerglobal · 34.120.88.10region asia-southeast1zone azone b: downzone ckade-api-1VM · zonalkade-api-2VM · zonal✕kade-dbdatabase VM · zonal✕no Kadé resources

api.kade.lk is down. kade-api-1 is still running, but kade-db was in zone b, so every order fails. One zonal database is a single point of failure for the whole shop.

Three things to take from it:

  • A zonal resource that everything needs is a single point of failure. Today, a zone b outage takes kade-db, and with it the whole shop, even though kade-api-1 keeps running.
  • Regional services survive a zone for you. Cloud SQL with high availability (chapter 9) and Cloud Run (chapter 10) keep copies in more than one zone. Google moves the work when a zone fails.
  • Surviving a whole region costs much more. It needs a second region with its own copy of the data and a global load balancer in front of both. Kadé accepts the risk for now; most small businesses do.

Reading the scope in names and commands

Every resource has a full name, its self link, and the path in it says the scope: global, regions/… or zones/…. gcloud asks for the matching flag:

#ResourcePath in its full namegcloud flag
1kade-vpcprojects/kade-prod/global/networks/kade-vpcnone
2sn-appprojects/kade-prod/regions/asia-southeast1/subnetworks/sn-app--region
3kade-api-1projects/kade-prod/zones/asia-southeast1-a/instances/kade-api-1--zone

To stop typing the flags, save Kadé's region and a default zone in your gcloud config. This changes only your own machine, not the project:

gcloud config set compute/region asia-southeast1gcloud config set compute/zone asia-southeast1-a

Try it: which scope?

  1. kade-vpcVPC network
  2. kade-allow-sshFirewall rule
  3. 0.0.0.0/0 default routeRoute
  4. sn-appSubnet
  5. kade-api-1VM
  6. kade-api-1's boot diskZonal persistent disk
  7. kade-routerCloud Router
  8. 34.120.88.10Load balancer IP
  9. 34.87.200.7Cloud NAT IP
  10. kade-api (Cloud Run)Cloud Run service
  11. kade-havpnHA VPN gateway

0 of 0 right · 11 left

Back to Kadé

Commands in this chapter

All read-only, except command 6, which only changes your local gcloud settings.

List the regions near Kadé

  • What it shows: Every region whose name starts with asia, with its status.
  • What to look for: asia-south1 (Mumbai) and asia-southeast1 (Singapore), Kadé's two nearest choices.
gcloud compute regions list --filter="name~^asia"

List the zones of Kadé's region

  • What it shows: The zones of asia-southeast1.
  • What to look for: Three zones, a, b and c, all UP.
gcloud compute zones list --filter="region:asia-southeast1"

See which zone each VM runs in

  • What it shows: Each VM with its zone and internal IP.
  • What to look for: kade-db alone in zone b, with nothing to take over if zone b fails.
gcloud compute instances list \  --format="table(name,zone.basename(),networkInterfaces[0].networkIP)"

See a resource's scope in its full name

  • What it shows: The self link of the VM and of its subnet.
  • What to look for: zones/asia-southeast1-a in the VM's path, regions/asia-southeast1 in the subnet's.
gcloud compute instances describe kade-api-1 --zone=asia-southeast1-a \  --format="value(selfLink,networkInterfaces[0].subnetwork)"

Measure same-zone and cross-zone round trips

  • What it shows: Ping times to kade-db from kade-api-2 (same zone) and from kade-api-1 (another zone). Run each line on the VM named in it.
  • What to look for: Both are small; the cross-zone one is a little higher.
# on kade-api-2, zone bping -c 5 10.10.2.5# on kade-api-1, zone aping -c 5 10.10.2.5

Save Kadé's region and zone as defaults

  • What it shows: Nothing on screen. Later commands use these when you leave out --region or --zone.
  • What to look for: gcloud config list now shows both under [compute].
gcloud config set compute/region asia-southeast1gcloud config set compute/zone asia-southeast1-agcloud config list

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