Sub topic 10
Local Zones, Wavelength Zones, and edge locations
This chapter assumes you know what a Region and an Availability Zone (AZ) are, that you can run aws CLI commands, and that you have a basic idea of a VPC (a private network in AWS) and a subnet (a slice of that network's address range). If those are new, review the earlier chapters first.
Why AWS extends beyond Regions and AZs
A standard Region puts your resources in a handful of large data center clusters. That is enough for most workloads. Some workloads need to be closer to end users than any Region can be, such as live video production, real-time gaming, or applications on 5G phones. Other workloads only need to deliver content quickly and don't need to run your code at all.
AWS addresses these cases with three kinds of locations that sit outside the Region and AZ model:
- Local Zones run a limited set of compute, storage, and database services in a metropolitan area, away from the parent Region.
- Wavelength Zones place AWS compute and storage inside a telecom provider's 5G network.
- Edge locations cache content and answer DNS queries near users. You cannot launch servers in them.
The main difference is whether you can run your own resources there. Local Zones and Wavelength Zones are places where you do. Edge locations are places that AWS services use on your behalf.
The three location types compared
| Property | Availability Zone | Local Zone | Wavelength Zone | Edge location |
|---|---|---|---|---|
| Runs your EC2 instances | Yes | Yes | Yes | No |
| Belongs to a parent Region | It is part of one | Yes | Yes | No |
| Enabled by default | Yes, in enabled Regions | No, opt-in | No, opt-in | Not applicable |
| Service coverage | Full Region catalog | A subset | A small subset | Specific edge services |
| Main goal | Resilience | Low latency to a city | Low latency to 5G devices | Content delivery and DNS |
| `ZoneType` value | `availability-zone` | `local-zone` | `wavelength-zone` | Not returned by EC2 |
Local Zones
A Local Zone is an extension of a Region. It lives in a city that is far from the Region's AZs, such as Los Angeles for the US West (Oregon) Region. Its name shows the parent Region and the city: us-west-2-lax-1a belongs to us-west-2.
How they fit into your network
A Local Zone does not have its own VPC. You extend a VPC from the parent Region into the Local Zone by creating a subnet there. Instances in that subnet can talk to instances in the Region's AZs over private IP addresses, because they are in the same VPC.
Every Local Zone belongs to a zone group and a network border group. The zone group is the unit you opt into. For us-west-2-lax-1a, the group is us-west-2-lax-1. The network border group is the set of locations from which AWS advertises public IP addresses. An Elastic IP address allocated for one border group cannot be used in another.
Enabling a Local Zone
Local Zones are off by default. Add --all-availability-zones to see zones you have not enabled:
aws ec2 describe-availability-zones \
--region us-west-2 \
--all-availability-zones \
--query "AvailabilityZones[?ZoneType=='local-zone'].[ZoneName,GroupName,OptInStatus,ParentZoneName]" \
--output tableThen opt in to a zone group:
aws ec2 modify-availability-zone-group \
--region us-west-2 \
--group-name us-west-2-lax-1 \
--opt-in-status opted-inThe change can take a few minutes to take effect. Your IAM identity needs the ec2:ModifyAvailabilityZoneGroup permission. You can also opt out by passing not-opted-in, but only if you have no resources in the zone.
Creating a subnet in a Local Zone
You create the subnet the same way as in an AZ. You give the Local Zone name as the zone. The VPC ID below is a placeholder.
aws ec2 create-subnet \
--region us-west-2 \
--vpc-id vpc-0123456789abcdef0 \
--cidr-block 10.0.8.0/24 \
--availability-zone us-west-2-lax-1aPick a CIDR block that does not overlap the subnets you already have in the VPC.
Limits to expect
- Fewer services. Core pieces such as EC2, EBS, and some load balancing, container, and database options are available. The set differs per Local Zone, so check the AWS documentation for the one you plan to use.
- Fewer instance types. Not every instance family is offered, and capacity can be smaller than in a Region.
- No multi-AZ inside the zone. A Local Zone has one
azone, so you cannot spread across AZs within it. To get resilience, keep a copy of the workload in the parent Region's AZs. - Different prices. Prices in a Local Zone are often higher than in the parent Region. Compare them with the pricing page before you move a workload.
Wavelength Zones
A Wavelength Zone is AWS infrastructure installed in a communications service provider's data centers at the edge of its 5G network. Traffic from a 5G device reaches your application without leaving the carrier's network, which reduces the number of network hops and the latency.
Names follow a pattern like us-east-1-wl1-bos-wlz-1, where wl1 identifies the carrier arrangement and bos the city. As with Local Zones, you opt in to the zone group first and then add a subnet to a VPC from the parent Region.
Wavelength has two networking pieces that other zones do not have:
- Carrier gateway. A VPC component that connects subnets in a Wavelength Zone to the carrier network and the internet. It plays the role an internet gateway plays for a normal subnet.
- Carrier IP address. An address from the carrier's pool that you assign to an instance, so that devices on the carrier network can reach it.
Wavelength supports only a small set of services, mainly EC2, EBS, and VPC networking. Data transfer to the parent Region is charged separately. Wavelength suits cases such as game servers, live video, and machine learning inference for mobile devices, where milliseconds matter.
Listing all zone types with boto3
The filter zone-type lets you choose which kinds of zone to see. This script groups every zone in a Region by type, including zones you have not enabled.
import boto3
from collections import defaultdict
ec2 = boto3.client("ec2", region_name="us-west-2")
response = ec2.describe_availability_zones(AllAvailabilityZones=True)
by_type = defaultdict(list)
for zone in response["AvailabilityZones"]:
by_type[zone["ZoneType"]].append(zone)
for zone_type, zones in by_type.items():
print(f"\n{zone_type} ({len(zones)})")
for z in zones:
print(f" {z['ZoneName']:<28} {z['OptInStatus']:<15} {z['NetworkBorderGroup']}")Standard AZs show opt-in-not-required. Local Zones and Wavelength Zones show not-opted-in until you enable their group.
Edge locations
An edge location is a site that belongs to the AWS content delivery network. AWS runs hundreds of them across the world, in more cities than there are Regions. They are also called points of presence.
Edge locations support these services:
- Amazon CloudFront caches copies of your content (web pages, images, video, API responses) so that a user fetches it from a nearby site. On a cache miss, the edge location asks your origin, such as an S3 bucket or a load balancer, and stores the answer.
- Amazon Route 53 answers DNS queries from many edge sites, so name lookups are fast.
- AWS Global Accelerator brings user traffic onto the AWS backbone network at the nearest edge location, and then carries it to your Regional endpoint.
- CloudFront Functions and Lambda@Edge run small pieces of code on requests and responses close to the user.
CloudFront also uses regional edge caches. These are larger caches between edge locations and your origin. When an edge location misses, it can find the object in the regional cache before it contacts your origin.
You do not choose an edge location. DNS and routing send each user to a nearby one. What you can choose is the CloudFront price class, which limits the set of edge locations used in order to lower cost, at the price of higher latency for users outside those areas.
What edge locations are not
- You cannot launch an EC2 instance, create a subnet, or store an S3 bucket in an edge location.
- They are not listed by
describe-availability-zonesordescribe-regions. - Caching helps only when the content can be reused. Highly personalized or uncacheable responses still go to your origin.
Choosing between them
Ask these questions in order:
- Do you need to run code or hold state near users? If not, and you only serve content, use CloudFront at the edge. Most websites stop here.
- Are your users on 5G devices on a specific carrier? If so, consider a Wavelength Zone.
- Are your users concentrated in one city that is far from the nearest Region? If so, consider a Local Zone.
- Does the workload need high availability? Keep the main deployment in multiple AZs of the parent Region, and use the extended zone only for the latency-sensitive part.
Common errors
InvalidParameterValueor "zone not supported" when creating a subnet. The zone group is not opted in yet. Rundescribe-availability-zones --all-availability-zonesand checkOptInStatus.- An instance type is not offered in the zone. Check availability with
aws ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=location,Values=us-west-2-lax-1a. - An Elastic IP does not attach. The address was allocated for a different network border group. Allocate it with
--network-border-groupset to the zone's group. - Higher latency than expected. Traffic between the Local Zone and the Region crosses the public network or a longer path. Keep chatty calls inside the zone.
- Unexpected data transfer charges. Moving data between the extended zone and the Region is billed. Review it in Cost Explorer.
Exercise
A team runs a video-editing tool for studios in Los Angeles. The main application runs in us-west-2 across three AZs. Editors report lag on live preview. Which of the three location types would you consider for the preview service, and what must you do before you can create its subnet?
Show answer
Use a Local Zone, such as us-west-2-lax-1a, because the users are concentrated in one city far from the Region. First opt in to the zone group (us-west-2-lax-1) with aws ec2 modify-availability-zone-group, then create a subnet in that zone from the existing VPC. Keep the main application in the Region's AZs.
Exercise
A colleague says they will place a cache server in the CloudFront edge location in Frankfurt to speed up their site. What is wrong with this plan, and what should they do instead?
Show answer
You cannot launch your own servers in an edge location. CloudFront manages the caches there. They should create a CloudFront distribution that points at their origin, and optionally pick a price class to control which edge locations are used.
Exercise
Write a boto3 call, or an AWS CLI command, that lists only the Wavelength Zones for the us-east-1 Region, including those you have not opted in to.
Show answer
aws ec2 describe-availability-zones --region us-east-1 --all-availability-zones --filters Name=zone-type,Values=wavelength-zone. In boto3: ec2.describeavailabilityzones(AllAvailabilityZones=True, Filters=[{"Name": "zone-type", "Values": ["wavelength-zone"]}]).