01

Why this matters

Distributed systems face two core challenges: read latency and read scalability. Users in distant regions experience slow content delivery when accessing data from a single remote data center. High concurrency loads strain both server capacity and network bandwidth.

A content delivery network (CDN) directly addresses these issues by distributing content geographically.

02

What is a CDN?

A CDN is a distributed network of servers placed globally to deliver web content as quickly as possible.

Without a CDN, all users access content from a single geographic location.

With a CDN, users fetch content from servers closer to their location.

03

How a CDN Works

A web content server stores content in a region, such as the United States.

A domain name is registered with a CDN provider, like Amazon CloudFront.

A new domain name is provided, which is then used in a web page.

When a user loads the page, the browser requests content from the CDN instead of the original server.

The CDN selects the closest server to the user.

The CDN server acts as a read-through cache.

If the content is cached, it is returned immediately.

If not cached, the CDN server retrieves the content from the original server and caches it for future requests.

This model is called a pull CDN.

There is also a push CDN, where content is pushed to CDN servers every time it is published.

When content is cached, a time-to-live (TTL) must be configured.

HTTP headers can control TTL.

04

CDN Architecture

A point of presence (POP), also known as an edge location, is a collection of servers in a specific geographic region.

Each POP contains two types of servers:

  • Cache servers: store content for user access.
  • Request routing servers: know about all cache servers in the POP and reference other POPs.

CDN providers register request routing servers with internet service providers in each region.

The DNS resolver of a user’s ISP resolves the CDN domain name to the IP address of the request routing server in the closest POP.

The closest POP is found using anycast routing.

The request routing server selects a cache server and returns its IP address.

The browser connects to that cache server.

If the current POP is busy or suboptimal, the request may be forwarded to a different POP.

05

Benefits of Using a CDN

  • Reduces read latency for users in distant regions.
  • Improves read scalability under high concurrent loads.
  • Builds redundancy through multiple data copies.
  • Enables failover when a POP fails.
  • Increases system reliability.
  • Balances network traffic across servers.
  • Helps protect against DDoS attacks via anycast and load balancing.

Questions

  • What is the role of TTL in a pull CDN?
  • How does anycast routing help in selecting the closest POP?
  • Why is a request routing server necessary in a POP?
  • What happens when a user requests content that is not cached?
  • How does a push CDN differ from a pull CDN?
  • What is the purpose of cache servers in a POP?
  • How does a CDN reduce network bandwidth usage?
  • What is the relationship between CDN and failover?

Key takeaways

  • A CDN delivers content from geographically close servers to reduce latency.
  • It improves scalability by distributing load across multiple locations.
  • It uses cache servers to serve content from memory, reducing direct server load.
  • Pull CDNs retrieve content on demand from the origin server.
  • Push CDNs replicate content automatically on publication.
  • TTL controls how long content is cached.
  • HTTP headers can set TTL values.
  • A POP contains cache and request routing servers.
  • Anycast routing selects the closest POP.
  • CDNs provide redundancy, failover, and traffic balancing.
  • CDNs enhance reliability and protect against DDoS attacks.