Lesson 8 of 9 · 27m
DNS Failover Patterns and TTL Reality
Compare multi-address answers, health-checked DNS failover, anycast, and traffic managers while respecting cache inertia.
DNS failover is usually sold as a magic health check: if the primary dies, the record changes and users move to the standby. In practice, caching resolvers, client behavior, TLS, application state, and split-brain risk decide whether failover works. DNS can steer traffic, but it cannot guarantee that every client notices steering changes quickly.
Multiple answers are the simplest resilience pattern
Returning several A or AAAA records lets clients choose among endpoints:
www.sudosecurity.org. 300 IN A 203.0.113.20
www.sudosecurity.org. 300 IN A 203.0.113.21Resolvers may reorder answers, and clients may prefer the first address, randomize, or implement their own failover logic. This pattern spreads load and survives endpoint failure only when both endpoints can serve the same application state. It is not controlled failover; it is ambiguity with benefits.
Health-checked records have cache inertia
A typical traffic manager queries a health endpoint and changes DNS answers when checks fail:
normal: www -> 203.0.113.20
degraded: www -> 198.51.100.20
TTL: 30 secondsEven with a 30-second TTL, real recovery time is worse than thirty seconds. Some resolvers cap minimum TTLs, clients cache independently, and browsers reuse connections. Worse, users who already hold the old answer continue hitting the dead service until their cache path expires it. Expect minutes, not seconds.
Failover can create split brain
If both regions write to independent databases, DNS failover may create two active versions of truth. Before using DNS for disaster recovery, answer the application questions:
Is the standby read-only or writable?
Does state replicate synchronously or asynchronously?
What happens when the primary returns?
Are sessions portable?
Does the TLS certificate cover the same names?DNS is only one layer in the failover design. It is often the least sophisticated layer.
Anycast and load balancers solve different problems
Anycast advertises the same IP from multiple network locations. Routing sends users to a nearby or surviving site without changing the DNS answer. Load balancers keep a stable virtual IP while shifting traffic across backends. These mechanisms can be more reliable than DNS switching, but they require infrastructure maturity. Many resilient designs combine them: anycast authoritative DNS, stable service anycast or load-balanced endpoints, and DNS only for high-level service discovery.
Design for brownouts, not just total failure
Health checks often test a shallow /healthz that returns 200 while authentication, storage, or a downstream dependency is broken. A failover system then keeps sending users to a wounded service or flaps between sites. Define health as user-visible success, include dependency sanity, and dampen transitions so one bad probe does not oscillate the Internet.
Field notes
- TTL 0 does not mean universal real-time lookup; some resolvers and clients cache anyway.
- CAA, MX, TXT verification, and service records need failover thought too, not only the web A record.
- Test failover by observing real resolver behavior and application writes, not by watching the DNS provider dashboard turn green.
- Returning both primary and standby addresses during planned failover can be safer than a hard switch when users can tolerate either endpoint.
Was this lesson helpful?