Optimizing DNS for Sub-100ms Resolution
Every DNS resolution that misses the local cache adds a full network round-trip — sometimes several — before the browser can even begin the TCP handshake. On a cold lookup, a recursive resolver may need to query the root, a TLD nameserver, and the authoritative server in sequence, easily accumulating 150-300ms of latency. For performance-critical applications, keeping resolution under 100ms requires deliberate architectural choices at every layer.
The most impactful optimization is caching. Setting appropriate TTLs on your records — long enough to be useful, short enough to allow operational flexibility — directly reduces the fraction of queries that trigger upstream lookups. Prefetching (resolving domains before the user clicks) and preconnecting (establishing TCP/TLS connections ahead of time) shift the latency cost out of the critical path. On the authoritative side, anycast routing ensures that queries are answered by the geographically nearest server instance.
Beyond the basics, EDNS Client Subnet (ECS) allows resolvers to include truncated client IP information in upstream queries, enabling CDN-aware authoritative servers to return geographically optimal answers. Minimizing the number of CNAME chains, consolidating nameserver delegations, and keeping DNSSEC signature sizes small all contribute to faster responses. Measuring with tools like dig, drill, or dnslab.dev's own lookup tool helps identify where the bottlenecks actually are.