0
0
Computer Networksknowledge~10 mins

Content Delivery Networks (CDN) in Computer Networks - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Content Delivery Networks (CDN)
Start: User requests content
DNS resolves domain name
DNS returns nearest CDN edge IP
Not configuredRequest goes to origin
Request hits CDN edge server
Is content in edge cache?
YesReturn cached content
No
Edge fetches content from origin server
Edge caches content and returns to user
End
This flow shows how a CDN intercepts user requests through DNS, checks its edge cache, and either serves cached content or fetches from the origin server.
Execution Sample
Computer Networks
User requests www.example.com/image.png
DNS resolves to CDN edge server IP
Edge server checks local cache
Cache MISS: edge fetches from origin
Origin returns image.png
Edge caches image.png with TTL 86400s
Edge returns image.png to user
This sequence shows a first-time request where the CDN edge has no cached copy, so it fetches from origin, caches the response, and serves the user.
Analysis Table
StepActionCondition/CheckResult/DecisionNext Step
1User requests image.pngN/AHTTP request initiatedDNS resolution
2DNS resolves domainIs CDN configured?Yes, CNAME points to CDNRoute to nearest edge
3Request reaches edge serverIs content in cache?No (cache MISS)Fetch from origin
4Edge fetches from originN/AOrigin returns content with headersCache the response
5Edge caches contentCache-Control: public, max-age=86400Stored with 24-hour TTLReturn to user
6Edge returns content to userN/AUser receives image.pngEnd
7Next user requests same contentIs content in cache?Yes (cache HIT)Return cached content directly
💡 Subsequent requests for the same content are served directly from the edge cache without contacting the origin server.
State Tracker
VariableStartAfter Step 2After Step 3After Step 5Final
request_urlwww.example.com/image.pngResolved to edge IPChecked at edgeServed from cacheDelivered to user
cache_statusUnknownUnknownMISSStored (TTL: 86400s)HIT for next request
origin_contactedNoNoNoYes (fetched content)No (for cached requests)
user_latencyN/ADNS: 5msEdge check: 1msOrigin fetch: 200msCache HIT: ~10ms total
Key Insights - 3 Insights
Why does DNS resolve to the CDN edge server instead of the origin?
The domain uses a CNAME record pointing to the CDN provider. The CDN's DNS uses anycast or geolocation to return the IP of the nearest edge server, as shown in step 2 of the execution_table.
What determines how long the edge server keeps the cached content?
The Cache-Control header from the origin server sets the TTL. In step 5, max-age=86400 tells the edge to cache for 24 hours before the content is considered stale.
Why is the second request so much faster than the first?
The first request (cache MISS) requires fetching from the origin server. The second request (cache HIT) is served directly from the nearby edge server, eliminating the origin round-trip as shown in step 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3. What happens when the edge server does not have the content cached?
AThe request is rejected
BThe edge fetches the content from the origin server
CThe user is redirected to the origin directly
DThe edge waits until the content appears
💡 Hint
Check the 'Next Step' column when the cache check results in a MISS.
According to the variable_tracker, what is the cache_status after step 5?
AMISS
BExpired
CStored with TTL 86400s
DEmpty
💡 Hint
Look at the cache_status row in the 'After Step 5' column.
What is the main reason a CDN reduces latency for users far from the origin server?
AIt compresses all content to smaller sizes
BIt serves cached content from a geographically closer edge server
CIt increases the origin server's processing speed
DIt uses a faster version of HTTP
💡 Hint
Think about the physical distance between the user and the server responding to the request.
Concept Snapshot
CDNs distribute cached content across edge servers worldwide.
DNS routes users to the nearest edge server using anycast or geolocation.
Edge servers check their cache: HIT serves instantly, MISS fetches from origin.
Cache-Control headers determine how long content stays cached.
Result: dramatically lower latency and reduced origin server load.
Full Transcript
This visual execution shows how Content Delivery Networks reduce latency by caching content at edge servers close to users. When a user requests content, DNS resolves the domain to the nearest CDN edge server instead of the origin. The edge server checks its local cache. On a cache miss, it fetches from the origin server, stores the response according to Cache-Control headers, and returns it to the user. On subsequent requests, the edge serves the cached content directly without contacting the origin. This turns a 500ms origin fetch into a 10ms edge response, which is why CDNs are essential for serving content to users around the world.