DNS Health Checks and Failover
Making DNS aware of the living world
DNS is stateless and can't know a server is down — so managed DNS adds health checks that probe endpoints and exclude unhealthy records from answers, powering region-level failover.
What you will learn
- Create health checks against endpoints
- Wire health checks into failover records
- Tune detection thresholds
A health check probes a URL/IP from multiple global vantage points; after a failure threshold, the record is removed from DNS answers and failover records shift traffic to the secondary — DNS turns down-outages into redirects.
What is this?
Route 53 health checks: HTTP/HTTPS/TCP probes, configurable path, port, interval (10-30s), failure threshold, string matching, and 'calculated health checks' (combine child statuses). Azure Traffic Manager monitors endpoints likewise; GCP external health checks gate backends. Endpoint types: LB DNS, bucket, instance IP. Failover records: PRIMARY/SECONDARY pairs serve the healthy one via health check state.
Why do you need it?
- Clients never learn an endpoint is down at the DNS layer unless we tell them.
- Health-based DNS is the first line of multi-region failover.
- Alerts + health == a closed loop: if a region fails, both traffic and on-call get notified.
- Shared probe vantage points catch 'works for you but not for users' issues.
Mental model
A cinema's 'now showing / today closed' sign triggered by a daily staff check
DNS health checks
The sign (records) never guesses — a person (probe) visits to verify the doors (endpoint) weekly-minute, SIGNS the sign on failure, and moviegoers reroute to the next cinema (failover).
How it works
- Probes hit the endpoint from several vantage points every 30s by default.
- Health = pass/fail per probe; threshold of N consecutive failures flips it unhealthy.
- A record attached to an unhealthy check is not served to resolvers.
- Failover pairs: PRIMARY record served while healthy; on failure the SECONDARY answers.
- Timers: interval × threshold + TTL bounds the end-to-end failover time.
Failover timeline.
Examples
Failover pair with health check
# health check for primaryaws route53 create-health-check --caller-reference primary-hc \ --health-check-config '{"Type":"HTTPS","ResourcePath":"/healthz","Port":443,"FailureThreshold":3,"RequestInterval":10}'# PRIMARY + SECONDARY recordsaws route53 change-resource-record-sets --hosted-zone-id ZONE \ --change-batch '{"Changes":[ {"Action":"UPSERT","ResourceRecordSet":{"Name":"app.example.com","Type":"A", "SetIdentifier":"primary","Failover":"PRIMARY","HealthCheckId":"hc-primary","TTL":60, "AliasTarget":{"HostedZoneId":"...","DNSName":"primary-lb"}}}, {"Action":"UPSERT","ResourceRecordSet":{"Name":"app.example.com","Type":"A", "SetIdentifier":"dr","Failover":"SECONDARY","TTL":60, "AliasTarget":{"HostedZoneId":"...","DNSName":"dr-lb"}}}]}'Probe the primary's /healthz; on failure DNS serves the secondary — the region-level circuit breaker.
In production
- Two-region e-commerce: PRIMARY health check on us-east-1; SECONDARY record on eu-west-1 with TTL 60.
- Azure global load balancer priority profile gates each region endpoint with probe cadence.
- Calculated health checks require 2 of 3 region endpoints before failing over (majority-decision).
Best practices
- Probe a path that reflects actual availability, not just TCP accept.
- Set FailureThreshold so a single probe blip doesn't failover the world.
- Keep the secondary TTL low too; failback must be deliberate, not flapping.
- Add alerting to the health check transitions to know when DNS actually rerouted.
Common mistakes
- Health check on '/' when the real dependency is /healthz — missing the outage.
- Threshold 1 → flapping failovers on transient 503s.
- No alert on health-state change: DNS rerouted silently.
- Failback (PRIMARY re-passes) without a steady-state; traffic flaps between regions.
Common issues
Region failed but DNS still serves itHealth check unhealthy but TTL/cache served the old record
Lower TTL on failover records and confirm the check flipped before expecting failover.
Failover flapped 4 times/hourThreshold too low or probe path flaky
Increase FailureThreshold + interval; fix the probe dependency.
Debugging tips
- 'Failover didn't happen': check the health check state directly, then TTL.
- A region that probed fine but apps were down = the probe didn't exercise the real path — widen it.
- Flapping between regions: raise thresholds and add a 'recovery' delay.
- Verify from a probe region perspective: probe source locates the failure geographically.
Interview checkpoint
Hands-on lab
- Wire a health-check + failover pair conceptually
- Simulate the failover timer math
- Practice the postmortem flow
Build and Qualify a DNS Failover Design
25 min · advanced
Quick quiz
Which sequencing bounds the end-to-end DNS failover time?