System Design · Concept Library · Free article
DNS
How a name like hatch.app becomes the numeric address the network can route to, and why the first lookup is often slower.
The network routes to numeric IP addresses, while people use names. DNS resolves a name to records such as an IP address. A resolver may walk a hierarchy of DNS servers, then cache the answer for its TTL. A cache hit is usually much faster because it avoids that external resolution, but it is not literally instant.
Names are for humans, numbers are for the network
You type hatch.app, but IP routing needs a numeric address such as 203.0.113.7. DNS, the Domain Name System, resolves the name to the records the client needs before it connects.
How a lookup resolves
A cache miss may require several queries. Your computer asks a resolver, which follows referrals from the root to the .app top-level domain and then to the authoritative server for hatch.app. The resolver returns the record and caches it for its TTL.
The interactive version of this example is available when JavaScript loads.
Who takes part
- Resolver: the helper (usually run by your network or a public service) that does the asking on your behalf.
- Root & top-level servers: the signposts: they do not know the final answer, they know who does.
- Authoritative server: the server that holds the records for that name.
Caching and time-to-live
DNS records have a time-to-live (TTL), which tells caches how long they may reuse an answer. A cache hit avoids repeating the external resolution path.
A first visit may therefore spend time resolving the name, while later visits can use an answer cached by the browser, operating system, or recursive resolver.
The record types worth knowing
| Record | What it maps | Plain meaning |
|---|---|---|
| A | name → IPv4 address | The classic "name to number." |
| AAAA | name → IPv6 address | Same idea, newer longer addresses. |
| CNAME | name → another name | "This name is really an alias for that one." |
| NS | name → its authoritative server | "Ask this server for the real answers." |
DNS as a routing tool
DNS can also return different answers to steer traffic, so it matters beyond the initial name lookup.
- Steer users by coarse location. A managed authoritative service may use the recursive resolver’s location, and sometimes EDNS Client Subnet, to return a regional address. It does not necessarily know the user’s exact location.
- Spread load coarsely. A name can return several addresses, but resolver caches and client address selection mean round-robin DNS does not guarantee even load.
- Support health-aware failover. A managed DNS service can stop returning an unhealthy address, but cached answers may remain until their TTL expires or a resolver’s stale-serving policy replaces them.
What goes wrong
What to remember
Sources and further reading
By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.