Content Delivery Networks

What it is

A Content Delivery Network (CDN) is a distributed network of servers that collectively act as proxies for webpages or other content. Instead of a single server in a datacenter, your website is served by an entire network of computers all across the world. If your site is loaded in China, that request is routed to the CDN’s China-based datacenter, decreasing load times.

This layer of abstraction makes sites faster and more reliable, and reduces the maintenance burden on the person creating the site. CDNs can also handle many other features commonly handled by a reverse proxy, such as caching, encryption, and compression, to name a few.

There are lots of CDN providers. Every major cloud platform offers one, like Amazon AWS’s CloudFront, Microsoft's Azure CDN, Google Cloud CDN, or Rackspace CDN. MaxCDN and Cloudflare are also extremely popular standalone CDNs.

Why it matters

The most basic way to host a website on the internet is to run a web server like apache on a single machine. Indeed, if you gave it a static IP address, you could run a web server directly from your desktop computer.

However, this creates all kinds of problems. What happens if the computer crashes? What happens when the site starts getting popular and the single machine can no longer handle all the incoming traffic?

The logistical and quality struggles with building your own servers is what gave rise to what we call the cloud, managed servers as service. Nowadays, you don’t need to manage the computer yourself, you can just spin up a virtual instance on AWS EC2 or something similar.

But you still have a problem. That EC2 instance is still just a single computer running somewhere. What if it breaks? What if someone loads your site from the other side of the planet? Even if your sever is extremely powerful, load times quickly can become limited by the speed of light itself. If it takes 100s of milliseconds for the packets to reach China, that delay will be noticeable by the end user.

The only way around this is to cache your content in proxy servers all around the world. This provides the additional benefit of providing fallbacks if one server fails. This is exactly what a CDN is for.

Related guides

How to learn it

Picking a good CDN is a subjective choice that relies on lots of different variables like features and cost. The deciding factor for me was using a service that was easy to set up and plug in to my existing hosting provider.

I host this site using AWS S3, so setting it up to serve it through Cloudfront was just a couple of clicks. Setting up HTTPS with their certificate authority is similarly simple. The best thing about AWS is that since they offer so many different services, you can do everything in a single ecosystem and they are easy to hook together.

I used to work at Amazon so I’m obviously biased, but the numbers don’t lie. Picking AWS tools like Cloudfront is logical because you’ll likely end up using AWS services at one job or another.