How DNS resolution works
When a browser requests api.streamhub.com, it does not know the server's IP. A multi-step lookup resolves the name.
DNS lookup path (Route 53)
StreamHub production architecture (AWS)
Resolution chain
- Browser cache — recent lookups cached for TTL seconds.
- OS resolver cache — local stub resolver.
- Recursive resolver — ISP DNS or public resolver (8.8.8.8, 1.1.1.1).
- Root → TLD → authoritative — delegation until the domain's nameserver answers.
- A/AAAA record — IPv4 or IPv6 address returned to the client.
# Trace a lookup (simplified)
dig +trace api.streamhub.com A
# Check TTL — how long clients cache this answer
dig api.streamhub.com | grep -E 'ANSWER|IN A'
DNS record types you need
| Record | Purpose | Example |
|---|---|---|
| A / AAAA | Hostname → IP | api.streamhub.com → 52.12.34.56 |
| CNAME | Alias to another name | www → streamhub.com |
| MX | Mail server | mail.streamhub.com |
| TXT | Verification, SPF, DKIM | v=spf1 include:... |
| NS | Authoritative nameserver | ns1.cloudprovider.com |
| SRV | Service location | _https._tcp service discovery |
A / AAAA
PurposeHostname → IPExampleapi.streamhub.com → 52.12.34.56CNAME
PurposeAlias to another nameExamplewww → streamhub.comMX
PurposeMail serverExamplemail.streamhub.comTXT
PurposeVerification, SPF, DKIMExamplev=spf1 include:...NS
PurposeAuthoritative nameserverExamplens1.cloudprovider.comSRV
PurposeService locationExample_https._tcp service discovery
For system design interviews, A/AAAA, CNAME, and TTL matter most.
TTL and caching trade-offs
TTL (time to live) controls how long resolvers cache a record.
| Aspect | Low TTL (60s) | High TTL (3600s) |
|---|---|---|
| Failover speed | Fast — clients pick up new IP quickly | Slow — stale IPs during migration |
| DNS load | More queries to authoritative NS | Fewer queries, lower cost |
| Use case | Blue-green deploys, DR drills | Stable CDN CNAMEs |
Failover speed
Low TTL (60s)Fast — clients pick up new IP quicklyHigh TTL (3600s)Slow — stale IPs during migrationDNS load
Low TTL (60s)More queries to authoritative NSHigh TTL (3600s)Fewer queries, lower costUse case
Low TTL (60s)Blue-green deploys, DR drillsHigh TTL (3600s)Stable CDN CNAMEs
StreamHub uses 60-second TTL on API endpoints during migrations and 300 seconds in steady state.
DNS in scaled architectures
DNS roles at scale
- Load balancing — multiple A records (round-robin DNS) or CNAME to an LB hostname.
- Geographic routing — Route 53 latency-based or geolocation policies send users to the nearest region.
- CDN — CNAME
cdn.streamhub.com→d111111abcdef8.cloudfront.net. - Service discovery — internal DNS (CoreDNS in Kubernetes) maps
streamhub-api.default.svc.cluster.local.
# Example Route 53 weighted routing during canary
api.streamhub.com:
- type: A
alias: lb-us-east-1
weight: 90
- type: A
alias: lb-us-east-1-canary
weight: 10
DNS as a failure point
DNS outages take down services that are otherwise healthy. Mitigations:
- Use managed DNS with anycast (multiple global PoPs).
- Keep TTLs low enough for failover but not so low that you DDoS yourself.
- Monitor resolution time and NXDOMAIN rates.
- Have a runbook for nameserver migration (pre-lower TTL 24h before change).
# Health check from multiple regions
curl -w '%{time_namelookup}\n' -o /dev/null -s https://api.streamhub.com/health
Internal vs external DNS
External DNS faces the public internet. Internal DNS resolves service names inside a VPC or Kubernetes cluster — critical for microservice-to-microservice calls without hard-coded IPs.
External: api.streamhub.com → public ALB
Internal: video-service.prod → 10.0.4.22 (pod IP, short TTL)
Quick recall
Everything you need if you only revisit this box.
- DNS maps hostnames to IPs through recursive and authoritative resolvers.
- A/AAAA for IPs, CNAME for aliases; TTL balances failover speed vs query load.
- Low TTL for migrations; higher TTL for stable CDN endpoints.
- DNS enables geo-routing, CDN CNAMEs, and internal service discovery.
- DNS failure makes healthy servers unreachable — use managed anycast DNS.
- Always include DNS in end-to-end traffic diagrams.
Test yourself
Answer these before moving on — recall is what makes it stick.