Systems-At-Scale

Content Delivery Networks (CDNs) in Large Scale Systems

Content Delivery Networks (CDNs) play an instrumental role in scaling web systems to cater to millions or even billions of users globally. This document provides an overview of how CDNs function within the context of large-scale systems.

Purpose of CDNs:

CDN Architecture:

CDN’s architectural design aims to distribute content to end-users from the nearest location. The main components include:

  1. Origin Server: The primary server holding the website content or web application. The CDN populates its cache using this server.
  2. Edge Servers: Distributed cache servers of the CDN, located worldwide. They store cached content versions and deliver them based on user proximity.
  3. PoP (Point of Presence): Physical data centers housing one or more edge servers. Each PoP is strategically positioned in different locations for specific user groups.
  4. Regional Cache: Serves as a buffer with a centralized cache compared to edge servers. If content is not found in an edge server, it’s retrieved from the regional cache before resorting to the origin server.

CDN Workflow in Large Scale Systems:

  1. Request Routing: Upon content request, the CDN identifies the optimal edge server. It uses factors such as server health, user proximity, and cache freshness.
  2. Content Retrieval:
    • Direct delivery to the user if content is fresh and available in the edge server’s cache.
    • If missing or outdated, the edge server might consult a regional cache.
    • If not in the regional cache, it’s fetched from the origin server, then cached on the edge for future requests.
  3. Content Delivery: After determining the server and fetching the content, it’s delivered to the user. The CDN employs optimizations like content compression or SSL offloading during this phase.
  4. Cache Invalidation: Policies are in place to refresh or evict outdated content. Methods such as “Time-to-Live” (TTL) or cache purging are employed to manage cache lifecycle.
  5. Data Analytics: CDNs provide content access patterns, traffic data, and potential security threats insights to support business decisions.
  6. Load Balancing: CDNs distribute traffic across numerous servers during high traffic scenarios or server outages, ensuring consistent performance and high uptime.
  7. Security Layers: To counteract threats like DDoS attacks, CDNs come equipped with security features like Web Application Firewalls (WAF).