Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ LiteCDN - Educational Content Delivery Network with GUI Dashboard

A lightweight, educational CDN implementation with built-in web-based GUI dashboard for monitoring and testing.

✨ What's Included

Core CDN System

  • 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

NEW: Interactive GUI Dashboard πŸŽ‰

  • 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

🎯 Features

System Features

βœ… 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

Dashboard Features

βœ… 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


πŸš€ Quick Start

Prerequisites

  • Node.js β‰₯ 16
  • npm (comes with Node.js)

Installation

cd LiteCDN
npm install

Start the System

npm run start:all

Access the Dashboard

Open your browser:

http://localhost:3000/dashboard.html

πŸ“Š Using the Dashboard

1. Load Test (πŸ“Š)

Tests load balancing across 3 edges

  • Sends ~100 concurrent requests
  • Shows request distribution
  • Displays balance metrics
  • Expected: ~33 requests per edge

2. Cache Test (πŸ’Ύ)

Verifies caching behavior

  • Tracks cache hits vs misses
  • Shows hit rate percentage
  • First request = MISS, subsequent = HIT
  • Expected: >50% hit rate

3. Routing Test (πŸ”€)

Validates round-robin routing

  • Verifies deterministic sequence
  • Checks accuracy percentage
  • Each request goes to next edge in order
  • Expected: 100% accuracy

πŸ“ Project Structure

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

🎨 Dashboard UI

Color Scheme

  • Gradient Background: Purple (#667eea β†’ #764ba2)
  • Status Green: #48bb78 (healthy)
  • Status Red: #f56565 (error)
  • Status Yellow: #feebc8 (warning)

Responsive Design

  • Works on desktop (full layout)
  • Works on tablet (2-column)
  • Works on mobile (single column)

πŸ“ˆ Example Outputs

Load Test

{
  "distribution": {
    "Edge-1": 34,
    "Edge-2": 33,
    "Edge-3": 33
  },
  "summary": {
    "totalRequests": 100,
    "imbalancePercent": 3.45,
    "status": "Balanced βœ…"
  }
}

Cache Test

{
  "summary": {
    "hits": 24,
    "misses": 6,
    "hitRate": "80.0%",
    "status": "Good βœ…"
  }
}

Routing Test

{
  "summary": {
    "totalRequests": 12,
    "correctCount": 12,
    "accuracy": "100.0%"
  }
}

πŸ”§ API Endpoints

Content Delivery

GET /cdn/<path>     β†’ Route request through CDN
GET /health         β†’ Check gateway status
GET /status         β†’ Get system status (edges, index)

Dashboard/Testing

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

πŸ§ͺ Testing

Manual Testing (without dashboard)

# 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

Automated Testing (with dashboard)

  1. Start system: npm run start:all
  2. Open: http://localhost:3000/dashboard.html
  3. Click test buttons for live results

πŸ“Š What Each Component Does

Origin Server (Port 4000)

  • Stores master copies of content
  • Serves requests from edge caches when miss occurs
  • Static files: hello.txt, data.json, sample.txt

Edge Servers (Ports 3001-3003)

  • Local caching layer
  • Serves cached content (HIT)
  • Falls back to origin on cache miss (MISS)
  • Round-robin distributed by gateway

CDN Gateway (Port 3000)

  • Main entry point for clients
  • Implements round-robin routing
  • Routes requests to appropriate edge
  • Serves dashboard UI and API

🎯 Dashboard Features in Detail

System Status Panel

Shows:

  • Number of active edges
  • Current round-robin index
  • Edge URLs and ports
  • Auto-detected on first load

Test Summary Panel

Displays quick results:

  • Load test: Balanced/Imbalanced
  • Cache test: Hit rate %
  • Routing test: Accuracy %

Interactive Charts

  1. Load Distribution (Bar Chart)

    • Requests per edge
    • Balance metrics
    • Hover for details
  2. Cache Status (Doughnut Chart)

    • Hit vs miss ratio
    • Percentages
    • Color-coded (green/red)
  3. Routing Accuracy (Bar Chart)

    • Correct vs incorrect routes
    • Accuracy percentage
    • Pass/fail indication

Detailed Results Table

  • Timestamp for each request
  • Edge ID
  • Cache status (HIT/MISS)
  • Response time
  • Searchable and sortable

βš™οΈ Configuration

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 },
};

🚨 Troubleshooting

Dashboard won't load

  • Ensure npm run start:all is running
  • Check port 3000 is available
  • Try full URL: http://localhost:3000/dashboard.html

Tests show errors

  • Verify all servers started successfully
  • Check console (F12 β†’ Console) for errors
  • Ensure no ports are blocked

Charts not rendering

  • Clear browser cache
  • Refresh the page
  • Check if Chart.js loaded (F12 β†’ Network)

Load imbalance detected

  • This is normal for small samples
  • Run load test multiple times
  • Check if one edge is slower

πŸ“š Documentation

  • GUIDE.md - Basic setup guide
  • DASHBOARD_GUIDE.md - Complete dashboard usage
  • GUI_IMPLEMENTATION.md - Technical implementation details
  • DASHBOARD_VISUAL_REFERENCE.md - Visual layout reference

🎯 Learning Objectives

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

πŸ”’ Security Notes

  • This is an educational project not for production
  • No authentication or authorization
  • No data encryption
  • Use only in trusted networks
  • No sensitive data handling

πŸ“¦ Dependencies

{
  "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

πŸš€ Performance

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

πŸŽ‰ Features Showcase

✨ What Makes This Cool

  1. Beautiful UI - Modern gradient design with smooth animations
  2. Real-time Tests - Run tests directly from browser
  3. Smart Charts - Auto-scaling visualizations
  4. Live Updates - No page reloads needed
  5. Responsive - Works on all devices
  6. Educational - Learn CDN concepts interactively

πŸ“ž Support

For issues or questions:

  1. Check the documentation files
  2. Review browser console (F12)
  3. Check server logs in terminal
  4. Verify all servers are running

πŸ“ License

MIT


πŸŽ“ Educational Value

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! πŸš€

About

A lightweight, modular CDN designed for low-latency content delivery with a focus on resource efficiency and minimal computing. The project simulates edge nodes, intelligent routing, adaptive caching, and fault tolerance, following the complete Software Development Life Cycle (SDLC).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages