System Design · Concept Library · Free article
Consistency vs Locality: Where Should This Data Live?
The closer data sits to the user who writes it, the harder it is to keep consistent everywhere at once, even on a healthy network. So the useful question is not whether a system is strongly or eventually consistent but which data needs which, decided workload by workload.
Locality means keeping a piece of data close to the user who uses it; consistency means everyone everywhere sees the same latest value. Across a planet, you can’t max both — the closer you home a write, the harder global consistency gets. This isn’t the CAP tradeoff (that’s about a partition); it’s the everyday, healthy-network one, and it’s spatial: a globally-consistent write must be agreed across regions, and agreement across an ocean is slow by the speed of light — so a globally-consistent write is a globally-slow write. The senior move is to stop asking "is our system strongly or eventually consistent?" and start asking it per workload: money and uniqueness need strong consistency (read the home authority, pay the distance); a user’s own cart or just-saved page needs a session guarantee (read-your-own-writes); a like-count or a public bio is fine eventual (read the nearest local copy, converge later). You place each data class on the spectrum by hand — spending scarce, slow, global consistency only where a wrong answer is unacceptable, and letting everything else be fast and local.
Two features, one company, opposite answers
You’re in a design review for Hatch’s new two-region setup. Someone asks the question that always gets asked: "So — are we strongly consistent, or eventually consistent?" The whole room looks at you. And the honest answer, the one that separates a staff engineer from a junior, is a question back: "For which data?"
Because Hatch holds both of these at once. When a creator upgrades to Pro, the payment and their account balance must be right everywhere, instantly — bill them twice, or let a stale balance overspend, and you’ve lost trust and money. But the view count on their page? If a fan in London sees 1,204 while a fan in Tokyo sees 1,207 for a few seconds, nobody cares, and nobody ever will. Same company, same database technology, same afternoon — and the correct consistency for these two is opposite. Answer "strongly consistent" for the whole system and you’ve just dragged every like-count across an ocean for nothing. Answer "eventually consistent" and you’ve let a balance go wrong. The real design isn’t a single answer; it’s a decision you make per piece of data.
Why you can’t have both at full strength
Here’s the physics, in one sentence you already earned on the flagship: a globally-consistent write is a globally-slow write. To be consistent everywhere, a write has to be agreed across regions before it counts — and agreement across an ocean costs a ~300 ms round trip set by the speed of light, not by your budget. To be local — fast for the person writing it — the write has to commit near them, without waiting on the far side of the world. You cannot do both for the same write at the same time: the moment you make it local, some other region is, for a beat, looking at an older value.
So consistency-vs-locality isn’t a switch, it’s a spectrum you place each data class on. Step across the three ways to own data across regions and watch locality rise as cross-region consistency falls — and conflict risk appear at the far end:
The interactive version of this example is available when JavaScript loads.
Two kinds of “local”: one home vs every region
Look closely at the middle and right of that spectrum, because they are genuinely easy to confuse: region-homed single-leader and active-active both keep the common write local, so on a happy day they feel identical. The difference — the one that decides whether you ever get a conflict — is not "are writes local?" It is how many regions are allowed to write the same record. Follow one record and it becomes obvious.
Region-homed: one home per record. Mei’s page lives in APAC, so her morning saves commit on a local majority — fast. A different creator’s page lives in US-East, so their writes are local too. The locality here comes from placing each record’s single home where its usual writers are — so across millions of records, most writes are local. But any one record still has exactly one authority. If Mei flies to New York and edits her page, that write is routed back to APAC and crosses the ocean (slow, but safe) — she does not get a second local home just because she travelled. One authority per record means there is always one truth, so nothing ever conflicts; the only price is that far-away reads of her page can be a beat stale.
Active-active: every region is a home for every record. Now Mei’s page can be written locally from APAC, US-East, or anywhere — so even the travelling Mei writes with no ocean. That is genuinely more locality than region-homing, because it makes the out-of-region write local too. But the record now has many authorities, and two of them can accept a write at the same instant — Mei-in-Tokyo and a queued edit back in US-East both change the page — leaving two versions with no built-in referee. Maximum locality, bought by giving up a single truth.
| Question | Region-homed single-leader | Active-active |
|---|---|---|
| How many regions can write ONE record? | Exactly one — the record’s home | All of them |
| The common write (writer in their own region) | Local & fast | Local & fast |
| A traveller’s / out-of-region write | Routed back to the home → crosses the ocean | Accepted locally → can conflict |
| Single source of truth per record? | Yes — no conflicts | No — needs a merge rule |
| What locality costs you | A beat of staleness on cross-region reads | The single truth itself (write conflicts) |
This is not the CAP tradeoff
It’s tempting to file this under CAP, but they’re different animals, and mixing them is a junior tell. CAP is about a partition — a rare, broken moment when the network splits and you must choose consistency or availability until it heals. What we’re talking about here happens on a perfectly healthy network, on an ordinary Tuesday, on every single request. Nothing is broken; distance is simply charging its tax.
The closest relative is PACELC’s "Else" leg — else (no partition), choose Latency or Consistency — and the CAP page owns that idea in full. But even PACELC frames it as a question about time: how long do you wait for your replicas to agree (synchronous) versus acknowledging now and shipping copies later (asynchronous)? Consistency-vs-locality asks the spatial version of the same question: not how long do you wait, but where do you put the authority — near this user (local, fast, but out of step with everyone else) or in one agreed place (consistent, but far for most people). Same underlying tension, a different knob: PACELC tunes the clock, locality places the map.
Classify every workload into one of three buckets
The framework is simple enough to run in your head in an interview: for each piece of data, ask "what does a stale answer cost here?" — and the answer drops it into one of three buckets, each with a home on the spectrum. You met these three as read guarantees on the read-replica page; here they become placement decisions across regions.
| Bucket | What a stale answer costs | Where it lives / how you read it | Examples |
|---|---|---|---|
| Strong (global) | Unacceptable — money lost, a rule broken | One agreed authority; reads go to the home leader and pay the distance | Account balance, a payment, claiming a unique @handle, inventory you can oversell |
| Session (read-your-own-writes) | Confusing for one user — they don’t see their own change | Pin the recent writer to their home briefly; everyone else reads local copies | Your own just-saved page, your shopping cart, your draft |
| Eventual (local) | Invisible — a beat behind and nobody notices | Serve from the nearest local copy; let it converge in the background | Like/view counts, a public bio, a feed, a catalog, telemetry |
Now run it on real workloads and feel how the same app lands each in a different bucket — some reads crossing the ocean for freshness, most staying local and fast:
The interactive version of this example is available when JavaScript loads.
A three-question placement recipe
Buckets tell you the guarantee; to turn that into a placement, ask three questions about the data class: where do its writers cluster? (one region, or everywhere), must its reads be current? (strict, or a beat-stale is fine), and can you tolerate — and resolve — conflicting writes? (no, or yes with a merge rule). Those three answers point almost mechanically at one of the models from the spectrum. Try it:
The interactive version of this example is available when JavaScript loads.
Gotchas
- Consistency creep — everything drifts to strong. One incident, one "just to be safe," and suddenly reads that never needed it are crossing an ocean. Global consistency is scarce; audit which reads actually demand it and demote the rest.
- A strong read served from a local copy by accident. The most dangerous bug: a balance or inventory read silently routed to a lagging replica because the default connection was local. Must-be-current reads have to be explicitly pinned to the authority — never left to which connection you grabbed.
- Reading the home authority by habit. The opposite mistake — paying the distance on every read when a nearby copy would do. If a stale answer is invisible, a strong read is pure waste.
- Session guarantees without sticky routing. Read-your-own-writes only works if the same user is consistently routed to their pinned home (or to a copy that has caught up). Bounce them across regions and they’ll see their own change flicker in and out.
- Forgetting locality has a legal floor. Sometimes where data lives isn’t your call — data-residency law fixes the home region regardless of latency. Treat compliance as a hard constraint that overrides the performance-optimal placement.
- Chasing the locality extreme without a conflict plan. Reaching for active-active because "local everywhere" sounds ideal, without a merge rule, doesn’t buy you locality — it buys you silent lost writes. Adopt write-anywhere deliberately, with conflict resolution, or not at all.
What to watch
- Share of strong / cross-region reads. Your bill for consistency. A rising fraction of reads hitting a far authority means consistency creep — or a workload misclassified as strict.
- Staleness, as an SLO per workload. For eventual data, bound how stale a local copy may be (e.g. "99% of reads ≤ 200 ms behind") and alert when the replication lag blows the budget — different budgets for a bio versus a cart.
- Cross-region read latency (p99). The felt cost of every strict read that crosses a border. If it’s creeping into user-facing paths, some read is paying distance it shouldn’t.
- Local-write ratio (carried from the flagship) — the share of writes that commit locally. Tells you your homes are placed where the writers are, which is half of getting locality right.
Rapid-fire cheat-sheet (intern → principal)
- "Is your system strongly or eventually consistent?"
- The right answer is "for which data?" Consistency is a per-workload choice: strong for money and uniqueness, session (read-your-own-writes) for a user’s own data, eventual for counts and feeds. A single system-wide answer is a junior tell.
- "Why can’t I have both full consistency and full locality?"
- Because global consistency means a write is agreed across regions before it counts, and agreement across an ocean is slow by the speed of light. Locality means committing near the writer without that wait — so the instant a write is local, another region is briefly out of step. A globally-consistent write is a globally-slow write.
- "How is this different from CAP?"
- CAP is a rare partition — stay correct or stay available while the network is split. This tradeoff happens on a healthy network, on every request. Its kin is PACELC’s ELC leg, but PACELC tunes how long you wait for replicas (sync vs async); consistency-vs-locality is about where you physically place the authority relative to the user.
- "How would you decide where a piece of data lives?"
- Three questions: where do the writers cluster, must reads be current, and can you tolerate conflicts? Concentrated writers + tolerant reads → region-homed single-leader (the sweet spot). Strict reads → one authority, read the home leader. Global writers + conflicts you can resolve → active-active with a merge rule. Global writers + strict reads → global-synchronous (pay the round trip) or relax the requirement.
- "A user updated their profile and it looked like it didn’t save. What happened?"
- A read-your-own-writes miss: their write went to the home region, and their immediate read hit a local copy that hadn’t caught up. That data belongs in the session bucket — pin the recent writer to their home (or to a caught-up copy) for a short window; everyone else keeps reading local copies.
- "When would you actually pay for global strong consistency?" (the principal one)
- Only where a wrong or stale answer is irreversible or dangerous: money, inventory you can oversell, a uniqueness constraint, who-is-the-leader, config everything trusts. It costs a cross-region round trip on every such op, so it’s scarce — spend it there and let everything else be fast and local. Overusing it makes the system slower and less available for no benefit.
The takeaway
By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.