{"id":67,"date":"2025-06-03T02:47:25","date_gmt":"2025-06-03T02:47:25","guid":{"rendered":"https:\/\/sreschool.com\/blog\/?p=67"},"modified":"2025-06-03T02:47:26","modified_gmt":"2025-06-03T02:47:26","slug":"how-a-cdn-works","status":"publish","type":"post","link":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/","title":{"rendered":"How a CDN Works?"},"content":{"rendered":"\n\n\n<p>A <strong>Content Delivery Network (CDN)<\/strong> is a globally distributed network of servers that <strong>delivers content to users faster<\/strong> by serving it from a <strong>location close to them<\/strong>. Let\u2019s break it down:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d <strong>What is a CDN?<\/strong><\/h3>\n\n\n\n<p>A <strong>CDN<\/strong> is a <strong>system of edge servers<\/strong> located around the world that cache and deliver static and dynamic content like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>HTML pages<\/li>\n\n\n\n<li>Images<\/li>\n\n\n\n<li>Videos<\/li>\n\n\n\n<li>CSS &amp; JS files<\/li>\n\n\n\n<li>APIs<\/li>\n<\/ul>\n\n\n\n<p>Instead of every user hitting your <strong>origin server<\/strong> (e.g., in the U.S.), the CDN <strong>serves a cached version<\/strong> of the content from the nearest <strong>edge location<\/strong> (e.g., Tokyo for users in Japan).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f <strong>How a CDN Works \u2013 Step by Step<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udfe1 First-Time Request (Miss):<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A user requests a file (e.g., image.jpg).<\/li>\n\n\n\n<li>The request goes to the <strong>nearest CDN edge server<\/strong> (based on GeoDNS or latency).<\/li>\n\n\n\n<li>If the edge <strong>doesn\u2019t have the file<\/strong> (cache miss), it:\n<ul class=\"wp-block-list\">\n<li>Fetches it from the <strong>origin server<\/strong> (e.g., your S3 bucket or Lightsail instance)<\/li>\n\n\n\n<li>Caches it locally<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Returns it to the user.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udfe2 Next Requests (Hit):<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Future requests from nearby users <strong>hit the cached copy<\/strong> on the edge server.<\/li>\n\n\n\n<li>The file is served <strong>instantly<\/strong> without contacting your origin.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd04 <strong>Illustration of Flow<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>User \u2192 Edge Server (CDN) \u2192 Origin Server (only if needed) \u2192 CDN \u2192 User\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\uddf0 <strong>Key CDN Features<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><strong>Caching<\/strong><\/td><td>Static files (and optionally dynamic content) stored temporarily on edges<\/td><\/tr><tr><td><strong>Geo-based Routing<\/strong><\/td><td>Delivers content from the server closest to the user<\/td><\/tr><tr><td><strong>HTTPS\/SSL<\/strong><\/td><td>Secure transmission with custom or free certificates<\/td><\/tr><tr><td><strong>Edge Functions<\/strong><\/td><td>Customize request\/response at the edge (e.g., with Lambda@Edge or Workers)<\/td><\/tr><tr><td><strong>DDoS Protection<\/strong><\/td><td>Mitigates attacks by absorbing traffic across global nodes<\/td><\/tr><tr><td><strong>Custom Headers\/Rules<\/strong><\/td><td>Control caching behavior, redirects, A\/B tests<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\udde0 <strong>Real-World Analogy<\/strong><\/h3>\n\n\n\n<p>Imagine you own a bakery in New York, but your customers are in Tokyo, Paris, and Sydney.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Without a CDN<\/strong>: Every customer orders from your NY store \u2014 slow shipping.<\/li>\n\n\n\n<li><strong>With a CDN<\/strong>: You store your pastries in freezers near Tokyo, Paris, Sydney \u2014 fast delivery!<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u26a1 <strong>Benefits of CDN<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Benefit<\/th><th>Why It Matters<\/th><\/tr><\/thead><tbody><tr><td>\ud83d\ude80 Faster Load Times<\/td><td>Content loads quicker from nearby servers<\/td><\/tr><tr><td>\ud83d\udcc8 Handles High Traffic<\/td><td>Distributes load across multiple locations<\/td><\/tr><tr><td>\ud83d\udd10 Better Security<\/td><td>Built-in HTTPS, DDoS protection<\/td><\/tr><tr><td>\ud83d\udcb8 Reduced Bandwidth<\/td><td>Origin server offloaded, less cost<\/td><\/tr><tr><td>\ud83d\udccd Geographic Reach<\/td><td>Global edge locations improve performance<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udee0\ufe0f <strong>Popular CDN Providers<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Amazon CloudFront<\/strong> (AWS)<\/li>\n\n\n\n<li><strong>Cloudflare<\/strong><\/li>\n\n\n\n<li><strong>Akamai<\/strong><\/li>\n\n\n\n<li><strong>Fastly<\/strong><\/li>\n\n\n\n<li><strong>Google Cloud CDN<\/strong><\/li>\n\n\n\n<li><strong>Microsoft Azure CDN<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 CDN Use Cases<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Serving <strong>static website files<\/strong><\/li>\n\n\n\n<li><strong>Video streaming<\/strong><\/li>\n\n\n\n<li>Accelerating <strong>API responses<\/strong><\/li>\n\n\n\n<li>Hosting <strong>software downloads<\/strong><\/li>\n\n\n\n<li><strong>Image optimization<\/strong> and resizing at the edge<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Here&#8217;s a simple <strong>diagram<\/strong> showing how a <strong>CDN (like CloudFront or Cloudflare)<\/strong> works:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce6 <strong>CDN Workflow Diagram<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>                         \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n                         \u2502     Origin Server      \u2502\n                         \u2502 (e.g., S3, Lightsail)  \u2502\n                         \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b2\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n                                   \u2502\n                          (Cache miss)\n                                   \u2502\n                      \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n                      \u2502                         \u2502\n             \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510       \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n             \u2502   Edge Server   \u2502       \u2502   Edge Server   \u2502\n             \u2502 (Tokyo POP)     \u2502       \u2502 (London POP)    \u2502\n             \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518       \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n                    \u2502                           \u2502\n        \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25bc\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25bc\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n        \u2502       End User 1        \u2502 \u2502       End User 2        \u2502\n        \u2502     (Japan Region)      \u2502 \u2502     (UK Region)         \u2502\n        \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\udde0 <strong>What Happens:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>End User 1 (in Japan)<\/strong> requests content.<\/li>\n\n\n\n<li>It goes to the <strong>nearest edge server<\/strong> (Tokyo).<\/li>\n\n\n\n<li>If content is <strong>cached<\/strong>, it&#8217;s returned instantly. \u2705<\/li>\n\n\n\n<li>If not, the edge server <strong>pulls from the origin<\/strong> (cache miss), then caches it.<\/li>\n\n\n\n<li><strong>Future users<\/strong> in Japan get the content directly from Tokyo edge \u2014 super fast. \ud83d\ude80<\/li>\n<\/ul>\n\n\n\n<p>Same process happens for <strong>End User 2<\/strong> via the London edge.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Legend:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Edge Server (POP)<\/strong>: Point of Presence; edge location that caches content.<\/li>\n\n\n\n<li><strong>Origin Server<\/strong>: Where your actual application or storage lives (e.g., AWS S3, Lightsail).<\/li>\n\n\n\n<li><strong>Cache Miss<\/strong>: When the edge doesn&#8217;t have the file \u2014 fetch from origin.<\/li>\n\n\n\n<li><strong>Cache Hit<\/strong>: File is available at the edge \u2014 fast return.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Content Delivery Network (CDN) is a globally distributed network of servers that delivers content to users faster by serving [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How a CDN Works? - SRE School<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How a CDN Works? - SRE School\" \/>\n<meta property=\"og:description\" content=\"A Content Delivery Network (CDN) is a globally distributed network of servers that delivers content to users faster by serving [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/\" \/>\n<meta property=\"og:site_name\" content=\"SRE School\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-03T02:47:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-03T02:47:26+00:00\" \/>\n<meta name=\"author\" content=\"Rajesh Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rajesh Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/\",\"url\":\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/\",\"name\":\"How a CDN Works? - SRE School\",\"isPartOf\":{\"@id\":\"https:\/\/sreschool.com\/blog\/#website\"},\"datePublished\":\"2025-06-03T02:47:25+00:00\",\"dateModified\":\"2025-06-03T02:47:26+00:00\",\"author\":{\"@id\":\"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201\"},\"breadcrumb\":{\"@id\":\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/sreschool.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How a CDN Works?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/sreschool.com\/blog\/#website\",\"url\":\"https:\/\/sreschool.com\/blog\/\",\"name\":\"SRESchool\",\"description\":\"Master SRE. Build Resilient Systems. Lead the Future of Reliability\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/sreschool.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201\",\"name\":\"Rajesh Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/sreschool.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g\",\"caption\":\"Rajesh Kumar\"},\"sameAs\":[\"http:\/\/sreschool.com\/blog\"],\"url\":\"https:\/\/sreschool.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How a CDN Works? - SRE School","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/","og_locale":"en_US","og_type":"article","og_title":"How a CDN Works? - SRE School","og_description":"A Content Delivery Network (CDN) is a globally distributed network of servers that delivers content to users faster by serving [&hellip;]","og_url":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/","og_site_name":"SRE School","article_published_time":"2025-06-03T02:47:25+00:00","article_modified_time":"2025-06-03T02:47:26+00:00","author":"Rajesh Kumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rajesh Kumar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/","url":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/","name":"How a CDN Works? - SRE School","isPartOf":{"@id":"https:\/\/sreschool.com\/blog\/#website"},"datePublished":"2025-06-03T02:47:25+00:00","dateModified":"2025-06-03T02:47:26+00:00","author":{"@id":"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201"},"breadcrumb":{"@id":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sreschool.com\/blog\/how-a-cdn-works\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/sreschool.com\/blog\/how-a-cdn-works\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sreschool.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How a CDN Works?"}]},{"@type":"WebSite","@id":"https:\/\/sreschool.com\/blog\/#website","url":"https:\/\/sreschool.com\/blog\/","name":"SRESchool","description":"Master SRE. Build Resilient Systems. Lead the Future of Reliability","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sreschool.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Person","@id":"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201","name":"Rajesh Kumar","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/sreschool.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g","caption":"Rajesh Kumar"},"sameAs":["http:\/\/sreschool.com\/blog"],"url":"https:\/\/sreschool.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":1,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":71,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions\/71"}],"wp:attachment":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}