Edge Computing
Edge computing runs code and stores data close to where it's needed — at the network edge, in hundreds of locations near users — instead of in a handful of centralized cloud regions. When a request no longer travels across a continent to a distant data center and back, latency drops from hundreds of milliseconds to tens, and the experience feels instant.
The web-development flavor of edge computing exploded when CDNs — already operating a global network of points of presence to cache static assets — added the ability to run code at those locations. Suddenly the same infrastructure that served your images could execute logic milliseconds from the user: rewriting requests, personalizing responses, authenticating, and rendering. This page focuses on that modern edge — edge functions and edge platforms — while placing it in the broader edge-computing picture.
TL;DR
- Edge computing runs compute at many locations near users, not in a few central regions — cutting latency by eliminating the long round-trip.
- Edge functions are serverless functions that run at CDN points of presence, milliseconds from the user, for request handling, personalization, auth, and routing.
- Edge runtimes are constrained: fast cold starts and lightweight isolates, but limited CPU time, memory, and often no full Node.js API or persistent local state.
- Great for latency-sensitive, lightweight, globally-distributed work; poor for heavy compute, large dependencies, or workloads needing a nearby database.
- The pattern is hybrid: edge handles the fast, distributed front layer; central cloud (or regional databases) handles heavy lifting and the source of truth.
- Data gravity matters — running code at the edge helps only if the data it needs is also near the edge, or the call still crosses the globe.
Quick Example
An edge function runs at the location nearest each visitor. Here one personalizes a response by the user's country — with no origin round-trip:
The same code is deployed to every edge location automatically; each request is served by the nearest one.
Core Concepts
Why Distance Is Latency
Network latency is bounded by physics — data travels at a finite speed through fiber. A round-trip from Sydney to a US-East data center is inherently ~200ms before any processing. Edge computing removes that distance: if the code runs at a point of presence in Sydney, the round-trip is a few milliseconds. For latency-sensitive interactions, where the compute runs dominates how fast the compute is.
The Edge Runtime Model
Edge functions don't run in traditional containers or VMs. They run in lightweight, fast-starting isolates (or WebAssembly sandboxes) that spin up in milliseconds — because a request could hit any of hundreds of locations, and you can't keep heavy runtimes warm everywhere. The tradeoffs of this model:
Edge Functions vs Central Serverless
Both are serverless, but they differ in where they run and what they can do:
- Central serverless (serverless functions, e.g. Lambda) runs in specific cloud regions with a full runtime, generous resources, and easy access to regional databases — but with higher latency for distant users and slower cold starts.
- Edge functions run everywhere at once with tiny cold starts and minimal latency — but with constrained CPU, limited runtime APIs, and no nearby database by default.
They're complementary layers, not substitutes.
Use Cases and Anti-Patterns
Where Edge Shines
- Request manipulation — rewrites, redirects, header/cookie logic, A/B routing, feature flags at the edge before a request reaches the origin.
- Personalization — geolocation, localization, and per-user variants computed instantly near the visitor.
- Authentication & authorization — validating tokens and gating requests at the edge, rejecting bad traffic before it crosses the globe.
- Edge rendering — server-rendering pages or fragments close to users for fast first paint (modern frameworks target edge runtimes).
- API caching and aggregation — caching and stitching responses at the edge to cut origin load and latency.
Where Edge Struggles
- Heavy compute — long-running or CPU-intensive jobs blow the edge CPU budget; run them centrally.
- Large dependencies / full Node APIs — many libraries assume a full Node.js runtime the edge doesn't provide.
- Database-heavy work — if the code needs many queries to a database in one central region, running at the edge just moves the latency to the DB calls. Data gravity wins.
- Stateful workloads — edge runtimes are ephemeral; durable state needs an edge data store or a central backend.
💡 Tip: The edge helps only when the data the code needs is also near the edge. Code at the edge calling a database across the world is often slower than central compute co-located with that database. Move data to the edge (edge KV, replicated stores) or keep data-heavy logic central.
Best Practices
Put the Fast, Distributed Layer at the Edge
Use the edge for the lightweight, latency-sensitive front layer — routing, auth, personalization, caching — and keep heavy or data-intensive work in central cloud. This hybrid split gets the latency win without fighting the edge's constraints.
Mind Data Gravity
Co-locate data with compute. If edge code depends on data, use edge-native stores (edge key-value, edge databases, replicated caches) so the data is near the code. Otherwise the request still pays the long trip — to the database instead of the origin.
Keep Functions Small and Stateless
Edge functions have tight CPU and memory budgets and are ephemeral. Write short, stateless handlers; push heavy processing and durable state elsewhere. Trim dependencies aggressively — edge bundles must be lean.
Target Web-Standard APIs
Edge runtimes implement web-standard APIs (Fetch, Request/Response, Web Crypto) rather than the full Node.js API. Write to that standard surface for portability across edge platforms and to avoid depending on Node built-ins that aren't there.
Measure Real User Latency
The edge's whole value is latency, so measure it from real users worldwide (RUM), not from one office. Verify the edge is actually reducing tail latency for distant users, and watch that data-access patterns aren't quietly reintroducing the round-trips you removed.
Common Mistakes
Running Data-Heavy Logic at the Edge
Assuming a Full Node.js Runtime
Importing a library that needs Node built-ins (fs, native modules, full Buffer semantics) into an edge function often fails at deploy or runtime. Check that dependencies target web-standard runtimes.
Using the Edge for Everything
Edge computing is a front-layer optimization, not a general compute platform. Forcing heavy, stateful, or database-bound workloads onto it fights its constraints. Keep those central and let the edge do what it's good at.
FAQ
What's the difference between edge computing and the cloud?
Traditional cloud runs your code in a few centralized regions; edge computing runs it in many locations close to users. The cloud offers full runtimes, big resources, and co-located databases; the edge offers minimal latency and global distribution with constrained resources. They're complementary — edge for the fast distributed layer, central cloud for heavy lifting and the source of truth.
How is an edge function different from a Lambda?
A central serverless function like Lambda runs in a specific region with a full runtime and generous resources but higher latency for distant users. An edge function runs at hundreds of locations at once with millisecond cold starts and minimal latency, but with a constrained CPU/memory budget, web-standard (not full Node.js) APIs, and no nearby database by default. Use each for what it's suited to.
When should I use edge computing?
When latency matters and the work is lightweight and distributable: request rewriting and routing, auth checks, geolocation and personalization, edge caching, and fast server-rendering close to users. Avoid it for heavy compute, large dependencies, or database-intensive work — those belong in central cloud.
Does running code at the edge always make things faster?
No. It only helps if the data the code needs is also near the edge. Edge code that makes several calls to a database in one distant region can be slower than central compute sitting next to that database — you've just moved the round-trips. This is "data gravity": co-locate data with compute, or keep data-heavy logic central.
What runs edge functions?
Platforms built on global CDN networks — Cloudflare Workers, Vercel Edge Functions, Fastly Compute, AWS CloudFront Functions/Lambda@Edge, Deno Deploy, and others. They use lightweight isolates or WebAssembly sandboxes for fast startup, and target web-standard APIs. See Cloudflare Workers.
Related Topics
- Serverless Patterns — Central serverless, the edge's complement
- Cloudflare Workers — A leading edge compute platform
- CDN — The content-delivery network edge functions run on
- Vercel — Edge functions and edge rendering for frontend apps
- Cloud Networking — How traffic reaches edge locations
- Web Performance — Latency reduction as a user-experience win
- Small Language Models — AI inference moving toward the edge