0
0
Computer Networksknowledge~30 mins

Content Delivery Networks (CDN) in Computer Networks - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Content Delivery Networks (CDN)
📖 Scenario: You are a network engineer learning how CDNs reduce latency by caching content at edge servers close to users. You will build a simple model of a CDN using Python dictionaries to represent edge servers, their caches, and the content delivery process.In this project, you will create the CDN infrastructure, simulate cache lookups, handle cache misses by fetching from origin, and track cache hit rates.
🎯 Goal: Build a basic data structure that models CDN edge servers, their cached content, origin server content, and a function to simulate the content delivery process with cache hit/miss tracking.
📋 What You'll Learn
Create a dictionary representing the origin server's content library
Create a dictionary representing CDN edge servers and their cached content
Implement logic to handle content requests with cache hit and miss tracking
Complete the model by calculating the cache hit rate
💡 Why This Matters
🌍 Real World
CDNs power content delivery for every major website. Understanding cache hit rates and edge server behavior is essential for optimizing performance and reducing origin server costs.
💼 Career
Network engineers and web developers use CDN metrics like cache hit rate to diagnose performance issues and optimize content delivery strategies.
Progress0 / 4 steps
1
Create the origin server content library
Create a dictionary called origin_server with these exact entries: 'index.html' with value 'Welcome Page', 'style.css' with value 'Body Styles', 'logo.png' with value 'Company Logo', and 'app.js' with value 'Application Script'.
Computer Networks
Need a hint?

Think of the origin server as a dictionary where each key is a filename and each value is the content it holds.

2
Create CDN edge servers with partial caches
Create a dictionary called edge_servers with two edge servers. 'edge_us' has a cache containing 'index.html' with value 'Welcome Page' and 'style.css' with value 'Body Styles'. 'edge_eu' has a cache containing only 'logo.png' with value 'Company Logo'.
Computer Networks
Need a hint?

Each edge server has its own cache dictionary. Not all content is cached at every edge — this is realistic CDN behavior.

3
Simulate content requests with cache tracking
Create two counter variables cache_hits and cache_misses, both set to 0. Create a list called requests with these tuples: ('edge_us', 'index.html'), ('edge_us', 'app.js'), ('edge_eu', 'logo.png'), ('edge_eu', 'style.css'). Use a for loop with variables server and file to iterate over requests. Inside the loop, check if file is in edge_servers[server]. If yes, increment cache_hits. If no, increment cache_misses and add the content from origin_server to the edge cache.
Computer Networks
Need a hint?

On a cache miss, the edge fetches from origin and stores it locally. This models how CDN caches warm up over time.

4
Calculate and store the cache hit rate
Create a variable called total_requests set to cache_hits + cache_misses. Create a variable called hit_rate set to cache_hits / total_requests.
Computer Networks
Need a hint?

The hit rate shows what percentage of requests were served from cache. A higher hit rate means less load on the origin server.