DNS and content delivery networks
Route users to the right place and serve content from the edge, close to them.
14 min readHow DNS resolves a name
DNS translates a domain such as shop.example.com into an IP address. The browser asks a recursive resolver, usually run by the ISP or a public provider, which walks the hierarchy from the root servers to the .com servers to the authoritative servers for example.com. Every answer carries a TTL that says how long resolvers may cache it. Long TTLs, such as an hour, make lookups fast and cheap; short TTLs, such as 60 seconds, let you change where traffic goes quickly, for example during a failover. Pick the TTL with your recovery time objective in mind.
DNS as a traffic tool
Because the authoritative server can return different answers depending on who asks and which endpoints are healthy, DNS doubles as a coarse load balancer across regions. It is coarse because it works per resolver, not per request, and because cached answers keep sending users to the old address until they expire. Use it to pick a region, and use a real load balancer inside the region to pick an instance.
- Round-robin records spread users across several IP addresses
- Geo or latency-based routing sends each user to the nearest region
- Health-checked failover removes a region that stops responding
- Limits: clients and resolvers cache answers, so changes take up to one TTL to apply
What a CDN does
A content delivery network is a fleet of caching servers in hundreds of locations, called points of presence. Users connect to the nearest one, often within 10 to 30 ms, instead of crossing a continent to your origin. On a hit the edge serves the content directly; on a miss it fetches from your origin, caches it according to its Cache-Control headers and serves later users from the edge. For static assets such as images, scripts, stylesheets and video segments, hit rates above 95% are common, which means your origin sees only a small fraction of the traffic.
Using a CDN well
Give static files content-hashed names such as app.3f9a2c.js and cache them for a year: a new version gets a new name, so you never need to purge. Cache public HTML and API responses for short periods, from a few seconds to minutes, which absorbs spikes without serving very stale content. Never cache personalised responses at the edge unless the cache key includes the user. On the SystCode canvas, placing a CDN in front of object storage or your API tier is the cheapest way to cut origin load and user latency at the same time.
Key takeaways
- DNS TTLs trade lookup speed against how fast you can redirect traffic
- DNS can route users to the nearest healthy region, but changes are not instant
- A CDN serves content from the edge, cutting latency and origin load together
- Use content-hashed file names with long TTLs; keep personalised content off the shared edge cache
Sign in to track lessons and earn badges.