Introduction to caching - Content Delivery Networks

Last revision:

Introduction

A content delivery network (CDN) is a geographically distributed network of servers that work together to provide fast delivery of Internet content.

A CDN facilitates the quick transfer of assets such as HTML pages, JavaScript files, CSS stylesheets, images, and videos.

Today the majority of web traffic is served through CDNs, including traffic from major sites like Facebook, Netflix, and Amazon.

How does a CDN work

CDNs are usually large and extremely complex, with hundreds of different kinds of servers working together to optimally orchestrate content delivery.

In its most basic form, a CDN consists of a reverse proxy server which coordinates with multiple content cache servers that are geographically spread around the internet.

Where a "simple" reverse proxy setup may have multiple cache servers all in the same physical location, a CDN spreads its cache servers across the globe.

You don't need a CDN to have a reverse proxy with multiple cache servers, but you DO need a CDN if you want your cache servers to be spread around the world and deliver your visitors' content by the servers that are closest to them. Or by the ones that have the fastest response time.

In a CDN:

  • The original content source (most likely your web server) is called an origin server.
  • The cache servers around the globe are called edge servers, because sit at the outer edge of the network.

Popular CDNs include:

Advantages

CDNs improve page load speeds by serving cached content and assets from the nearest (or fastest) available edge server.

Because assets are now served from CDN servers instead of your own servers, this typically results in reduced bandwidth costs.

Due to its distributed nature, a CDN can handle more traffic and withstand hardware failure better than many origin servers.

Many CDNs offer additional features such as optimization (compression) of media assets and protection against attacks.

Disadvantages

CDNs are built around reverse proxy servers, and share the same disadvantages.

As you add more tools like in-memory data stores, CDNs, application firewalls, and asset optimizers, you also add more complexity and rules around how long various types of content should be cached by the various cache layers.

More moving parts means a larger surface area where things can go wrong, and potentially more work troubleshooting incorrectly served content.

These disadvantages should not keep you from using a CDN, but you do have to be aware of the possible complexity you're adding to your infrastructure.

Summary

  • A CDN is a geographically distributed network of edge servers that serve cached content from the closest or fastest server available.
  • A CDN can improve page load speeds and reduce bandwidth on the origin server.
  • A CDN's complexity can make it harder to troubleshoot when and why outdated content is still being served instead of fresh content.