Instead of routing every request from Tokyo to a central server in Virginia, Edge Computing executes backend logic on the CDN node physically closest to the user. This drops latency from 200ms to 20ms.


Module 1: Edge Functions vs. Serverless

Traditional serverless functions (like AWS Lambda) typically run in a single region. Edge functions (Cloudflare Workers, Vercel Edge) are deployed globally to hundreds of data centers simultaneously and are executed via WebAssembly or V8 isolates for instant cold starts.

Use Cases for Edge Compute

  • A/B Testing: Intercepting requests and rewriting HTML at the edge without a round trip to the origin server.
  • Authentication: Validating JWTs at the network edge before allowing traffic inside.
  • Personalization: Injecting user-specific state into statically cached pages.

Module 2: State at the Edge

Compute at the edge is easy; data at the edge is hard. If your edge function has to query a database in Virginia, you've lost all the latency benefits.

worker.jsjavascript
export default {
  async fetch(request, env) {
    // KV stores are eventually consistent but extremely fast for edge reads
    const cachedData = await env.EDGE_KV.get('user_prefs_123');
    if (cachedData) {
      return new Response(cachedData);
    }
    
    // Fallback to origin if cache miss
    return fetch('https://origin.api.com/user/123');
  }
}

Module 3: Distributed Edge Databases

To solve the data problem, modern databases like Turso (libsql) or global CRDT-based stores replicate data to edge nodes globally, allowing for local, sub-millisecond reads while handling write conflict resolution in the background.