CDNs & Edge Computing
When applications need to serve global users, network latency and reliability become critical.
Even with powerful servers, requests traveling across continents add hundreds of milliseconds.
CDNs (Content Delivery Networks) and Edge Computing solve this by pushing content and computation closer to users.
1. CDNs (Content Delivery Networks)
A CDN is a geographically distributed network of edge servers that cache and deliver content.
Key Features
- Static content caching: HTML, CSS, JS, images, video.
- Dynamic content acceleration: optimize routing for APIs.
- DDoS protection: absorb traffic surges.
- Global routing: send users to nearest edge server.
Examples
- Cloudflare, Akamai, AWS CloudFront, Fastly, Vercel, Netlify.
2. Edge Computing
Edge computing takes CDN a step further: not just caching, but executing logic at the edge.
What it means
- Run computation closer to the user.
- Reduce round-trips to origin server.
- Useful for personalization, security, and latency-sensitive workloads.
Examples
- Cloudflare Workers: run JavaScript at the edge.
- AWS Lambda@Edge: serverless compute at CloudFront edges.
- Fastly Compute@Edge: WASM-powered edge compute.
3. Benefits of CDNs & Edge Computing
- Lower latency: serve from nearest location.
- Higher availability: multiple edge nodes reduce SPOF.
- Scalability: absorb sudden spikes (viral content, flash sales).
- Cost savings: reduce load on origin servers.
- Security: DDoS mitigation, WAF at edge.
4. Use Cases
- Static websites → CDN edge nodes serve all assets.
- Streaming services → cache video segments at edges.
- E-commerce → edge logic for localization, currency, personalization.
- APIs → cache GET responses, run authentication at edge.
- IoT & real-time apps → process data at edge before central aggregation.
5. Pitfalls & Trade-offs
- Cache invalidation → stale content if not purged correctly.
- Dynamic personalization → harder to cache (per-user responses).
- Debugging → edge logic harder to test locally.
- Vendor lock-in → each provider has unique APIs.
6. CDN vs Edge — Quick Contrast
Feature | CDN | Edge Computing |
---|---|---|
Focus | Caching content | Running logic near users |
Primary Benefit | Latency + offload origin | Personalization, real-time, low-latency |
Examples | CloudFront, Akamai, Fastly | Cloudflare Workers, Lambda@Edge |
7. Interview Tips
- Always mention CDNs for global scalability.
- Bring up edge computing for personalization, real-time processing, security.
- Show awareness of cache invalidation trade-offs.
- Mention that CDNs/edges are complementary to load balancing.
8. Next Steps
- Explore Scalability Patterns.
- Learn about Event-driven Architectures.