Introduction to DNS
easy 25 minDNS is the distributed database that turns names such as www.example.com into addresses computers can connect to.
When it comes up
The moments this idea belongs in a design interview, and the moments it does not.
Signals
When to bring it up
| You hear | Say | Because |
|---|---|---|
| Users on several continents | GeoDNS or latency routing to a regional balancer | The first decision is made before a connection exists |
| Customers bring their own domain | They add a CNAME to a name we control | We can move servers without asking them |
| A region can fail | Health-checked DNS with a short TTL | New lookups move in about a TTL, plus detection |
| Serve images faster | CNAME to a CDN | The CDN picks the nearest edge |
| Move in seconds, per request | Not DNS alone | Caches hold old answers |
Options
Compare your moves
Clients must find an API whose servers come and go every few minutes. How?
BreaksShip the server addresses in the app
- How
- A list of addresses inside the client.
- Limit
- Every change needs a new release, and old clients call dead machines.
- Choose when
- Never for servers you do not control for ever.
WorksOne name with many A records
- How
- Publish each server's address with a short TTL.
- Limit
- Stale answers, uneven load, and no view of how busy a server is.
- Choose when
- A few stable servers and patient clients that try the next address.
StrongOne name for a load balancer
- How
- DNS points at a stable balancer address. The balancer checks health and picks a server per request.
- Limit
- The balancer must be redundant and adds a hop.
- Choose when
- Almost always for a public API.