CDN

What is it?

  • Instead of every user traveling to one central "origin" server to get data, the CDN places copies of that data in various locations around the world so it’s closer to the user.
    • Example: Think of it like a chain of local warehouses for a major retailer. If you order a pair of shoes, it’s much faster if they ship from the warehouse in your city rather than the main factory halfway across the globe.
  • Used to cache the static content.
    • Example: S3 buckets, or Load Balancer response.
  • TTL (time to live) — how much time to cache?
  • We also have the abilities to remove cache (it is called Invalidations).
  • If we use CDN, new Domain name is provided.

How the process works?

When a user visits a website using a CDN, the magic happens in four main steps:

  1. The Request: A user enters a URL. Their browser sends a request for content (like an image or a video).
  2. The Routing: The CDN uses a process called Anycast or DNS redirection to figure out which "Edge Server" is geographically closest to that user.
  3. The Cache Check: * Cache Hit: If the local Edge Server already has the file, it serves it immediately.
    • Cache Miss: If the server doesn't have the file, it goes back to the Origin Server (the main host), grabs a copy, stores it for future use, and then gives it to the user.
  4. Delivery: The content is delivered over a much shorter physical distance, reducing latency.
SuperMade with Super