The Edge Computing Playbook: What to Run at the Edge (and What Not To)
The edge is fast because it's constrained. This is the decision map for what belongs at the edge, what belongs at origin, and how compute, data, caching, and auth fit together.
Key takeaways
- Run short, stateless request-shaping work at the edge, such as routing, redirects, token checks, cache logic and personalization.
- Keep heavy compute, chatty database access and authoritative writes near your data.
- If a function must call a single-region database several times per request, place it next to that database instead of next to the user.
On this page
Run routing, redirects, auth token checks, cache decisions and light personalization at the edge. Keep heavy compute, chatty database queries and strongly consistent writes at origin, next to the data. The edge wins when the work finishes without leaving the PoP; once every request reaches back to one region, a function near the database is faster.
Verified against
Wrangler 4.156.0, Cloudflare Workers runtime limits and Smart Placement docs, Vercel Edge runtime docs (updated 2026-08-03), against developers.cloudflare.com and vercel.com/docs. Checked October 2026.
Your code runs a few milliseconds from the user instead of a few hundred, and that speed comes with constraints: CPU and memory budgets, a restricted runtime, and data that lives somewhere else. Getting value from the edge is mostly about knowing which work fits inside those constraints. This page ties together compute, data, caching, auth and observability, with a deep dive linked for each.
What the edge is good at
Edge functions shine at short, stateless, per-request work that benefits from being close to the user:
- Routing and rewrites: A/B tests, feature flags, geo redirects, request normalization. This is the sweet spot for Vercel edge middleware.
- Auth checks: validating a signed token before a request ever reaches origin, covered in edge auth without origin round-trips.
- Caching and cache logic: deciding what to serve from cache, with patterns like stale-while-revalidate and disciplined cache invalidation.
- Personalization at the CDN: small transforms on cached HTML per user or region.
- Streaming responses: sending HTML while the rest is still assembling, via streaming SSR at the edge.
A minimal Worker that does two of those jobs, rejecting unauthenticated API calls and serving everything else from cache, looks like this:
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
if (url.pathname.startsWith("/api/") && !request.headers.get("authorization")) {
return new Response("unauthorized", { status: 401 });
}
const cache = caches.default;
let response = await cache.match(request);
if (!response) {
response = await fetch(request);
ctx.waitUntil(cache.put(request, response.clone()));
}
return response;
},
};
Real token validation (signature, expiry, audience) belongs in that first branch; the linked auth guide covers it.
What the edge is bad at
The constraints that make it fast make some work a poor fit. As of October 2026:
- Heavy compute. Cloudflare Workers Free allows 10 ms of CPU per request; Paid defaults to 30 seconds and can be raised to 5 minutes. Memory is 128 MB per isolate on both. Image processing, big transforms and model inference are still origin work. The ceilings are covered in edge runtime limits.
- Code that needs a full Node.js runtime. Workers now support most Node modules (
fs,http,net,crypto) behindnodejs_compat, enabled by default for compatibility dates from 2026-08-04. Vercel's Edge runtime is narrower: no filesystem, norequire, noeval, and a 1-4 MB gzipped code limit by plan. Vercel's own docs now say "We recommend migrating from edge to Node.js", and from Next.js 16.3runtime = 'edge'is no longer supported. - Chatty database access. A function 5 ms from the user but 120 ms from the database pays that 120 ms on every query. Three sequential queries cost more than running the whole function next to the database. This is the single most common edge mistake.
The data problem is the whole game
Compute at the edge is easy; data at the edge is the hard part. If the function reaches back to a single-region primary, you've moved the compute closer to the user and left the slow part where it was. Two fixes exist.
Move the function to the data. Cloudflare's Smart Placement watches request duration across locations and, if a location near your backend is significantly faster, forwards requests there:
name = "api-edge"
main = "src/index.js"
compatibility_date = "2026-10-01"
[placement]
mode = "smart"
npx wrangler deploy
curl -sI https://api-edge.example.workers.dev/api/orders | grep -i cf-placement
cf-placement: remote-LHR
remote-LHR means the request was forwarded to London near the database; local-EWR means it ran at the default location. Analysis takes up to 15 minutes after deploy, and the docs warn the header may change before the feature leaves beta. On Vercel, the equivalent is pinning a function's regions next to the database.
Move the data to the function.
- Edge databases replicate reads to the PoPs. See edge databases for low-latency apps, the Cloudflare D1 guide, and the Turso vs Cloudflare D1 comparison.
- Edge object storage like Cloudflare R2 vs S3 keeps assets close and egress cheap.
- Stateful coordination: when you need one authoritative place to serialize writes (counters, rooms, locks), Durable Objects give you one addressable instance instead of a race across PoPs.
The rule: read-heavy, latency-sensitive data gets replicated outward; write-heavy or strongly consistent data keeps a single home, and the edge reaches it only when it must.
Routing, platform choice and observability
Before any of this runs, the network routes the user to the nearest point of presence with anycast, explained in anycast and geo-routing. "The edge" isn't automatically the closest edge, and placement matters most for the data tier.
The Workers vs Lambda@Edge comparison covers the AWS angle. If your workload is really regional serverless, start from deploying a first Lambda function and read serverless cold starts.
Edge functions run in hundreds of locations, which makes debugging harder. You need logs, traces and metrics that aggregate across PoPs, covered in observability for edge functions. npx wrangler tail streams live logs from every location and is the first command to run when something misbehaves.
Failure modes and the errors they print
| Error text | Platform | Fix |
|---|---|---|
Error 1102: Worker exceeded resource limits | Cloudflare Workers | CPU or memory over budget; raise cpu_ms on Paid or move the work to origin |
Too many subrequests. | Cloudflare Workers | Over 50 fetches per request on Free; batch calls or upgrade |
Could not resolve "fs" with a hint to add nodejs_compat | Wrangler build | Add compatibility_flags = ["nodejs_compat"] or a newer compatibility date |
Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime | Next.js on Vercel | Remove the dependency doing eval, or switch the route to Node.js |
| Function size over the plan limit | Vercel Edge | Trim imports; Hobby allows 1 MB gzipped, Pro 2 MB, Enterprise 4 MB |
Where this breaks
This playbook assumes users spread across regions. If 90% of traffic comes from one country and your database is there, a well-placed regional function is as fast as the edge and far simpler. It also assumes a JavaScript or WebAssembly workload; long-running jobs, GPUs and native binaries belong elsewhere. And platform rules move fast: Vercel's recommendation flipped from edge toward Node.js on Fluid compute, so re-check the docs before you design around a runtime.
Questions people ask
What should run at the edge vs origin?
Run short, stateless, per-request work at the edge: redirects, A/B routing, token validation, cache decisions, header rewrites and light HTML personalization. Keep heavy CPU work, multi-query database access, payment flows and anything that needs strong consistency at origin, close to the data. If a request needs several round-trips to one region, the edge adds latency instead of removing it.
Is Vercel Edge runtime deprecated?
Not removed, but de-emphasized. As of October 2026, Vercel's Edge runtime docs say "We recommend migrating from edge to Node.js for improved performance and reliability", and both runtimes run on Fluid compute. From Next.js 16.3, setting runtime = 'edge' in routes and pages is no longer supported. Middleware and existing edge functions still work, but new work should default to Node.js.
What is the CPU time limit for Cloudflare Workers?
As of October 2026, Workers Free allows 10 ms of CPU time per HTTP request. Workers Paid defaults to 30 seconds and can be configured up to 5 minutes, and wall-clock duration has no limit for HTTP requests. Memory is 128 MB per isolate on both plans, and Free allows 50 subrequests per invocation versus 10,000 by default on Paid.
The call we'd make
Push the request-shaping work (routing, auth, caching, personalization, streaming) to the edge, and keep heavy compute and authoritative writes at origin. Then solve the data tier deliberately: replicate reads outward, keep strong-consistency writes in one place, turn on Smart Placement or regional pinning for functions that must talk to a single database, and reach for Durable Objects only when you need coordination. Start with one thing, auth or caching, measure the latency win, and expand from there.
Sources
Cite this article
Kiril Urbonas (2026). The Edge Computing Playbook: What to Run at the Edge (and What Not To). DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/edge-computing-playbook-what-to-run-at-the-edge
[The Edge Computing Playbook: What to Run at the Edge (and What Not To)](https://www.devopsness.com/blog/edge-computing-playbook-what-to-run-at-the-edge) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from Cloud
Explore more articles in this category
AWS IAM Roles Anywhere: Workloads Outside AWS Without Static Keys
We had long-lived AWS keys sitting in a datacenter we don't own. IAM Roles Anywhere let us delete every one of them. Here's the real setup.
Anycast and Geo-Routing: How Requests Reach the Nearest PoP
A request leaving a laptop somehow lands on a server 20ms away. Here is what actually decides which point of presence answers.
AWS ECS vs EKS: Choosing the Right Container Platform
We run both ECS and EKS in production. Which we use for what, and the actual decision criteria — not the marketing comparison.
You might have missed
Evergreen posts worth revisiting.