Skip to content

Domain Name System (DNS)

The Domain Name System turns names such as api.example.com into the addresses and service details a client needs to connect. It is the first hop of nearly every request, a cheap global traffic-steering tool and, when it fails, a way to take a healthy system offline. A designer needs to know how lookups and caching work, which records exist, and how to keep DNS from becoming the weakest link.

Four kinds of servers take part in a lookup:

  • Stub resolver: a small library in the OS. It asks one configured resolver and caches the answer.
  • Recursive resolver: run by the ISP, the corporate network, the cloud VPC, or a public service such as 1.1.1.1 or 8.8.8.8. It does the legwork and caches aggressively.
  • Root and TLD servers: they do not know the answer. They refer the resolver to the servers for .com, then to the servers for example.com. The root zone is served by 13 named server identities (A to M) run by 12 operators, backed by more than 2,000 anycast instances.
  • Authoritative server: holds the zone and gives the final answer.
sequenceDiagram
  participant B as Browser and<br/>OS stub
  participant R as Recursive<br/>resolver
  participant N as Root and<br/>TLD servers
  participant A as Authoritative<br/>for example.com
  B->>R: api.example.com,<br/>type A?
  Note over R: cache miss
  R->>N: api.example.com?<br/>(root server)
  N-->>R: referral to<br/>com servers
  R->>N: api.example.com?<br/>(com server)
  N-->>R: referral to<br/>example.com servers
  R->>A: api.example.com?
  A-->>R: 203.0.113.10, TTL 60
  R-->>B: 203.0.113.10, TTL 60

The stub sends one recursive query. The resolver then makes iterative queries, following each referral itself. Root and TLD referrals carry long TTLs (often days), so in practice a warm resolver goes straight to the authoritative server. A cold lookup can cost several round trips, which is one reason browsers prefetch DNS for links on a page.

Every answer carries a time to live set by the zone owner. Browsers, operating systems and resolvers count it down and reuse the answer until it expires. “DNS propagation” is just old cached answers expiring.

Short TTL (30–60 s)Long TTL (1 h – 1 day)
Moving traffic or failing overFastSlow: old answers live for up to one TTL
Query volume to authoritative serversHigh: up to 60 queries per hour per resolver at 60 sLow: one per hour at 3,600 s
Lookup latency seen by usersMore cache missesAlmost always cached
Exposure if the provider is downCaches empty quicklyCaches keep answering for a while

Practical rules:

  • Before a migration, lower the TTL, wait for at least one old TTL to pass, make the change, then raise the TTL again.
  • Negative answers are cached too. An “NXDOMAIN” response is cached for the smaller of the SOA record’s TTL and its MINIMUM field (RFC 2308). If you query a name before creating it, the “does not exist” answer can stick around.
  • Not every client honours TTLs. Some resolvers clamp very small values. Long-lived processes, such as JVMs with a DNS cache and connection pools that never re-resolve, may hold an address for hours. Don’t design for DNS failover faster than about a minute.
RecordPurposeNotes
A / AAAAName → IPv4 / IPv6 addressSeveral records give crude client-side spreading
CNAMEName → another nameCannot share a name with other records, so it cannot sit at the zone apex (example.com)
MXMail servers for the domain, with prioritiesLower value is tried first
NSWhich servers are authoritative for a zone or delegated subzoneMust match the delegation at the parent (registry)
TXTFree textDomain ownership checks, SPF, DKIM, DMARC
SRVHost and port for a service (_sip._tcp)Used by some protocols and by Kubernetes for named ports
CAAWhich certificate authorities may issue certificates for the domainCheap protection against mis-issuance (RFC 8659)
SOAZone metadata: primary server, serial, negative-cache TTLOne per zone
HTTPS / SVCBEndpoint, ALPN (for example h3) and other connection hintsRFC 9460 (2023); also allows aliasing at the apex

Alias / ANAME records. People want example.com itself to point at a load balancer or CDN hostname, but a CNAME is not allowed at the apex. Providers solve this with non-standard records that the authoritative server resolves itself and answers with plain A/AAAA records: Route 53 alias records, Cloudflare CNAME flattening, and ANAME or ALIAS records at other providers. Route 53 also does not charge for alias queries to AWS resources. The standards-based fix is the HTTPS record, as clients add support for it.

A managed authoritative server does not have to return the same answer to everyone. Common routing policies:

  • Weighted. Return endpoint A to 90% of queries and B to 10%. Uses: canary releases, draining a cluster before maintenance, splitting load across clusters of different sizes, A/B tests.
  • Latency-based. Return the region with the lowest measured latency from the resolver’s network.
  • Geolocation. Choose by country or continent. Uses: data-residency rules, localised content, licensing.
  • Failover. Return the primary while its health check passes, and the standby otherwise. Route 53, for example, probes from many locations and marks an endpoint unhealthy only when 18% or fewer of its checkers see it as healthy, so one isolated probe cannot trigger a failover.
  • Multivalue. Return several healthy addresses and let the client pick and retry.

Two limits apply to all of them. First, the authoritative server sees the resolver’s IP, not the user’s. A user in Madrid behind a resolver in Frankfurt looks German. EDNS Client Subnet (RFC 7871) lets resolvers pass a truncated client prefix, but privacy-focused resolvers often leave it out. Second, a busy resolver caches one answer for all its users, so a 90/10 weight produces roughly 90/10 resolvers, not exactly 90/10 requests.

flowchart LR
  subgraph geo["GeoDNS"]
    u1["User in EU"] -->|"gets 198.51.100.1"| eu["EU region"]
    u2["User in US"] -->|"gets 203.0.113.1"| us["US region"]
  end
  subgraph any["Anycast"]
    u3["User in EU"] -->|"192.0.2.1"| pop1["Nearest site"]
    u4["User in US"] -->|"192.0.2.1"| pop2["Nearest site"]
  end
GeoDNSAnycast
MechanismDifferent answers per resolver locationOne IP announced over BGP from many sites
Reaction to failureOne TTL plus client cachingRoute withdrawal, usually seconds to a minute
ControlFine-grained, per country or per weightCoarse: BGP picks the “nearest” site by network path
DDoS absorptionEach region takes its own attackAttack traffic is spread over all sites
RequirementsA managed DNS featureYour own IP space and BGP, or a provider that has it
Typical usersMulti-region appsRoot servers, public resolvers, CDNs, global load balancers

Anycast suits short UDP exchanges such as DNS. For TCP it works well as long as routes are stable, and large CDNs build their whole edge on it. Cloud products expose it as static anycast IPs: Google Cloud’s global load balancers and AWS Global Accelerator are examples. Many providers combine both: anycast for the authoritative DNS servers themselves, and GeoDNS-style answers for the application.

On 21 October 2016 the managed DNS provider Dyn was hit by three waves of DDoS traffic from the Mirai botnet, made up of compromised cameras, routers and other IoT devices. Sites that used Dyn as their only DNS provider, including GitHub, Netflix, Spotify and PayPal, became unreachable for many users in North America and Europe. Their servers were healthy, but nobody could look up their addresses.

In October 2021 Facebook showed the opposite failure. A backbone outage made its own DNS servers withdraw their BGP routes by design. Every Facebook domain stopped resolving, and so did internal tools engineers needed to fix the problem.

In October 2025 the failure came from automation instead. A race condition in AWS’s DNS management for DynamoDB left the us-east-1 endpoint with an empty record for nearly three hours, and the outage spread to EC2, load balancers and many services that depend on DynamoDB.

Mitigations:

  • Two independent authoritative providers. List both sets of NS records at the registrar and keep the zones identical, either through zone transfers (primary/secondary) or by pushing the same zone to both from code (octoDNS, Terraform). Proprietary routing policies rarely carry over between providers, so keep critical records simple or accept different behaviour on each side.
  • Keep DNS out of your own blast radius. Don’t host your only authoritative servers in the same network or region as the application they point to.
  • Break-glass access. Make sure consoles, VPNs and runbooks are reachable when your own names do not resolve.
  • Monitor from outside. Check resolution of key names from several networks, not only from inside your VPC.
  • Sensible TTLs. Moderate TTLs (minutes, not seconds) let caches keep serving through a short provider outage.

Classic DNS travels in plaintext over UDP port 53, so anyone on the path can read or tamper with it. DNS over TLS (DoT, RFC 7858, 2016) wraps queries in TLS on port 853. DNS over HTTPS (DoH, RFC 8484, 2018) sends them as HTTPS requests on port 443, where they are hard to tell apart from web traffic. DNS over QUIC (RFC 9250, 2022) followed. Major browsers and operating systems support encrypted DNS. This protects only the hop from the client to its resolver, and it can bypass corporate split-horizon DNS and filtering, which matters in enterprise networks. The server name still leaks in the TLS handshake unless the site uses Encrypted Client Hello (RFC 9849, 2026), whose keys are published in the HTTPS record. Encryption gives privacy, not authenticity. DNSSEC addresses authenticity by signing records, and it is a separate decision.

Typical choices are Amazon Route 53, Cloudflare DNS, Google Cloud DNS, Azure DNS (with Azure Traffic Manager for DNS-based routing), IBM NS1 Connect and Akamai Edge DNS. All of them offer anycast authoritative servers, an API and health-checked routing to some degree. Inside Kubernetes clusters, CoreDNS serves service names, which is covered in service discovery.

DNS-based steering gives youIt costs you
Global reach with no extra hop in the data pathReaction time bounded by TTLs and misbehaving caches
Simple weighted or regional splitsDecisions based on the resolver’s location, not the user’s
Health-checked failover between regionsCoarse granularity: no per-request or per-path routing
A managed service with a strong SLAA critical dependency that needs its own redundancy

Based on The System Design Primer by Donne Martin (CC BY 4.0). Restructured, rewritten and updated; site content is licensed under CC BY 4.0.