Why names exist
You have already leaned on hostnames without examining them: the S3 URL in lesson 4-1, and the load balancer, whose public address AWS hands you as a name, not a number. Next unit's database does the same. Time to look at the machinery.
DNS (Domain Name System) is the internet's name-lookup service: given a hostname like myapp.com, it returns the current IP address. It exists because addresses change constantly — servers get replaced, load balancers move, databases fail over to a standby — and every config file that stored the name keeps working through all of it, while every config file that stored the number breaks. That is the working rule: configure names, let DNS resolve the number at the last moment.
A lookup is called resolving a name, and the software that does it (built into every OS and browser) is a resolver.
Code exercise · bash
DNS at its core is a lookup table maintained by whoever owns the domain. This function is that table for myapp.com. Run it, including the miss: NXDOMAIN (non-existent domain) is DNS's "no such name" answer, and you will meet it in real error messages.
Records, TTLs, and Route 53
Each row in that table is a record. The two you will actually touch:
- An A record maps a name to an IP address:
myapp.com → 3.91.44.10. - A CNAME record maps a name to another name:
www.myapp.com → myapp.com. This is how you point at AWS resources whose IPs you never learn, like a load balancer.
Every record carries a TTL (time to live): the number of seconds a resolver may cache the answer before it must ask again. TTLs exist because the world cannot re-ask DNS on every request — caching keeps lookups fast and cheap. The trade-off is staleness: with a TTL of 86,400 (one day), a changed record keeps serving the old address from caches for up to a day. Records that must move fast, like a database endpoint that fails over, use short TTLs.
Route 53 is AWS's DNS service (named for port 53, where DNS listens). You buy or import a domain, it hosts your records for $0.50 per month per domain, and its alias records point straight at AWS resources — a load balancer, a CloudFront distribution — tracking their addresses for you.
Code exercise · bash
This is the caching decision every resolver makes: is the saved answer still inside its TTL? The starter shows a record cached at t=1000 with TTL 300. Your turn: a failover-sensitive endpoint uses TTL 60 instead. Change ttl to 60 and check t=1030 and t=1100.
Quiz
Tomorrow you will move myapp.com to a new load balancer. Today you lower the record's TTL from 86,400 to 60. Why?