Cloud Regions, Availability Zones and Basic Networking Explained
Cloud ComputingLesson 2 of 46 min read
What you'll learn
- Explain regions and availability zones and what each protects against
- Choose a region using latency, data residency, service availability and price
- Plan a virtual network with public, private and data subnets in two zones
- Describe the roles of route tables, gateways, security groups, load balancers, DNS and a CDN
On this page
A food-delivery start-up serves one city from servers in a data centre a few kilometres away, and orders feel instant. Then it launches in a second country, and the owner in that country complains that the app is slow, while the lawyer asks where customer addresses are stored. Both problems are about where the system physically runs. The cloud gives you a vocabulary for choosing that place.
Regions and availability zones
A region is a geographic area where a provider operates a cluster of data centres, for example "western Europe" or "southern India"; each provider has its own list of names. Regions are separate from each other by design: an outage in one is not supposed to spread to another, and each has its own prices and its own list of available services. An availability zone (AZ) is one or more data centres inside a region with independent power, cooling and networking, connected to the other zones in the region by fast, low-latency links. Providers use slightly different terms and guarantees, so check the specifics for the one you use.
| Level | Typical failure it protects against | How you use it | Cost of using it |
|---|---|---|---|
| Single server | Nothing | One machine in one place | Cheapest; any hardware fault is an outage |
| Multiple zones in one region | A data centre fire, power or network failure | Run copies in two or more zones behind a load balancer | Some extra instances; small cross-zone data charges on some providers |
| Multiple regions | A whole region unavailable, or users far from the data | Replicate data and run the app in two regions; route users by DNS | Highest: duplicate infrastructure, replication delay, much more complexity |
For most business applications, running across two or more zones of one region gives the best balance. Going multi-region is a deliberate step you take for strict recovery requirements, legal needs or global latency, not the default.
Choosing a region
- Latency: light in optical fibre covers roughly 200 kilometres per millisecond at best, and real paths are longer and slower than the map distance. Put compute near your users, and remember each round trip your app makes multiplies the delay.
- Data residency and law: some data, such as health or financial records, may have to remain within a country or economic area. This is a legal question; involve whoever handles compliance before choosing.
- Service availability: newer services and some machine types arrive in some regions before others.
- Price: the same service can cost different amounts in different regions.
- Where your other pieces are: moving data between regions or out to the internet is usually billed, so keep chatty components together.
A virtual network, laid out on paper
Inside a region you create a virtual network (called a VPC or VNet depending on the provider): your own private address space, cut into subnets. A common layout uses three tiers across two zones. Public subnets hold only what must face the internet, such as the load balancer. Private subnets hold application servers that receive traffic only from the load balancer. Data subnets hold databases with no route to the internet at all. The Python standard library can do the arithmetic for you.
import ipaddress
network = ipaddress.ip_network("10.20.0.0/16")
blocks = list(network.subnets(new_prefix=24)) # 256 possible /24 blocks
plan = {
"public-zone-a": blocks[0], # load balancer, NAT gateway
"public-zone-b": blocks[1],
"private-zone-a": blocks[10], # app servers
"private-zone-b": blocks[11],
"data-zone-a": blocks[20], # database, no route to the internet
"data-zone-b": blocks[21],
}
print("network", network, "holds", len(blocks), "subnets of /24")
for name, block in plan.items():
print(f"{name:15} {str(block):14} {block.num_addresses} addresses")
probe = ipaddress.ip_address("10.20.10.57")
owner = [n for n, b in plan.items() if probe in b]
print()
print(probe, "belongs to", owner)
print("overlaps with 10.20.0.0/16?", network.overlaps(ipaddress.ip_network("10.20.5.0/24")))
print("overlaps with 192.168.0.0/16?", network.overlaps(ipaddress.ip_network("192.168.0.0/16")))Output
network 10.20.0.0/16 holds 256 subnets of /24 public-zone-a 10.20.0.0/24 256 addresses public-zone-b 10.20.1.0/24 256 addresses private-zone-a 10.20.10.0/24 256 addresses private-zone-b 10.20.11.0/24 256 addresses data-zone-a 10.20.20.0/24 256 addresses data-zone-b 10.20.21.0/24 256 addresses 10.20.10.57 belongs to ['private-zone-a'] overlaps with 10.20.0.0/16? True overlaps with 192.168.0.0/16? False
The addresses (like 10.20.0.0/16) are private ranges, usable only inside your network. The number after the slash says how many leading bits are fixed: a /16 leaves room for 65,536 addresses and a /24 for 256. In real clouds each subnet loses a handful of addresses to the provider, and the number varies, so do not plan to use all 256. The overlap check matters in practice: if you later connect this network to an office or to another network, overlapping ranges cannot be routed, so plan ranges before you build.
Internet
|
[ DNS / CDN ]
|
+-------+-------------------------+
| Virtual network 10.20.0.0/16 |
| |
| Zone A Zone B |
| public .0/24 public .1/24 |
| [LB node] <----> [LB node] |
| private .10/24 private .11 |
| [app] [app] [app] [app] |
| data .20/24 data .21 |
| [DB primary] -> [DB standby] |
+---------------------------------+The moving parts that connect it
| Component | Job | Detail worth remembering |
|---|---|---|
| Route table | Says where traffic for each address range goes | A subnet is "public" because its route table sends outbound traffic to an internet gateway, not because of its name |
| Internet gateway | Two-way door between the network and the internet | Only resources with a public address and a permissive firewall rule can be reached through it |
| NAT gateway | Lets private servers start outbound connections without being reachable inbound | Typically billed per hour plus per gigabyte processed, so it can be a surprising cost |
| Security group / firewall | Stateful allow-rules attached to resources | Default-deny inbound; open only the ports you need, and prefer allowing traffic from another group rather than from the whole internet |
| Load balancer | Spreads incoming requests over healthy servers in several zones | Health checks stop it sending traffic to a broken instance; see Scalability and Load Balancing |
| DNS | Turns names into addresses; can steer users to the nearest or healthy region | Cached by clients, so changes take time to spread |
| CDN | Caches static content in many locations close to users | Cuts latency and origin load for images and scripts |
Common mistakes
- Putting everything in one zone and calling it highly available. Symptom: the whole product goes down in a zone event while the status page of the provider says only "one zone affected".
- Making the database publicly reachable "just for now". Symptom: a flood of login attempts in the database logs within hours. Put it in a data subnet and reach it through the application tier or a controlled admin path.
- Choosing overlapping address ranges. Symptom: a later VPN or peering connection cannot be created, or traffic goes to the wrong network, forcing a rebuild. Reserve distinct ranges per environment and per site.
- Opening the firewall to everyone on a management port. Symptom: remote-administration ports receiving attacks from the whole internet. Restrict by source or use a managed access path.
- Ignoring cross-zone and cross-region data charges. Chatty services spread across zones or regions can generate a bill nobody budgeted for.
How this shows up in real projects and interviews
Questions here are often "how would you make this service survive a data-centre failure?" and "explain a public versus a private subnet". The expected answer: two or more zones behind a load balancer, stateless application servers, a database with a standby in another zone, and a network layout where only the load balancer is internet-facing. In real projects the network is usually defined once in infrastructure-as-code and then rarely touched, so the cost of a wrong address plan arrives months later. Spend an hour on it up front, and when you want hands-on practice with one provider's version of it, move on to AWS Fundamentals.
Try it yourself
Modify subnets.py to plan a second environment called staging in 10.30.0.0/16 with two public and two private /24 subnets, and print whether it overlaps with the production network. Then write three sentences explaining which region you would choose for a ticket-booking site whose customers are all in one country, and what question you would ask legal before deciding.
Show a hint
Use network.overlaps(other) with both networks created by ipaddress.ip_network. For the region, start with the country of your customers and ask whether any of their data must remain inside it.
Key takeaways
- A region is a geographic cluster of data centres; an availability zone is an independent data-centre group inside a region.
- Spread across zones for ordinary resilience; go multi-region only for strict recovery, legal or global-latency needs.
- Pick regions by latency, data residency, service availability, price and where your data already lives.
- Use public, private and data subnets so only the load balancer faces the internet; plan non-overlapping address ranges early.
- Route tables, gateways, security groups, load balancers, DNS and CDNs each have one clear job; zones protect against failures, not against mistakes.
Test yourself
A trick from this lesson's ride: Law first, then latency, then price: a legal rule strikes regions off the list before any comparison. Four more tricks like it wait along the route, each followed by a question.
Frequently asked questions
What is the difference between a region and an availability zone?
A region is a geographic area containing multiple isolated locations, while an availability zone is one of those locations: one or more data centres with independent power and networking. Zones in a region are connected by fast links, so you can spread an application across zones to survive a single data-centre failure.
What is a VPC in cloud computing?
A VPC (virtual private cloud, or virtual network on some providers) is your own isolated network inside the provider's cloud. You choose its private address range, divide it into subnets, control routing and apply firewall rules. It is where you place servers, databases and load balancers.
What is the difference between a public and a private subnet?
A public subnet has a route to an internet gateway, so resources with public addresses in it can be reached from the internet. A private subnet has no direct inbound route from the internet; its resources reach out through a NAT gateway if needed. Databases and application servers usually sit in private subnets.