Back to blog
Edge-First Architecture: Why Your Backend Should Live 50ms From Every User — CloudCode blog

Edge-First Architecture: Why Your Backend Should Live 50ms From Every User

8 min readDeep Dive

In 2026, distributing logic to 300+ edge locations globally is cheaper, faster, and more resilient — and cloud IDEs enable it natively.

The Latency Tax of Centralised Infrastructure

Every millisecond of latency costs money. Not in the abstract sense that slow apps are bad for business, but in a measurable, quantifiable sense. Akamai research found that a 100ms delay in load time reduces conversion rates by 7%. Google found that slowing search results by 400ms reduced searches per user by 0.59%. Amazon calculated that a 1-second slowdown would cost them $1.6 billion in sales per year.

The dominant model for web application deployment for the past twenty years has been to run your application on a handful of servers — often all in a single data centre, or distributed across two or three geographic regions. A user in Sydney making a request to an application running in Virginia travels roughly 16,000 kilometres. At the speed of light, that is 53ms each way. In practice, with network hops, TCP handshakes, and TLS negotiation, a fast cross-Pacific request easily exceeds 300ms round trip time.

Edge-first architecture is the answer to this latency tax.

What Edge Execution Actually Means

Edge computing distributes your application's logic to dozens or hundreds of locations globally, each physically close to a population of users. Instead of a request travelling from Sydney to Virginia and back, it travels from Sydney to a data centre in Sydney or Singapore — a round trip measured in single-digit milliseconds.

The enabling technology is a new category of runtime: V8 Isolates running inside edge infrastructure. Cloudflare Workers, Vercel Edge Functions, Fastly Compute, and Deno Deploy all run JavaScript or WebAssembly at the edge using this model. Each request is handled by an isolated execution context — no shared state, no long-lived processes, no cold start problem of the kind that plagued first-generation serverless functions. V8 Isolates start in under a millisecond.

The Architecture Implications

Statelessness is mandatory. Edge functions are stateless by design. You cannot store anything in memory between requests — each request arrives at an isolate that may be on a completely different physical machine from the previous request from the same user. This forces you to think carefully about where state lives.

The data layer becomes critical. If your logic is at the edge but your database is in a single region, you have moved the latency problem without solving it. A 5ms edge function that makes a 200ms database round trip is not an edge-first application. The data layer needs to follow the compute to the edge. This is driving adoption of globally distributed databases — Cloudflare D1, PlanetScale, CockroachDB, and database replication at the edge through services like Fauna. CloudCode's managed backend uses Supabase, which supports edge-proxied connections that significantly reduce the latency of database access from edge functions.

Caching strategy changes fundamentally. At the edge, caching is not an optimisation afterthought — it is a core architectural primitive. Every piece of data your edge function reads should be evaluated against a cache-vs-database trade-off. Static content should be cached at the edge indefinitely. Personalised content should be cached with short TTLs. Highly dynamic content may need to bypass the cache entirely.

When Not to Use the Edge

Edge-first architecture is not always the right choice. Edge runtimes have strict CPU time limits — Cloudflare Workers currently limit CPU time to 50ms per request. If your handler needs to run a complex image transformation, a machine learning inference, or a large database aggregation, you need a conventional serverless function or a dedicated compute instance.

Complex database transactions with multi-table joins are also difficult to optimise for low latency when your database is regionally distributed. Stateful protocols like WebSockets and server-sent events require a long-lived connection to a specific server, which edge isolates are not designed for (though Cloudflare Durable Objects are beginning to address this gap).

Getting Started With Edge-First in CloudCode

CloudCode's one-click deploys put your static assets on Vercel's global network, and a small Express API can go out as a Vercel serverless function. For edge handlers, the practical path today is Supabase Edge Functions, which run on Deno's runtime close to your users.

You can write Supabase Edge Functions directly inside CloudCode — or have the agent generate them with the Deno runtime API in mind — then push the project to GitHub and deploy them with the Supabase CLI.

The recommended approach for new projects is to default to edge deployment for all request handlers, and to move handlers back to conventional serverless only when you encounter a specific capability limitation that requires it. Start at the edge; step back only when you must.