Routing policies
How Route 53 chooses which answer to give, with simple, weighted, latency, failover, geolocation, geoproximity, IP-based and multivalue answer routing.
What it is
A routing policy decides how Route 53 answers a DNS query when a name has several possible values.
Don't be confused by the word routing. It isn't like load balancer routing, which moves the traffic. DNS doesn't route any traffic: it only answers the query, and the client then connects to the address it was given.
Simple
- Usually sends traffic to a single resource.
- One record can hold several values (for example three IP addresses). Route 53 returns all of them in random order, and the client picks one.
- An alias can name only one AWS resource.
- No health checks.
Weighted
- Controls the percentage of answers that go to each resource.
- Each record gets a relative weight (0 to 255): a record's share = its weight ÷ the sum of all weights. The weights don't need to add up to 100.
- All the records must have the same name and type.
- Can be linked to health checks.
- A weight of 0 stops traffic to that record. If all records have weight 0, they're returned equally.
- Use cases: load balancing between Regions, testing a new version of an app on a small share of users (canary), moving traffic gradually.
Latency-based
- Sends users to the resource with the lowest latency for them.
- Latency is measured between users and AWS Regions: each record is tagged with the Region the resource is in. Users in Germany might be sent to the US if that's faster for them.
- Can be linked to health checks, which gives it a failover ability.
- Use case: a global app in several Regions where speed matters most.
Failover (active-passive)
- One primary record and one secondary record.
- The primary must have a health check. While it's healthy, Route 53 answers with the primary; when it fails, Route 53 answers with the secondary (for example a disaster recovery site).
- Works in public and private hosted zones.
Geolocation
- Routes by where the user is, not by latency.
- Locations are chosen by continent, country or US state. If locations overlap, the most precise one wins (a record for Canada beats one for North America).
- Create a default record for users who match no location (and for IP addresses Route 53 can't place).
- Can be linked to health checks.
- Use cases: website localization (French site for France), restricting content to certain countries, load balancing by region.
Geoproximity
- Routes by the location of users and of resources: each user goes to the nearest resource.
- A bias shifts more or less traffic to a resource by growing or shrinking its area:
- 1 to 99 expands it (more traffic);
- −1 to −99 shrinks it (less traffic).
- Resources can be AWS resources (give the AWS Region, or Local Zone group) or non-AWS resources (give latitude and longitude).
Updated since the slides
The slides say geoproximity requires Route 53 Traffic Flow, a visual editor for complex routing trees. Geoproximity records can now be created directly in the console; Traffic Flow is still where they appear on a map. On the exam, "shift traffic between Regions with a bias" still means geoproximity.
IP-based
- Routes by the client's IP address.
- A CIDR collection is uploaded: lists of IP ranges, each mapped to a location name. Records then say which endpoint serves each location. For example,
203.0.113.0/24→ location-1 →1.2.3.4. - Use cases: send users of a particular ISP to a specific endpoint, to optimize performance or reduce network costs.
Multivalue answer
- Use when routing traffic to several resources.
- Route 53 returns up to 8 healthy records for each query, chosen at random.
- Can be linked to health checks, so only healthy values are returned. That's the difference from simple with several values.
- Not a substitute for a load balancer: the client still picks one address, and there's no real load spreading.
Updated since the slides
The AWS documentation now also lists an AZ-affinity routing policy, newer than the course. New features need to be available for at least three months before they can be tested (see how current is the exam), so concentrate on the eight above.
Exam tips
- "Send 10% of users to the new version", "gradual migration" → weighted.
- "Best performance for users worldwide", "lowest latency" → latency-based.
- "Active-passive", "disaster recovery site when the primary fails" → failover (with a health check).
- "Users in a country must see a localized site", "restrict by country", "legal requirements" → geolocation.
- "Shift more traffic to one Region based on distance", "bias" → geoproximity.
- "Route users of a specific ISP or IP range" → IP-based.
- "Return several healthy IP addresses" → multivalue answer.
- "Health checks with one record holding several IPs" → not possible with simple; use multivalue.
Common traps
- "Latency-based sends users to the geographically closest Region." It uses measured latency, which isn't always the closest.
- "Geolocation is the same as latency." Geolocation uses the user's location, regardless of speed.
- "Multivalue replaces an ELB." It doesn't.
- "Forget the default record in geolocation." Users outside every location get no answer.
Hands-on lab: weighted records
Goal: create two weighted records and watch Route 53 alternate its answers.
Costs money
A private hosted zone deleted within 12 hours is free; testing from saa-web costs about $0.01. Any Region works.
Before you start: create the saa.internal private hosted zone from the records lab.
Create two weighted records
Create record in saa.internal: name app, type A, value 10.0.0.1, TTL 5, routing policy Weighted, weight 70, record ID blue. Add another: same name and type, value 10.0.0.2, weight 30, record ID green.
Ask many times
From saa-web:
for i in $(seq 20); do dig +short app.saa.internal; sleep 6; done | sort | uniq -cRoughly 14 answers are 10.0.0.1 and 6 are 10.0.0.2.
Stop traffic to one
Edit green and set its weight to 0. Run the loop again: only 10.0.0.1 comes back.
Expected result: answers split roughly 70/30, then all to one record when the other's weight is 0.
Clean up: delete both records and the hosted zone.
AWS documentation
CNAME vs alias
How a CNAME and a Route 53 alias record differ, why alias works at the zone apex, and which AWS resources an alias can point to.
Health checks
Route 53 health checks for endpoints, other health checks and CloudWatch alarms, how health is decided, private endpoints, and automated DNS failover.