See It Flow
Interactive guide · 9 chapters · ~20 min read

DNS Production Engineering

Running DNS in production is a different discipline from understanding a lookup. It's about caching strategy, global routing, failure detection, and understanding how DNS fails in production.

Mangesh MandlikLast updated:
01 · Performance

DNS Caching

In production, TTL is a dial you tune deliberately — trading propagation speed for resolver load and lookup latency.

A high TTL (hours or a day) means fewer lookups reach your authoritative servers, lower latency for most users, and less load on your DNS provider — but it also means changes take longer to reach everyone. A low TTL (seconds to minutes) reduces the cache window for changes and DNS-based failover, at the cost of more queries hitting your authoritative infrastructure.

Static, rarely-changing records

MX records, NS records, and long-lived A records for stable infrastructure can often use long TTLs (hours to a day) because they rarely change and benefit from lower resolver load.

Records behind active failover / load balancing

Records that need to react quickly to health changes should use relatively short TTLs (often tens of seconds to a few minutes). That narrows the stale-cache window, but DNS failover is still bounded by health-check detection and by whatever browsers, OS resolvers, and recursive resolvers have already cached.

02 · Global scale

CDN & Geo Routing

DNS is one of the control-plane mechanisms a CDN or globally distributed service uses to steer users toward an appropriate edge or regional entry point before the deeper caching and origin-selection logic takes over.

GeoDNS

The authoritative nameserver estimates where the recursive resolver is located (usually from the resolver IP, sometimes improved by ECS/EDNS Client Subnet) and returns a region-specific answer — for example, a European resolver may receive a European edge or regional ingress IP.

Anycast

The same IP address is announced from many physical locations at the network (BGP) layer; routers deliver traffic to the topologically nearest announcing location. DNS commonly hands out an anycast address, while the CDN and network layer do the detailed work of getting the user to a nearby edge.

Latency-based routing

Some DNS providers (e.g. Route 53) measure real network latency from various vantage points to each candidate region and route users to the lowest-latency option rather than pure geographic proximity.

03 · Scaling

Load Balancing

DNS round robin is a simple form of traffic steering: DNS decides which IPs clients learn about, but it does not sit in the request path making per-request balancing decisions.

Authoritative NS3× A recordsServer 1Server 2Server 3
The authoritative nameserver rotates through multiple A records for the same domain.

Round robin

The authoritative server can rotate record order on each response, or return several IPs and let the client/resolver use them in its own order, spreading traffic only roughly over time.

Weighted routing

Some providers support assigning traffic percentages per record (e.g. 90% to the primary region, 10% to a canary region) instead of pure even rotation.

04 · Reliability

Failover

DNS-based failover removes an unhealthy target from future answers — coarser and slower than an application load balancer, but works even without one.

A DNS provider with health-check integration (Route 53, Cloudflare Load Balancing, NS1) continuously probes each candidate endpoint. When a probe starts failing consistently, the provider stops including that endpoint in new answers — but only for clients performing fresh lookups after the health system has detected the problem.

Worked example: worst-case DNS failover (assumed values)

Assumptions: health checks every 10 s, an endpoint is marked unhealthy after 3 consecutive failures, and the record TTL is 60 s. Worst case, the endpoint dies just after a passing probe, so the failing probes land at +10 s, +20 s and +30 s: detection ≈ interval × threshold = 30 s. A resolver that cached the old answer just before the provider updated it keeps serving it for up to one full TTL: worst case ≈ 30 s + 60 s = 90 s, plus the provider's own propagation of the change. With a 300 s TTL the same math gives ≈ 330 s. Clients that cache beyond the TTL (some browsers, OS caches, resolvers that clamp TTLs) can stay on the dead endpoint longer than any computed figure, so treat this as a floor on the bound, not a guarantee.

05 · Detection

Health Checks

Health checks are what turn DNS from a static phonebook into a system that reacts to real infrastructure state.

Active checks

The DNS/traffic-management provider itself sends periodic HTTP or TCP probes to each endpoint from multiple global vantage points, marking it unhealthy after a threshold of consecutive failures (to avoid flapping on transient blips).

Passive / synthetic checks

Some setups also feed real traffic error rates or synthetic transaction results into the same health signal, catching failures that a simple TCP handshake wouldn't.

06 · Change management

DNS Propagation

"DNS propagation" isn't the record spreading to new servers — it's every existing cached copy gradually expiring and being refreshed.

Record updated → fully propagatedUpdate atauthoritative NSSome resolversstill cache old IPTTL expireseverywhereFullypropagated
The change is immediate at the authoritative source; when users observe it depends mostly on existing caches aging out.
07 · Observability

DNS Monitoring

DNS is invisible until it breaks — production DNS monitoring checks resolution time, error rates, record accuracy, and expiry dates explicitly rather than assuming it "just works."

Query latency & error rate

Track resolution time and NXDOMAIN/SERVFAIL rates from multiple regions — a spike often precedes a broader outage.

Record drift detection

Continuously verify that live DNS records match what's declared in infrastructure-as-code (Terraform, etc.) — manual out-of-band changes are a classic source of incidents.

Domain & DNSSEC expiry monitoring

Domain registration and DNSSEC key expirations are a recurring, entirely preventable cause of outages — automated expiry alerts are standard practice.

08 · Failure modes

Common Production Issues

A handful of recurring DNS failure patterns show up again and again in production incidents.

Expired domain registration

A highly avoidable outage class — a domain lapses and every record under it vanishes. Prevented entirely by auto-renewal and expiry alerts.

Misconfigured or dangling records

A CNAME pointing at a decommissioned third-party resource (e.g. a deleted S3 bucket or old load balancer) — this is also a security risk known as subdomain takeover, where an attacker claims the abandoned resource and hijacks the subdomain.

TTL set too high before an urgent change

During an incident requiring an emergency IP change, a long-lived TTL from before the incident means many clients keep hitting the failed IP long after the fix is live.

DNS provider outage

If your DNS provider itself goes down, your domain is unreachable regardless of how healthy your actual servers are — this is why some large organizations run DNS across two independent providers.

09 · Practice

Debugging DNS

A small set of command-line tools cover almost every DNS debugging scenario an engineer will face.

bashBasic lookup with full trace of the resolution path
dig +trace example.com
bashQuery a specific record type against a specific resolver
dig MX example.com @8.8.8.8
bashReverse lookup
dig -x 93.184.216.34
bashCheck what a specific authoritative nameserver returns directly (bypassing all caches)
dig example.com @ns1.example.com
Key takeaways
  • Choose TTLs per record: long for stable NS/MX records, short (tens of seconds to a few minutes) for records behind failover, and lower them days before a planned cutover.
  • DNS failover is bounded by detection time plus cache lifetime: with 10 s checks × 3 failures and a 60 s TTL, the worst case is about 90 s before well-behaved clients move, and longer for clients that over-cache.
  • DNS round robin and DNS failover complement an in-path load balancer; they do not replace its per-request health awareness.
  • Audit for dangling CNAMEs after decommissioning resources, and alert on domain registration and DNSSEC key expiry — both are preventable outages.
  • A single DNS provider is a single point of failure for the whole domain; large organisations mitigate it with two independent providers.