Web & Network5 min readLast updated: Wed Mar 13 2024 00:00:00 GMT+0000 (Coordinated Universal Time)

What is a CDN? (Content Delivery Network)

If your server is in New York, a user in Tokyo has to wait for data to travel halfway across the world. Speed of light limits mean this will always have latency (lag).

The Solution: CDN

A Content Delivery Network is a network of servers distributed globally.

  1. Origin Server: This is your main server (in New York).
  2. Edge Servers: These are CDN servers in Tokyo, London, Sydney, etc.

How it works

  1. The first time a user in Tokyo requests image.jpg, the CDN in Tokyo fetches it from New York. This is slow.
  2. The CDN caches (saves) image.jpg in Tokyo.
  3. The next user in Tokyo requests image.jpg. The CDN serves it immediately from the Tokyo server.

Benefits

  1. Speed: Lower latency for users.
  2. Reliability: If your main server crashes, the CDN can often still serve cached pages (like a "Site Offline" version).
  3. Security: CDNs often block DDoS attacks (floods of fake traffic) before they reach your server.

Common CDNs include Cloudflare, AWS CloudFront, and Akamai.