Skip to content

Data Locality and Edge Computing

CoreConceptJuly 18, 20267 min read

A product-page personalization API needs to answer in under 100ms for a good user experience. A shopper in Sydney hits it, and the request has to reach the origin server in Virginia and come back — a round trip that, even at the physical speed limit of light in fiber, cannot finish in under roughly 160 milliseconds. No amount of server-side optimization fixes that number; the origin server could respond in zero milliseconds and the request would still be too slow, because the distance itself is the bottleneck.

This guide follows that personalization request. We will calculate why distance imposes a hard latency floor no engineering removes, apply the edge compute patterns that actually address it — caching, edge functions, and data replication — weigh what moving data to the edge costs, trace a real incident where edge replication quietly violated a data-residency requirement, and decide what should and shouldn't run at the edge.

Sydney to Virginia and back: ~160ms floor before any processing happens
Sydney to Virginia and back: ~160ms floor before any processing happens

Distance has a latency floor no engineering removes

Light in fiber travels at roughly two-thirds the speed of light in a vacuum, due to the fiber's refractive index — about 200,000 km/s. Sydney to Virginia is a great-circle distance of roughly 16,000 km one way; a round trip at that speed alone takes about 160ms, before any server processing, TLS handshake, queueing, or actual computation happens. This is a propagation floor: a physical constant, not an engineering shortfall, and it cannot be reduced by a faster server, a better database, or more efficient code at the origin.

This matters because teams often try to solve a distance problem with a compute problem — optimizing the origin server's response time when the origin server was never the bottleneck. If the propagation floor alone exceeds the latency budget, the only lever left is reducing the distance the request has to travel — moving computation, data, or both physically closer to the user. This is the entire premise of edge computing: not that edge servers are faster than origin servers, but that they're closer.

The corollary matters just as much: for data or logic that genuinely must be globally authoritative (a real-time inventory count, an account balance), no amount of edge placement helps, because correctness requires reaching the one place that knows the true, current answer — the latency floor for that specific request is unavoidable, and the honest fix is budgeting for it, not architecting around it.

If the propagation floor exceeds the budget, only distance reduction helps
If the propagation floor exceeds the budget, only distance reduction helps

Quick reference

  • Fiber-optic light travels at ~200,000 km/s — about two-thirds the vacuum speed of light.
  • A propagation floor is a physical constant — no server-side optimization reduces it.
  • Sydney-to-Virginia round trip alone is roughly 160ms before any processing occurs.
  • If the floor exceeds the budget, the only lever is reducing physical distance, not compute time.
  • Globally authoritative data has no edge shortcut — the latency floor for reaching it is unavoidable.

Remember this

When latency comes from distance, optimizing the origin server is optimizing the wrong thing — the fix is moving computation or data closer, or accepting the floor honestly for data that must stay authoritative.

Edge compute patterns: caching, functions, and data replication

Edge caching (a CDN) serves a previously-computed, cacheable response from a point of presence near the user — it eliminates the round trip entirely, but only for responses that are the same for many users and can tolerate being slightly stale. It does nothing for GET /api/personalize?userId=u-501 — that response is unique per user and can't be cached against a shared key.

Edge functions (Cloudflare Workers, Lambda@Edge, and similar) run actual application logic at a point of presence close to the user, which helps with per-request computation — but if that function still has to call back to a centralized origin database for the data it needs, the propagation floor comes right back, just wrapped in a function instead of a direct API call. An edge function only removes the round trip if the data it needs is also local.

Edge data replication solves that: a subset of data relevant to a region is replicated out to regional or edge-adjacent stores, so an edge function can read locally without ever crossing the ocean. Combined with an edge function, this is the pattern that actually closes the gap for a request like this one — compute and data both move closer to the user, not just one of them.

Three patterns, each closing a different part of the gap
Three patterns, each closing a different part of the gap

Quick reference

  • Edge caching: eliminates the round trip for shared, cacheable responses only.
  • Edge functions alone: move compute closer, but data calls back to origin still pay the full floor.
  • Edge data replication: moves relevant data closer too, closing the gap edge functions leave open.
  • The combination (function + local data) is what actually removes the round trip for dynamic, per-user work.
  • Match the pattern to what the specific response actually needs — shared, computed, or data-dependent.

Remember this

Edge functions without local data still pay the propagation floor on every data call — the round trip only disappears when compute and data are both moved closer to the user.

Data locality trade-offs: consistency, cost, and residency

Replicating data to the edge almost always means eventual consistency — the same trade-off covered in strong vs eventual consistency: a regional copy lags the source of truth by some window, and a personalization model retrained centrally takes time to propagate to every edge location. For recommendation data, that lag is usually an acceptable trade for latency; for a real-time inventory count gating checkout, it usually isn't, and that data has to stay origin-authoritative regardless of the latency cost.

Storage and operational cost multiply with every additional location data is replicated to — a dataset replicated to fifty edge regions costs roughly fifty times the storage of one, plus the ongoing replication pipeline itself. This cost has to be weighed against the actual latency benefit for the specific data in question, not applied as a blanket "replicate everything everywhere" policy.

Data residency is the trade-off most likely to be missed entirely, because it's a legal and compliance constraint, not a technical one: some data (particularly EU personal data under GDPR-style rules) is legally required to stay within specific jurisdictional boundaries. A replication pipeline built purely to optimize latency, without a corresponding residency-aware filter, can silently violate that requirement the moment it starts replicating regulated data to edge locations outside the permitted region — exactly the failure traced below.

Edge replication trades latency for three real costs
Edge replication trades latency for three real costs

Quick reference

  • Edge replication almost always means eventual consistency — plan for a real propagation lag.
  • Storage and pipeline cost scale with the number of edge locations data is replicated to.
  • Data residency is a legal constraint, easy to violate silently in a latency-only replication design.
  • Weigh replication cost against the specific data's actual latency benefit, not as a blanket policy.
  • Compliance requirements need explicit filtering at the replication layer, not an assumption of safety.

Remember this

Moving data to the edge trades a real latency win for real consistency lag, multiplied cost, and — if the replication pipeline isn't residency-aware — a legal risk that's invisible until an audit finds it.

Failure story: recommendation data replicated straight past a residency boundary

Trigger. To hit the sub-100ms personalization target, the team builds an edge-replication pipeline that copies each user's profile and recommendation context to the nearest edge region — a purely latency-motivated design, built and shipped before any residency requirement existed for the product. Symptom. Months later, a compliance audit triggered by a new EU regulatory requirement finds EU users' personal profile data present on edge nodes in the US and APAC regions — data that was legally required to remain within EU infrastructure.

Root mechanism. The replication pipeline's design was "replicate every user's data to every edge region nearest their recent traffic," with no concept of jurisdiction attached to the data at all — it optimized purely for latency and had no residency dimension in its design, because residency wasn't a requirement when it was built and nobody revisited the pipeline when it became one. The pipeline was working exactly as designed; the design itself was the gap.

Evidence. Edge-node data audit logs show EU-origin user IDs present in the us-east and ap-southeast regional stores, with replication timestamps going back to the pipeline's original launch — this wasn't a recent bug, it had been true the entire time. Recovery: purge the non-compliant replicas immediately, notify legal/compliance to assess breach-notification obligations, and audit every other edge-replicated dataset for the same gap. Prevention: tag every dataset with its residency requirement at the source, enforce that tag as a hard filter in the replication pipeline itself (not a downstream check), and require a compliance review as a standing step before any new edge-locality initiative ships — not an afterthought triggered only by an external audit.

Failure: a latency-only replication pipeline had no residency dimension at all
Failure: a latency-only replication pipeline had no residency dimension at all

Quick reference

  • Trigger: an edge-replication pipeline built purely for latency, before a residency requirement existed.
  • Symptom: a compliance audit finds regulated data present in disallowed regions.
  • Mechanism: the pipeline had no jurisdiction concept — it replicated everywhere by design.
  • Evidence: edge audit logs showing the violation dates back to the pipeline's original launch.
  • Prevention: tag data with residency requirements at the source; enforce as a hard filter in replication.

Remember this

The pipeline never malfunctioned — it did exactly what it was built to do, which was the problem: a latency-only design with no residency dimension will eventually replicate the wrong data to the wrong place, silently and by design.

Choosing what runs at the edge

Start from what the specific response actually needs, not a blanket edge-everything or origin-everything policy. Fully shareable, cacheable responses go to a CDN. Per-request logic that can tolerate a real, bounded staleness window goes to an edge function paired with regionally-replicated data. Anything requiring a globally authoritative, immediately-consistent answer — a real inventory count, an account balance, anything fault tolerance vs high availability would call loss-intolerant — goes to the origin, and the latency cost is accepted honestly rather than engineered around.

Evaluate every edge-replication decision against three dimensions together, not latency alone: the consistency lag the data can tolerate, the storage/operational cost of replicating it to N locations, and — critically — its residency or compliance requirements. A design that only optimizes the first dimension is exactly how the failure above happened.

Treat data residency as a design-time filter baked into the replication pipeline from the first version, tagged at the data's source, not a policy applied after an audit finds the gap.

Choose from what the response needs — not latency alone
Choose from what the response needs — not latency alone

Quick reference

  • Cacheable, shared responses: CDN. Per-request, staleness-tolerant: edge function + regional data.
  • Globally authoritative, loss-intolerant data: origin only — accept the latency floor honestly.
  • Evaluate consistency lag, replication cost, and residency together, not latency alone.
  • Tag data with residency requirements at the source; enforce as a design-time filter, not an afterthought.
  • Revisit edge-replication designs whenever a new compliance requirement appears for existing data.

Remember this

Choose the edge pattern from what the response actually needs across latency, consistency, cost, and residency together — a design optimized for only the first of those four will eventually fail on one of the other three.

Key takeaway

Distance imposes a real, physical latency floor that no server-side optimization removes — the only fix for a request that must cross an ocean and back within a tight budget is moving computation and data closer to the user. Edge caching, edge functions, and edge data replication each address a different part of that problem, and each comes with its own cost: consistency lag, multiplied storage, and — the one most likely to be missed — data residency. A replication pipeline built purely for latency will eventually replicate the wrong data to the wrong place if residency was never part of its design.

Practice (30 minutes): pick one API in a system you know that serves a global user base. Calculate the propagation floor for its farthest realistic user (distance / fiber speed, round trip) and compare it against the endpoint's actual latency budget. If the floor exceeds the budget, identify what specific data the response depends on and whether that data could be replicated closer — then check, explicitly, whether any of it carries a residency requirement your replication design would need to respect. That last check is the exact gap this article's failure story came from.

Share:

Related Articles

A dashboard can look “fast” while users still wait, and a load test can report huge requests-per-second while p99 checko

Read

A team deploys their application to three regions, each with its own app tier, database, and network path. On paper, a f

Read

A URL shortener's redirect endpoint, GET /r/{code}, looks purely read-heavy — billions of redirects against a handful of

Read

Keep learning

Follow a structured path or browse all courses to go deeper.