The cloud computing era brought us a simple model: run your servers in a handful of massive data centers — us-east-1, eu-west-1 — and serve users wherever they happen to be. It works, mostly. But "mostly" is doing a lot of work in that sentence.

If you're in North America and your server is in Virginia, you're dealing with maybe 30-50ms of latency. If you're in São Paulo or Nairobi or Jakarta, that same server might be 200ms away. For a database query. That's before any application processing time.

Edge computing flips this model: instead of routing everything to a central location, move the computation as close to the user as physically possible — to servers in CDN points-of-presence (PoPs) distributed worldwide. The physics of light speed means 30ms is the maximum achievable from anywhere with decent connectivity.

What "Edge" Means Practically in 2024

There's a spectrum of what "edge" means today:

  • CDN edge (static) — The original edge. Cache HTML, CSS, JS, images close to users. CloudFront, Fastly, Cloudflare CDN. Been around for 20+ years.
  • Serverless edge functions — Execute code at CDN PoPs. Cloudflare Workers, Vercel Edge Functions, Deno Deploy. Low cold-start, true global distribution.
  • Edge AI inference — Run ML models at the edge. Cloudflare Workers AI, AWS Inferentia at edge nodes. Reduce inference latency dramatically.
  • IoT/device edge — On-device compute (phones, cameras, sensors). Separate discussion, different constraints.

The interesting action right now is in serverless edge functions — and the ecosystem around them has matured remarkably fast.

Cloudflare Workers: Edge Functions at Global Scale

Cloudflare Workers runs JavaScript/TypeScript (and compiled WebAssembly) on Cloudflare's network of 300+ PoPs worldwide. Cold start time: zero (it uses V8 isolates, not containers). Maximum latency to any user with decent internet: ~50ms. Regions: everywhere.

// A simple Cloudflare Worker — globally distributed
export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);

    // Personalize response based on request geography
    const country = request.cf?.country ?? 'unknown';
    const city    = request.cf?.city    ?? 'somewhere';

    // Route to different handling
    if (url.pathname.startsWith('/api/')) {
      return handleAPI(request, env, country);
    }

    // Edge-side A/B testing
    const variant = Math.random() > 0.5 ? 'A' : 'B';
    return new Response(`Hello from ${city}, ${country}! Variant: ${variant}`, {
      headers: { 'Content-Type': 'text/plain' }
    });
  }
};
The V8 Isolate Advantage
Workers uses V8 isolates rather than containers or VMs. Isolates spin up in ~0ms (they're pre-warmed) and use ~10MB RAM vs hundreds of MB for a container. This is how Cloudflare runs Workers on the same hardware as its CDN without massive cost overhead.

Edge Databases: The Hard Part

Compute at the edge is solved. Data at the edge is harder. Database reads and writes can't just live in Virginia if your compute is in London, Tokyo, and São Paulo.

The ecosystem response:

  • Cloudflare D1 — SQLite at the edge, globally replicated reads, write forwarding to primary. Zero latency for cached reads.
  • Cloudflare KV — Eventually consistent key-value store across all PoPs. Great for session data, feature flags, config.
  • Cloudflare Durable Objects — Strongly consistent single-object storage with colocated compute. The missing piece for stateful edge applications.
  • Turso — libSQL (SQLite fork) with global read replicas, designed for edge deployments.
  • PlanetScale Boost — MySQL with globally distributed read replicas and intelligent query routing.
// Using Cloudflare D1 — SQLite at the edge
export default {
  async fetch(request, env) {
    const { results } = await env.DB.prepare(
      'SELECT * FROM posts WHERE published = 1 ORDER BY created_at DESC LIMIT 10'
    ).all();

    return Response.json(results);
  }
};

When to Use Edge (and When Not To)

Edge shines for:

  • Authentication middleware (verify JWTs before hitting your origin)
  • Personalization (geolocation, A/B testing, feature flags)
  • API proxying and transformation
  • Bot protection and rate limiting
  • Streaming HTML (progressive enhancement without full client-side rendering)
  • Image optimization and media delivery

Still better on centralized compute:

  • Long-running workloads (edge functions typically have 30ms-10s limits)
  • Heavy compute (video encoding, large ML training)
  • Applications requiring strong consistency across all operations
  • Anything needing connection to legacy databases or services in a single VPC

Edge AI: The Next Frontier

The convergence of edge compute and AI inference is genuinely exciting. Cloudflare Workers AI runs models (Llama, Mistral, Whisper, SDXL) on GPU nodes at Cloudflare's edge — meaning you can invoke a language model with single-digit millisecond network overhead from anywhere in the world.

// Workers AI: run an LLM at the edge
export default {
  async fetch(request, env) {
    const { question } = await request.json();

    const response = await env.AI.run('@cf/meta/llama-3-8b-instruct', {
      messages: [
        { role: 'system', content: 'You are a helpful tech blog assistant.' },
        { role: 'user',   content: question }
      ]
    });

    return Response.json(response);
  }
};
The combination of edge compute and edge AI inference may be more transformative than either alone. Sub-50ms AI responses, globally, without massive data center infrastructure — that's a qualitatively different user experience.

Getting Started with Edge Development

  1. Cloudflare Workersnpm create cloudflare@latest gets you a Worker running locally in 60 seconds. Free tier is generous.
  2. Wrangler CLI — Cloudflare's dev tool. Local emulation, deployment, tail logs.
  3. Vercel Edge Functions — If you're in the Next.js ecosystem, edge functions integrate naturally.
  4. Deno Deploy — TypeScript-first, global deployment, excellent for API services.

The developer experience for edge has improved dramatically. If you haven't tried it since 2021, go again — it's a different world.

TF Editorial

TF Editorial

Editorial Team · Tomfoolering

We write about technology with depth and without condescension.