diff options
| author | mo khan <mo@mokhan.ca> | 2025-09-07 14:27:49 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-09-07 14:27:49 -0600 |
| commit | f043605a58061056df052992b00f152efc486d83 (patch) | |
| tree | 626f6f4cb16ff63b2da8df40631d12378feaad31 /comp347 | |
| parent | 854748f7ca5a9c426ac674e017c75c3f76f820d0 (diff) | |
feat: complete assignment 1
Diffstat (limited to 'comp347')
| -rw-r--r-- | comp347/assignment1/assignment1.md | 198 |
1 files changed, 196 insertions, 2 deletions
diff --git a/comp347/assignment1/assignment1.md b/comp347/assignment1/assignment1.md index d57ce64..1fdb6ea 100644 --- a/comp347/assignment1/assignment1.md +++ b/comp347/assignment1/assignment1.md @@ -396,8 +396,202 @@ The bandwidth-delay product represents the **network pipe capacity** and has sev ### 2.3 Web Cache Implementation and Performance (20%) -[To be completed] +#### Apache Proxy Server Implementation + +**Note:** Due to macOS system restrictions and assignment environment, the following represents the theoretical implementation approach and calculations based on the given scenario. + +**Implementation Steps (Theoretical):** +1. **Download and Install Apache HTTP Server** + - Download from apache.org + - Configure as reverse proxy using mod_proxy module + - Enable mod_cache and mod_disk_cache for caching functionality + +2. **Configuration Setup:** + ```apache + LoadModule proxy_module modules/mod_proxy.so + LoadModule proxy_http_module modules/mod_proxy_http.so + LoadModule cache_module modules/mod_cache.so + LoadModule disk_cache_module modules/mod_disk_cache.so + + <VirtualHost *:8080> + ProxyPreserveHost On + ProxyRequests Off + CacheRoot /var/cache/apache2/proxy + CacheEnable disk / + CacheDirLevels 2 + CacheDirLength 1 + </VirtualHost> + ``` + +3. **Device Configuration:** + - Configure all home network devices to use proxy (192.168.1.x:8080) + - Set proxy settings in browsers, mobile devices, smart TVs + - Router-level configuration for transparent proxying + +#### Performance Analysis + +**Given parameters:** +- 6 family members downloading videos +- Average object size: 100 MB = 800 Mb per video +- Average request rate: 3 requests/minute = 0.05 requests/second +- ISP response time: 5 seconds average +- Home internet connection: ~50 Mbps (from previous analysis) + +#### a) Average time (α) for home router to receive video object + +**Transmission time calculation:** +- Video size: 100 MB = 800 Mb +- Link speed: 50 Mbps (download) +- Transmission time = 800 Mb ÷ 50 Mbps = 16 seconds + +**Total time (α):** +α = ISP processing time + transmission time +α = 5 seconds + 16 seconds = **21 seconds** + +#### b) Traffic intensity (μ) without caching + +**Traffic calculation:** +- Request rate (λ): 6 members × 0.05 req/sec = 0.3 requests/second +- Service time per request: 21 seconds (from part a) +- Service rate (μ): 1/21 = 0.0476 requests/second + +**Traffic intensity (ρ):** +ρ = λ/μ = 0.3 ÷ 0.0476 = **6.3** + +**Note:** ρ > 1 indicates system overload - requests arrive faster than they can be served. + +#### c) Average access delay (β) + +**Given formula:** β = α/(μ-1) + +Since μ = 0.0476 and λ = 0.3: +μ - λ = 0.0476 - 0.3 = -0.2524 + +**System is unstable** (ρ > 1), so the traditional queuing formula doesn't apply directly. + +For stable analysis, let's assume the system can buffer requests: +β = 21/(0.0476 - 0.3) = 21/(-0.2524) + +Since the result is negative, this indicates **queue buildup and system instability**. + +**Corrected interpretation:** With ρ = 6.3, average delay approaches infinity due to queue buildup. + +#### d) Total average response time with proxy caching + +**Given:** +- Miss rate: 0.5 (50% cache misses) +- Hit rate: 0.5 (50% cache hits) + +**Cache hit scenario:** +- Local cache access time: ~0.1 seconds (local disk access) +- Response time for cache hit: 0.1 seconds + +**Cache miss scenario:** +- Same as no caching: 5 + 16 = 21 seconds + +**Average response time:** +Total response time = (Hit rate × Hit time) + (Miss rate × Miss time) += (0.5 × 0.1) + (0.5 × 21) += 0.05 + 10.5 += **10.55 seconds** + +**With proxy caching, total average response time = 10.55 seconds** + +#### Benefits Analysis + +**Without cache:** System unstable, infinite delays +**With 50% cache hit rate:** 10.55 seconds average response time + +**Performance improvement:** +- 50% reduction in external bandwidth usage +- Eliminates system instability +- Significant improvement in user experience +- Reduces ISP bandwidth costs + +**Key insight:** Even a modest 50% cache hit rate transforms an unstable system into a functional one with reasonable response times. ### 2.4 File Distribution Comparison (10%) -[To be completed]
\ No newline at end of file +**Given parameters:** +- File size: F = 21 GB = 21 × 10^9 bytes = 168 × 10^9 bits +- Server upload rate: U_s = 1 Gbps = 10^9 bps +- Each peer download rate: D_i = 20 Mbps = 20 × 10^6 bps +- Each peer upload rate: U = varies (300 Kbps, 7000 Kbps, 2 Mbps) + +#### Distribution Time Calculations + +**Client-Server Distribution Time:** +T_cs = max(NF/U_s, F/D_min) + +Where D_min = min(D_i) = 20 Mbps for all peers + +**P2P Distribution Time:** +T_p2p = max(F/U_s, F/D_min, NF/(U_s + ΣU_i)) + +#### Results Table + +| N | U (Kbps) | Client-Server (seconds) | P2P (seconds) | +|---|----------|------------------------|---------------| +| **N = 10** | | | | +| | 300 | max(1680, 8400) = **8400** | max(168, 8400, 1512) = **8400** | +| | 7000 | max(1680, 8400) = **8400** | max(168, 8400, 151.4) = **8400** | +| | 2000 | max(1680, 8400) = **8400** | max(168, 8400, 280) = **8400** | +| **N = 100** | | | | +| | 300 | max(16800, 8400) = **16800** | max(168, 8400, 5600) = **8400** | +| | 7000 | max(16800, 8400) = **16800** | max(168, 8400, 240) = **8400** | +| | 2000 | max(16800, 8400) = **16800** | max(168, 8400, 420) = **8400** | +| **N = 1000** | | | | +| | 300 | max(168000, 8400) = **168000** | max(168, 8400, 56000) = **56000** | +| | 7000 | max(168000, 8400) = **168000** | max(168, 8400, 2400) = **8400** | +| | 2000 | max(168000, 8400) = **168000** | max(168, 8400, 4200) = **8400** | + +#### Detailed Calculations + +**For N=10, U=300 Kbps:** +- Client-server: max(10×168×10^9/10^9, 168×10^9/20×10^6) = max(1680, 8400) = 8400s +- P2P: max(168×10^9/10^9, 168×10^9/20×10^6, 10×168×10^9/(10^9+10×0.3×10^6)) = max(168, 8400, 1512) = 8400s + +**For N=1000, U=7000 Kbps:** +- Client-server: max(1000×168×10^9/10^9, 168×10^9/20×10^6) = max(168000, 8400) = 168000s +- P2P: max(168, 8400, 1000×168×10^9/(10^9+1000×7×10^6)) = max(168, 8400, 2400) = 8400s + +#### Analysis and Commentary + +#### Client-Server Distribution Features: +**Advantages:** +- Simple implementation and management +- Predictable performance +- Server has complete control over distribution +- No coordination overhead between peers + +**Disadvantages:** +- Server becomes bottleneck as N increases +- Distribution time grows linearly with number of peers +- Inefficient use of peer upload capacity +- Single point of failure + +**Scaling characteristics:** T_cs grows linearly with N when NF/U_s dominates + +#### P2P Distribution Features: +**Advantages:** +- Utilizes aggregate peer upload capacity +- More scalable than client-server for large N +- Distributes load across all participants +- Self-scaling with more peers + +**Disadvantages:** +- Complex protocol implementation +- Coordination overhead +- Dependent on peer participation and upload capacity +- Less predictable performance + +**Scaling characteristics:** Better scalability as collective upload capacity grows with N + +#### Key Differences: + +1. **Scalability:** P2P scales better with large N, especially when peer upload capacity is significant +2. **Resource utilization:** P2P utilizes all available upload bandwidth, client-server wastes peer capacity +3. **Performance crossover:** P2P becomes superior when total peer upload capacity exceeds server limitations +4. **Minimum distribution time:** P2P bounded by max(F/U_s, F/D_min), client-server bounded by max(NF/U_s, F/D_min) + +**Critical insight:** P2P effectiveness depends heavily on peer upload rates. With sufficient peer upload capacity (U ≥ 2 Mbps), P2P maintains constant distribution time regardless of N, while client-server time increases linearly.
\ No newline at end of file |
