CDN - Why Websites on the Other Side of the World Load Fast
Accessing a server in the US from Japan incurs over 50 ms of one-way latency just from crossing undersea cables. Yet when watching Netflix or YouTube, you barely notice this delay. The reason is CDN (Content Delivery Network).
A CDN distributes copies of content across servers (edge servers) around the world, delivering content from the server closest to the user. When you access IP Check-san, have you ever thought about which server the response is coming from?
How CDNs Work - Three Core Technologies
1. Distributed Edge Server Placement
Major CDN providers place servers in hundreds to thousands of locations worldwide. Cloudflare has presence in over 300 cities, and Akamai operates in over 130 countries. Within Japan, multiple edge servers are deployed in Tokyo, Osaka, and other locations.
2. DNS-Based Routing
When a user accesses a CDN-enabled site, DNS returns the IP address of the edge server closest to the user. A user in Tokyo gets the Tokyo edge server, while a user in London gets the London edge server. Because CDN routing depends on DNS, a DNS leak can cause your requests to be routed to the wrong edge server, increasing latency instead of reducing it.
3. Caching
Edge servers cache (temporarily store) content retrieved from the origin server. Subsequent requests for the same content are served instantly from the edge server's cache without querying the origin server.
Three Problems CDNs Solve
Latency Reduction
The speed of light has limits, and latency from physical distance is unavoidable. CDNs minimize this physical latency by placing content close to users. Accessing a US origin server from Tokyo takes over 100 ms RTT, but from a Tokyo edge server, it's under 5 ms.
Origin Server Load Reduction
Even when millions of users simultaneously access a popular site, the majority of requests are handled by edge server caches, dramatically reducing the load on the origin server.
DDoS Attack Mitigation
A CDN's distributed infrastructure spreads DDoS attack traffic across edge servers worldwide, mitigating attacks that would otherwise concentrate on a single server. Cloudflare and Akamai offer integrated CDN and DDoS protection services.
Behind the CDN - The Magic of Anycast
One mechanism CDNs use to route to the "nearest server" is Anycast. With Anycast, multiple servers around the world share the same IP address. When a user accesses that IP address, BGP routing automatically directs them to the network-nearest server.
Cloudflare's DNS service (1.1.1.1) is a prime example of Anycast. No matter where in the world you access 1.1.1.1, you reach the nearest Cloudflare server.
How to Tell If a Site Uses a CDN
- HTTP response headers: Headers like
Server: cloudflare,X-Cache: HIT, orVia: 1.1 varnishconfirm CDN usage - DNS CNAME: Checking a domain's DNS often reveals a CNAME pointing to a CDN provider's domain (e.g.,
d1234.cloudfront.net) - traceroute: If the final hop is within a CDN provider's network, you're accessing via CDN
Summary
CDNs are the Internet's most practical solution to the insurmountable constraint of physical distance. By bringing content closer to users, they effectively "bypass" the speed of light limitation.
When you access IP Check-san, try checking the response headers in your browser's developer tools. You might be able to read CDN cache hit status and edge server location information.