Edge Computing
A distributed computing paradigm that brings computation and data storage closer to the sources of data.
Detailed Explanation
Edge computing (like Cloudflare Workers) runs logic at CDN locations near the user. By processing data at the 'edge' of the network instead of a central cloud data center, it drastically reduces latency for tasks like authentication, personalization, and real-time image resizing. It is essential for modern, global-scale web performance.
Quick Summary
Edge computing runs code on servers physically close to the user, at CDN points of presence or on-device, instead of in a single central data center. The win is dramatically lower latency for global users; the cost is tighter runtime constraints.
Key Takeaways
- Edge runtimes (Cloudflare Workers, Vercel Edge, Deno Deploy) usually use V8 isolates rather than full Node, startups in single-digit ms.
- Constraints: typically no native modules, limited memory (tens to hundreds of MB), short execution windows.
- Data at the edge: KV stores, R2/S3, Durable Objects, D1, designed for eventually-consistent or per-region access patterns.
- Best for read-heavy, latency-sensitive logic (auth checks, A/B tests, redirects, personalization) close to users worldwide.
- Not a replacement for the origin, heavy compute, large transactions, and tight consistency still belong in regional data centers.
When to use it
- Geo-aware redirects, language detection, and personalization at request time.
- Auth token validation and rate limiting before the request ever reaches the origin.
- Image and video transformations on-the-fly from a single source asset.
- A/B test variant assignment with no client-side flicker.
Common Mistakes
- Treating edge functions as drop-in Node.js, many Node APIs and packages don't exist in V8-isolate runtimes.
- Doing heavy CPU work at the edge and getting killed by execution-time limits.
- Reaching back to a single-region database from every edge POP, undoing the latency win.
- Ignoring cold-region behavior, your code might run somewhere with high latency to your data.
Edge Computing, Frequently Asked
Edge functions vs. regional serverless (Lambda)?
Edge functions trade runtime flexibility for proximity and near-zero cold starts. Lambda gives you full Node/Python/JVM but runs in one region. Use edge for fast request-path logic and Lambda for heavier work that doesn't need to be globally distributed.
Can I run a database at the edge?
Edge-friendly databases exist, Cloudflare D1, Turso/libSQL, Upstash Redis, Neon with HTTP, but they're built for low-latency reads and small/eventually-consistent writes. A traditional Postgres at the edge would just relocate the latency problem.
Is edge computing the same as CDN?
A CDN caches static content close to users; edge computing runs your code close to users. Modern CDNs (Cloudflare, Fastly, Akamai) bundle both, which is why the terms blur.