DNS Routing Policies
Choosing the best answer per resolver
Beyond simple lookups, DNS answers can be chosen by latency, geography, weight or failover state. These policies turn the resolver's question into an intelligent routing decision — the cheapest global load balancing you can buy.
What you will learn
- Differentiate latency, geolocation, weighted, failover policies
- Apply health-based DNS failover
- Combine policies with regional LBs
Routing policies make DNS choose between multiple records: latency (nearest), geolocation (closest region by client's resolver location), weighted (canary splits), or failover (primary/secondary with health checks).
What is this?
Route 53 policies: simple, weighted, latency, geolocation, geoproximity(BIAS), failover, multivalue answer — each record identified by SetIdentifier. Azure Traffic Manager profiles: Performance (latency), Geographic, Priority (failover), Weighted, Multivalue. GCP: Cloud DNS + GLB anycast for latency-aware routing. Health checks gate records: a sick region's record is excluded automatically.
Why do you need it?
- Sending users to the nearest region cuts latency without app changes.
- Weighted splits support canary/blue-green and slow-roll traffic.
- DNS failover is the first wake-up call when a region dies.
- Compliance: geolocation keeps data processing region-resident.
Mental model
A delivery dispatch center assigning drivers by city (geo), time lag (latency), and load (weight)
DNS routing policies
The dispatcher (policy) reads the sender's location (resolver), prefers the closest open hub (latency), when overloaded splits packages (weighted), and if the local hub is closed reroutes (failover).
How it works
- Each record has a SetIdentifier/priority tag; the policy picks among them at query time.
- Latency policy: resolver's location → nearest healthy region by modeled latency.
- Geolocation: deterministic region-assignment from the resolver's IP.
- Weighted: split % per record (0-100) for canary; low weight = trickle traffic.
- Failover: health-checked primary; if unhealthy, DNS serves the secondary.
Policy → region selection.
Examples
Weighted and latency policy records
# Route 53: weighted records for canary (app-v1 90%, app-v2 10%)aws route53 change-resource-record-sets --hosted-zone-id ZONE \ --change-batch '{"Changes":[ {"Action":"UPSERT","ResourceRecordSet":{"Name":"app.example.com","Type":"A", "SetIdentifier":"v1","Weight":90,"TTL":60,"AliasTarget":{"HostedZoneId":"...","DNSName":"v1-lb"}}}, {"Action":"UPSERT","ResourceRecordSet":{"Name":"app.example.com","Type":"A", "SetIdentifier":"v2","Weight":10,"TTL":60,"AliasTarget":{"HostedZoneId":"...","DNSName":"v2-lb"}}}]}'Two alias records, weighted 90/10, deliver canary traffic at the DNS layer.
In production
- Two-region SaaS: latency records send EU→eu-west-1 and US→us-east-1 with 60s TTL.
- Azure Traffic Manager priority: prod region primary, DR region on failover.
- Geolocation policy reserves a region for regional-contract customers while weighted handles the rest.
Best practices
- Attach a health check to every failover/latency record.
- Low TTL (60s) on policy records to keep swim at takeoff.
- Test the chosen record per region (dig with @region resolvers, or edns-client-subnet).
- Document SetIdentifiers/policy intent in IaC — mislabeled weights cause silent skew.
Common mistakes
- Latency policy with no health check → routed to a dead region.
- Weights that sum ≠ 100 for the records (traffic invisible to some weights).
- Geolocation records that don't cover 'all remaining' (default) regions → NXDOMAIN holes.
- Forgetting cache: policy changes apply only after TTL expires.
Common issues
Some users get a cross-region recordResolver IP ≠ user location (VPN, carrier NAT)
Rely on latency instead of geo for user-experience, or use CDN/front-routing.
Failover record never fails overHealth check marks region healthy or TTL caches the old answer
Verify the health path/probe; lower TTL; wait out caches.
Debugging tips
- dig which record you get: resolver IP drives the choice — test from multiple locations.
- Validate health checks: switch the health path and watch record selection change.
- Geolocation gaps: add a 'Default' coverage record so unmapped resolvers still get an answer.
- Weighted drift: check Traffic Distributed metrics per weighted record over time.
Interview checkpoint
Hands-on lab
- Simulate latency/geo/weighted selection
- Model health-check gating
- Reason about cache impact
Model Routing Policies and Their Failover Behavior
25 min · intermediate
Quick quiz
Why attach a health check to a latency-routed record?