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.
- Google's: the region, zones, hosts and network
- Kadé's: VMs it created, each on one host
Wide by design - scroll it sideways.
| # | Level | What it is | For Kadé | Who picks it |
|---|---|---|---|---|
| 1 | Google's network | Google's own fibre, joining every region and every edge location (section 04) | Carries a shopper's request from Colombo to Singapore | |
| 2 | Region | An independent geographic area, usually one city, made of three or more zones | asia-southeast1, Singapore | You, for every regional and zonal resource |
| 3 | Zone | A deployment area inside a region, built so that it fails on its own | asia-southeast1-a and -b | You, for every zonal resource |
| 4 | Host | One physical server in a zone | Never visible to you | Google. It can move a VM to another host in the same zone without stopping it (live migration) |
| 5 | VM | Your machine, running on one host | kade-api-1 | You 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:
| # | Question | Why it matters | For Kadé |
|---|---|---|---|
| 1 | How 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 |
| 2 | Does it offer what you need? | Not every product and machine type is in every region, and new ones reach some regions later | Cloud Run, Cloud SQL and Cloud NAT are all in Singapore |
| 3 | What does it cost? | The same VM has a different price in different regions | Compare in Google's pricing calculator |
| 4 | Must the data stay in one country? | Some laws and contracts say where data may be stored | No 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-southeast1hasa,bandc. - Named region plus letter.
asia-southeast1-ais zoneaofasia-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:
- 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.
| # | Traffic | Where it enters Google | How it travels | Chapter |
|---|---|---|---|---|
| 1 | A shopper to the load balancer 34.120.88.10 | The edge nearest the shopper. The Google Front End there ends TLS | Google's backbone, from that edge to the region | 12.1 |
| 2 | A VM to a VM in another region of the same VPC | It never leaves Google | The backbone, on internal IPs. No VPN, no NAT | 2 |
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:
| # | Region | Edge location | |
|---|---|---|---|
| 1 | What is there | Google's own data centres, full of hosts | Google's routers and front-end servers, inside a building shared with ISPs |
| 2 | Can you run a VM there? | Yes: VMs, disks, databases, Cloud Run | No. You never create anything in an edge location |
| 3 | How many | A few dozen, in large cities | Many more, in many more cities |
| 4 | What it does for Kadé | Runs kade-api and the database | Receives 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:
| # | Scope | Meaning | Why it has this scope | If a zone fails |
|---|---|---|---|---|
| 1 | Zonal | Pinned to one zone | It is a physical thing: a VM runs on one host, a disk sits next to it | Down until the zone is back |
| 2 | Regional | Lives in one region; Google spreads it over the zones inside | It is a range or a service that Google runs in several zones for you: a subnet, Cloud NAT, Cloud Run | Keeps working from the other zones |
| 3 | Global | One object for the whole planet, not a copy per region | It is only configuration. The control plane (chapter 1.2) pushes it to every host that needs it: the VPC, its firewall rules, its routes | Not affected |
- 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:
| # | Scope | Resource | Kadé's | Chapter |
|---|---|---|---|---|
| 1 | Global | VPC network, routes | kade-vpc, its subnet routes and default route | 2, 4 |
| 2 | Global | Firewall rules, global firewall policies | kade-allow-* | 5.1, 5.2 |
| 3 | Global | Global external IP and the global load balancer's parts | kade-lb-ip 34.120.88.10, kade-https-rule, kade-url-map, kade-api-backend, kade-hc | 11, 12.1 |
| 4 | Global | Cloud DNS zones, Cloud Armor policies | kade-lk, kade-internal, kade-edge-policy | 8, 12.1 |
| 5 | Global | Images, snapshots | The images VMs boot from | 12.2 |
| 6 | Regional | Subnets | sn-app, sn-data, later sn-run | 2 |
| 7 | Regional | Regional external IPs | kade-nat-ip 34.87.200.7 | 3, 7 |
| 8 | Regional | Cloud Router, Cloud NAT | kade-router, kade-nat | 7 |
| 9 | Regional | Cloud Run services, Cloud SQL with high availability | Cloud Run kade-api, kade-sql | 9, 10 |
| 10 | Regional | Regional managed instance groups, HA VPN | The VM group behind the load balancer, kade-havpn | 12.2, 15 |
| 11 | Zonal | VMs and their disks | kade-api-1 (zone a), kade-api-2 and kade-db (zone b), kade-worker (zone a) | 0, 10 |
| 12 | Zonal | Zonal managed instance groups, machine types | e2-small exists separately in each zone | 12.2 |
| 13 | Zonal | Cloud SQL without high availability | Not 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:
- 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:
| # | Join | Rule | What goes wrong if you break it |
|---|---|---|---|
| 1 | VM → subnet | The subnet must be in the VM's region | The subnet is "not found": GCP looks for it in the VM's region |
| 2 | VM → disk | The disk must be in the VM's zone | The disk cannot be attached. Copy it with a snapshot (global) first |
| 3 | VM or Cloud NAT → external IP | A regional IP from the same region | A Mumbai IP cannot be given to a Singapore VM |
| 4 | Cloud NAT → subnets | Only subnets in Cloud NAT's own region | A future subnet in Mumbai would need its own Cloud NAT (chapter 7) |
| 5 | Global load balancer → backends | Backends in any region | Nothing: this is what "global" buys you (chapter 11) |
| 6 | Any resource → VPC, firewall rules, routes | Always allowed; they are global | Nothing: 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:
| # | Path | Kadé's example | Round trip | Price per GiB |
|---|---|---|---|---|
| 1 | Same zone | kade-api-2 → kade-db, both in zone b | Well under 1 ms | Free, on internal IPs |
| 2 | Another zone, same region | kade-api-1 (zone a) → kade-db (zone b) | About 1 ms or less | $0.01 |
| 3 | Another region | Singapore → Mumbai | Tens of milliseconds | About $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
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
boutage 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:
| # | Resource | Path in its full name | gcloud flag |
|---|---|---|---|
| 1 | kade-vpc | projects/kade-prod/global/networks/kade-vpc | none |
| 2 | sn-app | projects/kade-prod/regions/asia-southeast1/subnetworks/sn-app | --region |
| 3 | kade-api-1 | projects/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-aTry it: which scope?
- kade-vpcVPC network
- kade-allow-sshFirewall rule
- 0.0.0.0/0 default routeRoute
- sn-appSubnet
- kade-api-1VM
- kade-api-1's boot diskZonal persistent disk
- kade-routerCloud Router
- 34.120.88.10Load balancer IP
- 34.87.200.7Cloud NAT IP
- kade-api (Cloud Run)Cloud Run service
- 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) andasia-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,bandc, allUP.
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 zonebfails.
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-ain the VM's path,regions/asia-southeast1in 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.5Save Kadé's region and zone as defaults
- What it shows: Nothing on screen. Later commands use these when you leave out
--regionor--zone. - What to look for:
gcloud config listnow shows both under[compute].
gcloud config set compute/region asia-southeast1gcloud config set compute/zone asia-southeast1-agcloud config list