DNS
How a name becomes an address, what the common records do, and why TTL is the setting I check before any migration.
The phone book. It turns a shop name into its street address.
That is DNS. People type a name such as app.example.com. Machines need a number. DNS is the lookup that connects the two, and it is the first hop of almost every request.
How it works
A resolver asks DNS for a name and gets back an answer. The resolver then keeps that answer for a while so it does not have to ask again.
Browser → Resolver → DNS → 203.0.113.10
(cached for the TTL)
Browser → 203.0.113.10
The records that matter most:
- A and AAAA. A name points to an IPv4 or IPv6 address.
- CNAME. A name points to another name. This is how custom domains work in a multi-tenant product: the customer points their own name at mine.
- MX and TXT. These route email and prove who is allowed to send it, through SPF, DKIM and DMARC.
- TTL. How long a resolver may cache an answer.
The TTL is the setting that matters
A long TTL means fewer lookups and fast answers. It also means a change takes a long time to spread, because caches keep serving the old address. A short TTL spreads changes quickly, at the cost of more queries.
The habit to follow: lower the TTL a day or two before a migration, make the change, then raise it again. If you forget the first step, some users keep reaching the old server long after you moved.
Routing with DNS
DNS can also spread traffic. It can answer differently by region, or drop an unhealthy address from its answers. That is useful across regions. It is not the main failover tool, because resolvers and browsers cache answers and some ignore short TTLs. Pair it with a load balancer that can react in seconds.
Reading a lookup end to end
When a name is not cached, the resolver walks down the hierarchy: the root servers point to the servers for the top-level domain, and those point to the nameservers that hold the actual records. Each step can be cached, and each cache has its own timer. That is why two people can see different answers for the same name at the same moment during a change. Tools such as dig show the answer and the remaining TTL, and they check what a resolver currently believes instead of guessing from the provider's dashboard.
Where I used it
I haven't shipped this in a public project yet.
None of my case studies describe nameserver or record work, so I will not invent any. What I carry from this note is the checklist: lower the TTL first, keep a record of every name that points at the product, and know which provider answers for the domain.
Trade-offs
- Slow changes. Caching is what makes DNS fast, and it is also why a wrong record lingers. You cannot recall an answer that is already cached.
- A provider outage takes everything down. If the nameservers are unreachable, nobody can find the product, even when every server is healthy. DNS is a single point of failure unless the provider is resilient or you use more than one. Write that down as a known risk.
- Not a fast failover. DNS-based failover works in minutes at best. A load balancer reacts faster inside one region.
- Email depends on it too. A wrong TXT record does not break the website. It quietly sends your email to spam. Check SPF, DKIM and DMARC after any change.
- Short TTLs are not free. More queries means more load on the provider and a little more delay on first lookup. Use short TTLs around a change, not as a permanent default.
The rule I use: every public service needs DNS, so the decision is not whether to use it. The decision is how long to let the world remember your answers, and what happens on the day you need them to forget.