Development

Choosing an Edge Region: Latency, Data Residency and Cost

Antonio Evans8 min read

A world map with glowing dots representing user clusters.
Key points

Key points

  1. 1Pick the edge region closest to your largest user cluster only after checking it against data residency rules and per-request cost at your expected volume.
  2. 2Measure round-trip times from each candidate region rather than assuming the nearest city is fastest, because database location can dominate total latency.
  3. 3Classify data by sensitivity and jurisdiction before you deploy, since edge networks route requests to the nearest node, not to a node you chose.
  4. 4Model request volume against each provider's pricing and invocation rules, because a region that wins on latency can lose on cost or on regional control.

Why the placement decision comes before the provider choice

Edge functions are serverless functions that run at the network location closest to the requesting user rather than in one broad cloud region, which lowers latency by shortening the distance data travels Netlify. That global reach is the whole promise: a request from Arizona answered by a local node returns faster than one answered from London Netlify.

The mechanism behind the speed is the runtime. Edge platforms run code in V8 isolates, lightweight sandboxes inside an existing engine process, instead of spinning up a container or virtual machine per request Cloudflare. An isolate can start around a hundred times faster than a Node process on a container and uses an order of magnitude less memory at startup Cloudflare. One practitioner analysis puts isolate creation under 1ms and a few hundred kilobytes, against 50 to 200ms and megabytes for a full Node process ResumeLens.

That speed does not tell you where your function runs. Most edge platforms route each request to the nearest point of presence automatically, which is the right default for stateless logic and the wrong default for anything that touches a distant database or a regulated record. The placement decision is therefore a separate design step with three inputs: user latency, legal residency and cost. Get the order wrong and you either pay for edge latency you cannot use or ship a compliance problem.

A useful rule before any measurement: if your function makes more than one call to a centralized database, the region next to the database usually beats the region next to the user. Vercel's engineering write-up describes exactly this, noting that a function doing three database lookups from Australia against a US East database can add over a second, so moving the function toward the data can be faster than moving it toward the user Vercel.

Step 1: Map where your users and your data actually are

Start with two maps, not one. The first is user concentration: pull request counts by country or metro area from your CDN or access logs over a representative month. The second is data location: list every database, object store and third-party API your function calls, and the region each one lives in.

The two maps rarely agree. A media site may draw most readers from Europe while its primary database sits in Virginia, and a B2B tool may have users spread thinly across dozens of countries but a single tenant cluster in Frankfurt. Supabase's documentation makes the trade-off explicit: edge functions execute closest to the user by default, but functions doing bulk database operations, large file processing or complex multi-round-trip queries often perform better pinned to the database region Supabase.

Write the two maps into a short table before you touch a dashboard. A worked example for a fictional store:

Candidate regionShare of monthly requestsPrimary data dependencyData dependency region
Frankfurt (eu-central-1)46%Orders databaseFrankfurt
N. Virginia (us-east-1)31%Orders databaseFrankfurt
Singapore (ap-southeast-1)15%Product catalog (read replica)Singapore
Sao Paulo (sa-east-1)8%Orders databaseFrankfurt

Reading this table, Frankfurt is the obvious first candidate: it serves the largest cluster and sits next to the orders database, which is the dependency that multiplies latency. Singapore is a candidate only for catalog reads. That is a placement decision you can defend in review, and it takes an afternoon to assemble.

Step 2: Measure round-trip time from candidate regions

Never ship a region choice based on a map. Measure. You want two numbers per candidate: the round trip from representative user locations to the edge node, and the round trip from that edge node to your data.

For the first, run a small probe from monitors in each user cluster against an endpoint deployed in each candidate region. For the second, time the actual database call from inside the function. The gap between the two is usually the surprise. Supabase users have documented the pattern: a hello-world function returns similar latency from any region, but a function making a few database calls went from 250ms in us-west to 1.1s in us-east to 2.3s in the Asia region, because every query crossed an ocean GitHub discussion.

Cold starts belong in the same measurement. Serverless functions can pay initialisation latency when an instance is created, and estimates for container-based platforms range from a few hundred milliseconds to a few seconds PayPro Global. Edge runtimes compress that, with one comparison putting serverless cold starts at roughly 50 to 500ms and edge cold starts at 50 to 200ms Netlify. Supabase reported internal medians of about 400ms for a cold first request and about 125ms for warm requests, varying by roughly 100ms across regions GitHub discussion. Treat those as reference points, then measure your own function, because your bundle size and dependencies move the number.

A practical probe loop looks like this:

# Deploy the same function to each candidate region, then sample from each user cluster
for region in eu-central-1 us-east-1 ap-southeast-1; do
  for run in $(seq 1 50); do
    curl -s -o /dev/null -w "%{time_total} $region\n" \
      -H "x-region: $region" "https://your-function.example/?probe=$run"
  done
done | sort -k2,2 -k1,1n

Sort by region, then by time, and read the median rather than the mean. One slow outlier should not move your decision.

Step 3: Classify data by sensitivity and jurisdiction before choosing

Latency finds the fastest region. Compliance removes some of them. Data residency means the data, including in-transit copies, backups, metadata and processing intermediaries, stays inside a jurisdiction's borders, while data sovereignty means the data is governed by the laws of the country where it sits OneSourceCloud. A provider can store data in a US region yet route telemetry through another country, which fails a strict residency requirement OneSourceCloud.

In the United States there is no single federal residency statute; requirements arrive through sector rules and state law. HIPAA's Security Rule does not explicitly require US-only storage, but in practice most business associate agreements specify US-only processing, making US residency a de facto requirement for clinical data OneSourceCloud. Financial institutions face similar scrutiny under the Gramm-Leach-Bliley Act and SEC rules, and federal contractors must meet FedRAMP requirements that keep data within the United States OneSourceCloud. IBM frames the wider problem for edge deployments: regulating where data lives is harder when processing is distributed across many locations, so sovereignty has to be designed into the architecture rather than added later IBM.

Turn this into a short classification before you pick a region:

Data classExamplesPlacement constraintTypical region rule
Regulated personal dataHealth records, card data, government recordsStays in one jurisdiction, no automatic reroutingPin to a single region in that jurisdiction
Personal data, generalAccounts, emails, order historyLawful transfer basis requiredPrefer user's region or one approved hub
Pseudonymous telemetryAggregated events, performance metricsUsually flexibleAny region, but document it
Public or cached contentCatalog text, images, static HTMLNoneAny region, global routing fine

The constraint row matters most. Supabase's documentation warns that when you pin a function to a region with the region header, requests are not rerouted automatically during an outage, so you should plan a manual failover Supabase. Automatic rerouting is a latency feature and a residency hazard at the same time.

Step 4: Model per-request cost against volume and region rules

Cost comes last because it depends on the region and the data class you have already chosen. Build a simple model: monthly invocations, average execution duration, memory setting and any per-invocation fee your platform charges. Multiply, then add the data transfer your region choice implies.

Region choice changes cost in three ways. First, some platforms charge differently by region, so the same function costs more in one location than another. Second, cross-region database calls add egress, so a globally routed function that queries a single database region pays for distance on every query. Third, tiered controls matter: a platform that offers only an "Earth" style option routes to the nearest user with no toggle, which is cheap to run but unusable for pinned compliance, as early Supabase users discovered when they needed functions beside their database rather than beside the user GitHub discussion.

A worked comparison for a function invoked 50 million times a month, averaging 5ms of execution:

OptionRegion strategyLatency to main user clusterCompliance fitCost drivers
AGlobal auto-routingLowestWeak: unknown routingPer-request fee plus cross-region database egress
BPinned to user hubLowStrong for one jurisdictionPer-request fee plus storage in one region
CSplit by user locationLow for mostStrong if each region stays in-jurisdictionDuplicated deploys, more configuration
DPinned to database regionMedium for distant usersStrongLowest egress, some user latency

Option D is the underrated one. It follows Vercel's advice to move functions toward the data when query waterfalls dominate Vercel, and it usually minimizes both egress and the number of regions you must audit. Option C is correct when no single region satisfies all three constraints. Supabase's documentation supports the split explicitly: use the user-nearest default for light, latency-sensitive work and pin to the database region for heavy operations Supabase.

Runtime constraints that limit where you can actually run

Placement also depends on whether your code runs at all on an edge runtime. Edge runtimes expose web platform APIs such as Fetch, Streams, Web Crypto and URL, and they exclude the filesystem, native modules and most Node core modules Edge Runtime guide. Edge also prohibits dynamic code evaluation, so eval and new Function fail, and bundles carry tight size limits OneUptime.

The practical consequence: a region is only a real candidate if your function can be built for that runtime. Teams routinely discover that a library with native bindings or a database driver that needs raw sockets forces the function back to a regional Node runtime, because those APIs are simply not present in the edge environment OneUptime. Check runtime compatibility before you count a region's latency as available.

Two more constraints worth writing into the plan. Isolates are evicted for resource limits or suspicious behavior, so do not store mutable state in global scope and expect it to persist Cloudflare. And because the network routes by anycast, an IP maps to a pool of machines rather than one host, so the "nearest" node can differ between users in the same country and between requests Stack Overflow. Your measurements should reflect that spread, not a single best-case probe.

A decision rule and a fallback plan

After the maps, the measurements, the classification and the cost model, the rule is short. Pick the region closest to your largest user cluster that satisfies every residency obligation for the data the function touches, then confirm that the per-request cost at expected volume fits the budget. If no single region clears all three, split traffic by user location or by data type, and pin each path separately.

Add one guard for the future. Re-run the measurements when a user cluster grows past roughly a fifth of traffic, when a new data store changes the dependency map, or when a regulation changes. Re-evaluate the split when cross-region egress becomes a visible line item.

If the function's main job is calling models rather than moving bytes, the region still matters, because routing every model call through one provider's endpoint can add distance you did not plan for. Quanta Inference puts text, image, video, audio and embedding models behind one OpenAI-compatible key, which keeps the model-call path consistent across regions and makes the placement math simpler: one egress pattern, one pricing unit, everywhere.

FAQ

FAQ

Do edge functions always run in the region closest to the user?

Most platforms route each request to the nearest point of presence by default, which is what makes them fast Netlify. That default is not guaranteed to match your data residency needs, and some platforms let you pin the region explicitly, after which requests are not rerouted automatically Supabase.

Should I place the function near users or near the database?

Count the database round trips first. If the function makes one fast query and returns, the user-nearest node usually wins; if it makes several queries against a distant database, moving the function beside the database is often faster overall Vercel.

How do I handle users in a country that requires data to stay local?

Classify that data as regulated, pin the function and its storage to a region inside that jurisdiction, and accept the latency for distant users. Split traffic so those users hit the pinned path while everyone else stays on the nearest node, as Supabase's regional invocation guidance describes Supabase.

Does pinning a region hurt cold starts or cost?

Pinning does not change cold starts much, but it removes automatic rerouting and can raise latency for distant users, and it may increase egress if the pinned region is far from your data. Supabase notes that pinned requests are not rerouted during outages, so budget for a manual failover path as well Supabase.

What should I measure before committing to a region?

Measure median and tail round-trip time from each user cluster to each candidate region, the same times for database calls made inside the function, and cold versus warm request latency. Team discussions on Supabase show the gap clearly: a trivial function looks identical everywhere while a database-backed one can go from 250ms to 2.3s across regions GitHub discussion.

Sources

Sources

  1. Edge Functions Explained | Netlify Blog
  2. How Workers works - Cloudflare Docs
  3. Edge Runtime: Vercel Edge Functions, Cloudflare Workers, Deno Deploy
  4. Colocate your edge to your data on Vercel
  5. Regional Invocations - Edge Functions
  6. Is it possible to choose which region(s) the Edge functions run in?
  7. What is Cold Start? Understanding Serverless Latency - PayPro Global
  8. Poor performance with Edge Functions #29301
  9. U.S. Data Residency in the Cloud: Requirements, ...
  10. Data Sovereignty at the Edge
  11. How to Fix 'Edge Runtime' Limitations in Next.js - OneUptime
  12. Exploring the infrastructure and code behind modern edge functions
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles