A lightweight, educational CDN implementation with built-in web-based GUI dashboard for monitoring and testing.
- Origin Server (Port 4000) - Serves static content
- 3 Edge Servers (Ports 3001-3003) - Caching layer with round-robin routing
- CDN Gateway/Router (Port 3000) - Main entry point with reverse-proxy
- Real-time test execution (Load, Cache, Routing tests)
- Beautiful charts & visualizations using Chart.js
- System status monitoring with metrics
- Professional web interface with responsive design
β
Round-Robin Routing - Distributes requests evenly
β
Edge Caching - Caches content locally
β
Deterministic Behavior - Predictable routing for testing
β
Multi-Origin Support - Connect edges to origin servers
β
Load Distribution Chart - Bar chart showing requests per edge
β
Cache Status Chart - Doughnut chart for hit/miss ratio
β
Routing Accuracy Chart - Verification of round-robin
β
System Status Panel - Shows active edges and URLs
β
Test Metrics - Real-time performance data
β
Detailed Results - Full test logs and data
- Node.js β₯ 16
- npm (comes with Node.js)
cd LiteCDN
npm installnpm run start:allOpen your browser:
http://localhost:3000/dashboard.html
Tests load balancing across 3 edges
- Sends ~100 concurrent requests
- Shows request distribution
- Displays balance metrics
- Expected: ~33 requests per edge
Verifies caching behavior
- Tracks cache hits vs misses
- Shows hit rate percentage
- First request = MISS, subsequent = HIT
- Expected: >50% hit rate
Validates round-robin routing
- Verifies deterministic sequence
- Checks accuracy percentage
- Each request goes to next edge in order
- Expected: 100% accuracy
LiteCDN/
βββ backend/
β βββ config.js # Configuration (ports, URLs)
β βββ cdn.js # CDN Gateway with API endpoints
β βββ testAPI.js # Test runner for dashboard
β βββ routing.js # Round-robin routing logic
β βββ edge/edge.js # Edge server with caching
β βββ origin/origin.js # Origin server
βββ frontend/
β βββ dashboard.html # GUI Dashboard (NEW!)
β βββ index.html # Basic interface
β βββ styles.css
βββ scripts/
β βββ startAll.js # Launcher script
βββ testing/
β βββ testCache.js # Cache testing
β βββ testLoad.js # Load testing
β βββ testRouting.js # Routing testing
β βββ testZipf.js # Zipf distribution test
βββ GUIDE.md # Basic guide
βββ DASHBOARD_GUIDE.md # Dashboard usage guide
βββ GUI_IMPLEMENTATION.md # Implementation details
βββ package.json
- Gradient Background: Purple (#667eea β #764ba2)
- Status Green: #48bb78 (healthy)
- Status Red: #f56565 (error)
- Status Yellow: #feebc8 (warning)
- Works on desktop (full layout)
- Works on tablet (2-column)
- Works on mobile (single column)
{
"distribution": {
"Edge-1": 34,
"Edge-2": 33,
"Edge-3": 33
},
"summary": {
"totalRequests": 100,
"imbalancePercent": 3.45,
"status": "Balanced β
"
}
}{
"summary": {
"hits": 24,
"misses": 6,
"hitRate": "80.0%",
"status": "Good β
"
}
}{
"summary": {
"totalRequests": 12,
"correctCount": 12,
"accuracy": "100.0%"
}
}GET /cdn/<path> β Route request through CDN
GET /health β Check gateway status
GET /status β Get system status (edges, index)
GET /api/tests/load β Run load test
GET /api/tests/cache β Run cache test
GET /api/tests/routing β Run routing test
GET /dashboard.html β Dashboard UI
# Terminal 1 - Start system
npm run start:all
# Terminal 2 - Run individual tests
node testing/testLoad.js
node testing/testCache.js
node testing/testRouting.js
node testing/testZipf.js- Start system:
npm run start:all - Open:
http://localhost:3000/dashboard.html - Click test buttons for live results
- Stores master copies of content
- Serves requests from edge caches when miss occurs
- Static files:
hello.txt,data.json,sample.txt
- Local caching layer
- Serves cached content (HIT)
- Falls back to origin on cache miss (MISS)
- Round-robin distributed by gateway
- Main entry point for clients
- Implements round-robin routing
- Routes requests to appropriate edge
- Serves dashboard UI and API
Shows:
- Number of active edges
- Current round-robin index
- Edge URLs and ports
- Auto-detected on first load
Displays quick results:
- Load test: Balanced/Imbalanced
- Cache test: Hit rate %
- Routing test: Accuracy %
-
Load Distribution (Bar Chart)
- Requests per edge
- Balance metrics
- Hover for details
-
Cache Status (Doughnut Chart)
- Hit vs miss ratio
- Percentages
- Color-coded (green/red)
-
Routing Accuracy (Bar Chart)
- Correct vs incorrect routes
- Accuracy percentage
- Pass/fail indication
- Timestamp for each request
- Edge ID
- Cache status (HIT/MISS)
- Response time
- Searchable and sortable
Edit backend/config.js to change:
- Gateway port (default: 3000)
- Edge server ports (default: 3001-3003)
- Origin server URL (default: http://localhost:4000)
module.exports = {
cdn: { port: 3000 },
edges: [
{ id: 'Edge-1', port: 3001 },
{ id: 'Edge-2', port: 3002 },
{ id: 'Edge-3', port: 3003 },
],
origin: { port: 4000 },
};- Ensure
npm run start:allis running - Check port 3000 is available
- Try full URL:
http://localhost:3000/dashboard.html
- Verify all servers started successfully
- Check console (F12 β Console) for errors
- Ensure no ports are blocked
- Clear browser cache
- Refresh the page
- Check if Chart.js loaded (F12 β Network)
- This is normal for small samples
- Run load test multiple times
- Check if one edge is slower
- GUIDE.md - Basic setup guide
- DASHBOARD_GUIDE.md - Complete dashboard usage
- GUI_IMPLEMENTATION.md - Technical implementation details
- DASHBOARD_VISUAL_REFERENCE.md - Visual layout reference
This project demonstrates:
- β CDN architecture and round-robin routing
- β Edge caching and hit/miss behavior
- β Load distribution and balancing
- β Reverse proxy implementation
- β REST API design
- β Real-time web dashboards
- β Data visualization with charts
- This is an educational project not for production
- No authentication or authorization
- No data encryption
- Use only in trusted networks
- No sensitive data handling
{
"axios": "^1.7.0", // HTTP client
"express": "^4.21.0", // Web framework
"cors": "^2.8.5" // CORS middleware
}Frontend uses:
- Chart.js (via CDN) - Easy charting
- HTML5 - Modern web standards
- CSS3 - Responsive design
Typical test results:
- Load Test: 5-10 seconds (100 requests)
- Cache Test: 2-5 seconds (12 requests)
- Routing Test: 1-3 seconds (12 requests)
- Dashboard rendering: <500ms
- Beautiful UI - Modern gradient design with smooth animations
- Real-time Tests - Run tests directly from browser
- Smart Charts - Auto-scaling visualizations
- Live Updates - No page reloads needed
- Responsive - Works on all devices
- Educational - Learn CDN concepts interactively
For issues or questions:
- Check the documentation files
- Review browser console (F12)
- Check server logs in terminal
- Verify all servers are running
MIT
This CDN implementation is perfect for learning:
- How CDNs distribute content
- How round-robin routing works
- How edge caching improves performance
- How to monitor distributed systems
- How to build web dashboards
- Real-time data visualization
Start learning: npm run start:all β http://localhost:3000/dashboard.html
Enjoy your LiteCDN journey! π