AlgoViz

Introduction to DNS

easy 25 min

DNS 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 hearSayBecause
Users on several continentsGeoDNS or latency routing to a regional balancerThe first decision is made before a connection exists
Customers bring their own domainThey add a CNAME to a name we controlWe can move servers without asking them
A region can failHealth-checked DNS with a short TTLNew lookups move in about a TTL, plus detection
Serve images fasterCNAME to a CDNThe CDN picks the nearest edge
Move in seconds, per requestNot DNS aloneCaches 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.