Module 1 - Data Storage

Edge Computing

Moving computation closer to users for lower latency and better performance.

1The Coffee Shop Analogy

Simple Analogy
Traditional (Origin Server): Order coffee, barista ships it from headquarters across the country. Takes forever.

Edge Computing: Coffee shops in every neighborhood. Your order is prepared at the nearest location. Fast and fresh.

Edge Computing: Running code and storing data at locations geographically close to users, rather than in a centralized data center. Part of a CDN strategy for dynamic content.

2Edge vs Origin

AspectOrigin ServerEdge
LocationCentralized data center200+ locations globally
Latency100-300ms10-50ms
StateFull database accessLimited (KV stores, caches)
ComputeFull server capabilitiesLimited execution time
CostStandard hostingPay per request

3Use Cases

A/B Testing

Route users to different variants at the edge, no origin roundtrip

Authentication

Validate JWT tokens at the edge, reject invalid requests early

Geolocation

Personalize content based on user location

Bot Protection

Block malicious traffic before it reaches origin

Image Optimization

Resize and format images on the fly

API Aggregation

Combine multiple API calls at the edge

4Edge Platforms

Cloudflare Workers
V8 isolates, KV storage, Durable Objects. 0ms cold start.
Vercel Edge Functions
Built on Cloudflare. Integrates with Next.js.
AWS CloudFront Functions
Lightweight functions at CloudFront edge.
Fastly Compute@Edge
WebAssembly-based edge compute.

5Limitations

Limited Execution Time
Usually 50ms-30s max. Not for long-running tasks.
No Traditional Database
Use KV stores, Durable Objects, or call origin for DB access.
Cold Starts (some platforms)
Lambda@Edge has cold starts. Workers don't.
Debugging Complexity
Distributed execution makes debugging harder.

6Key Takeaways

1Edge computing runs code close to users for low latency
2Great for authentication, A/B testing, geo-personalization
3Limited execution time and storage compared to origin
4Cloudflare Workers and Vercel Edge are popular choices
5Use edge for lightweight, latency-sensitive operations

?Quiz

1. What's the main benefit of edge computing?

2. Which task is NOT suitable for edge?