Multi-Region and Geo-Distributed Systems Questions
Running a system across regions and continents: multi-region replication, data residency and sovereignty, geo-routing and CDN edge distribution, cross-region consistency and quorum placement, and conflict resolution when two regions accept writes. Covers regional failover and split-brain prevention, recovery objectives (RTO/RPO), region-by-region rollout and blast-radius containment, and the latency, cost, and consistency tradeoffs of going global. Global distribution strategy across the service and data tiers.
Design a global shopping-cart service that caches carts at the edge for low latency but must guarantee carts converge within 1 minute across regions. Describe cache strategy, replication/propagation model, conflict resolution, and cost vs latency trade-offs. Explain how eventually-consistent returns are acceptable or not for checkout flows.
Sample Answer
A shopping cart can safely be fast and loosely consistent for browsing and editing, but the moment of checkout needs a different, stricter path: cache and replicate cart edits at the edge using commutative operations that converge automatically within the 1 minute target, then require an explicit, authoritative validation step before money changes hands, because "the cart eventually agrees across regions" and "the charge is definitely correct" are two different guarantees that shouldn't share the same consistency budget.
Session consistency while a user moves between regions
Cart traffic is heavily read-dominated (reads far outnumber writes, since a user views their cart many times for every edit), and the harder requirement is session consistency: whichever edge a user's session is currently pinned to must always show that session's own latest write immediately, even if a global merge is still in flight elsewhere. This is solved by session stickiness, routing a given session consistently to the same edge region for its duration, with a fallback that, if the user's device roams to a new region mid-session, that new edge reads the user's own recent operation log directly rather than waiting for ordinary cross-region propagation, which is what keeps the cart feeling instantly correct to that one user regardless of the 1 minute global convergence budget.
Cache strategy
Each edit (add item, remove item, change quantity) is appended to a per-cart operation log at the edge closest to the user, rather than overwriting a single cart snapshot; the edge serves reads from its local, fast-growing log plus a periodic snapshot, giving low-latency reads and writes for ordinary cart interaction.
Replication and propagation model
Operations propagate from the accepting edge to every other region via a fast event stream, tagged with an HLC timestamp (hybrid logical clock: a timestamp combining wall-clock time and a logical counter so operations from different regions can still be ordered consistently) and an idempotent (idempotent: applying the same operation more than once has the same effect as applying it once) operation id so a retried or duplicated message never double-applies. Under normal network conditions this propagation completes in well under a second per hop; even allowing generous retry and batching overhead, reaching every region within the 1 minute target leaves wide margin.
Conflict resolution
Cart edits are modeled as commutative operations, similar to a CRDT (conflict-free replicated data type: a structure designed so concurrent updates merge automatically to the same result everywhere) for the item set, where add and remove converge regardless of order, and, for quantities, a structure chosen to match the operation rather than one structure for both operations, because the two cart edits that touch a quantity are not the same shape. "Add 2 of this item" is a delta and it commutes, so a counter-like structure is right: a cart at quantity 1 with two devices each adding 2 converges to 5, which is what the user did. "Change the quantity to 3" is a SET and it does not commute, so a counter is wrong for it: each edge converts the set into a delta against its own local view (+2 from 1), the two deltas merge, and the cart ends at 1 + 2 + 2 = 5 when the user asked for 3 on both devices. Model set-quantity as a last-write-wins register on that item's quantity field, tagged with the same HLC timestamp, which returns 3 for that case; model add-quantity as the counter. Tag each operation in the log with which of the two it is at the moment the client issues it, because the distinction is only recoverable from user intent and is unrecoverable afterwards. With that split, two regions adding different items to the same cart at the same time both survive the merge with no coordinator required, and a quantity edit from two devices lands on the number the user actually chose. For checkout specifically, this automatic merging is deliberately not trusted as the final word: the checkout step re-reads the full operation log, applies a final deterministic merge, and locks the cart before validating price and inventory.
Cost versus latency trade-offs
Fully synchronous cross-region replication on every cart edit would guarantee the cart is always identical everywhere, at a real latency and infrastructure cost that ordinary browsing and editing don't need; the chosen asynchronous, operation-based approach keeps everyday interaction fast and cheap, spending the extra synchronous cost only at the one moment, checkout, where correctness genuinely requires it.
Is eventual consistency acceptable for checkout?
For browsing, adding, and removing items, yes: a cart converging within a minute is invisible to a normal user, who is not adding items from two different continents within the same second. For the actual checkout and charge, no: checkout must perform an authoritative read of the fully merged cart state, lock it against further edits, validate current price and inventory, and only then commit the charge; if two checkout attempts for the same cart somehow race, such as a duplicate tab or a retried request, the right answer is to prevent the second charge rather than to undo it. Carry an idempotency key derived from the cart and the checkout attempt through to the payment call, so the second request resolves to the SAME payment rather than creating a new one, and pair it with the cart lock so only one attempt can reach the payment step at all. A first-commit-wins rule where the loser is refunded and notified is a fallback for the case where prevention failed (two distinct keys were somehow issued), and it should be described as remediation, not prevention: the customer saw two charges on their statement and then saw a refund, which is a support ticket and a trust problem even though the final balance is correct.
Worked example
A user adds an item from a mobile app in the US at time zero. That operation reaches the EU and APAC regions' logs, under normal conditions, well within a few seconds via the event stream; even in a degraded scenario with retries and batching delays pushing propagation to, say, 20 to 30 seconds, the cart still converges with roughly half the 1 minute budget to spare. If that same user opens the site from an EU browser 45 seconds later, they see the item, because normal propagation is far faster than the 1 minute target; if they had opened the EU site within the first second, the session-consistency path described above is what applies, not the propagation delay: because it is the SAME user's session roaming, the EU edge reads that user's own recent operation log directly instead of waiting for ordinary cross-region propagation, so they see the item they just added. The 1 minute convergence budget governs a DIFFERENT observer: another session or device that is not the one which issued the write, for example a partner sharing the cart, or an internal service in another region reading the cart for a promotion check. Keeping those two cases separate is the whole point of the split. If the design ever cannot distinguish them, for instance because session identity is unavailable to the roamed edge, then the user does briefly see a stale cart, and that fallback is the bounded staleness the 1 minute convergence target is defined to cover.
Trade-offs and pitfalls
The operation-log approach handles ordinary editing cheaply and converges well within budget, but it shifts real complexity onto the checkout path, which now has to do an authoritative merge and lock rather than trusting the fast path's already-converged state. The pitfall to avoid is skipping that authoritative re-validation because the cart usually converges fast anyway: the rare case where it hasn't yet converged is exactly the case a checkout-time safeguard exists to catch, and skipping it trades a rare, bounded staleness bug for an unbounded, unpredictable billing bug.
You're seeing high monthly cross-region egress costs due to frequent read replicas and backups. Propose concrete cost-optimization strategies that reduce egress while keeping acceptable latency and availability for a global read-heavy analytics dashboard. Include trade-offs for each suggestion.
Sample Answer
Direct answer
The recurring pattern behind high cross-region egress cost from read replicas and backups
is almost always "we keep shipping the same or overlapping data across regions more times
than necessary." The fix is to reduce how much crosses the wire (compress, deduplicate,
send deltas instead of full copies) and to reduce how often each region has to ask for it
(cache aggressively, pre-compute what the dashboard actually needs), not to simply accept
the current data movement pattern and look for a cheaper way to move the same bytes.
Concrete cost-optimization strategies
Consolidate read replicas instead of maximizing their number. Every additional read
replica in a new region is another target for the same replicated data stream. If several
regions with light traffic each have their own replica, check whether they could share one
replica in a nearby region plus a lightweight cache in front of it, cutting the number of
full replication streams while still meeting latency needs for those lower-traffic regions.
Trade-off: slightly higher latency for the consolidated regions' reads.
Pre-aggregate for the dashboard instead of shipping raw rows. A read-heavy analytics
dashboard usually queries the same handful of aggregate shapes repeatedly (totals by day, by
region, by category). Compute those aggregates once, close to the data, and replicate or
cache the much smaller aggregate result set across regions instead of the full raw dataset
each dashboard viewer's queries would otherwise touch. Trade-off: the dashboard becomes
less flexible for truly ad hoc queries that don't fit a pre-computed shape; keep a
narrower, more expensive path available for those.
Cache dashboard query results at the edge or in each region. If many users in a region
are looking at largely the same dashboard views, a shared cache with a sensible time-to-live
(TTL, how long a cached value is considered valid before refreshing) can serve most requests
without touching the cross-region data path at all. Trade-off: dashboard data is as fresh
as the cache TTL, not real-time; usually acceptable for analytics, rarely acceptable for
live operational data.
Move from full backups to incremental/differential backups. A full backup ships every
byte every time; an incremental backup ships only what changed since the last one. For large
datasets with a modest daily change rate, this alone can cut backup-related egress by a
large margin, since a full copy is only needed occasionally, with cheap incrementals
in between. Trade-off: restoring from an incremental chain is slightly more operationally
complex than restoring a single full snapshot, and you need to periodically consolidate the
chain so restore time doesn't grow unbounded.
Keep backup storage in-region rather than duplicating across regions by default. Ask
whether every backup genuinely needs a cross-region copy, or whether a single durable,
in-region backup (with a separate, less-frequent cross-region copy only for disaster
recovery purposes) meets the actual recovery requirement. Trade-off: slightly weaker
protection against a full-region disaster if the cross-region copy is less frequent, a trade
worth making explicit against the recovery point objective (RPO, the maximum amount of data the business can afford to lose, measured as time since the last good backup) the business actually
needs, not assumed away.
Compress data in transit for replication and backup streams. A straightforward lever
that reduces bytes moved for both read-replica streams and backup jobs, at the cost of CPU
time to compress and decompress; usually a clear win when the network, not compute, is the
constrained and costly resource.
Worked example
A dashboard queries daily revenue-by-region from a primary database replicated in full to
three regional read replicas, and takes nightly full backups shipped cross-region for
disaster recovery. Switching the dashboard to read from a nightly pre-computed
revenue-by-region aggregate table (a few thousand rows instead of the full transactional
table) lets you stop replicating the full transactional table into those three regions and
replicate only the small aggregate, and that narrowing is where the saving actually comes
from. Be precise about the mechanism, because it is easy to get backwards: a read replica's
cross-region bytes are driven by the write volume at the source, not by how many queries the
dashboard runs against the replica. Queries against a local replica never cross a region
boundary and cost nothing in egress at all. So pre-aggregation buys you egress savings by
exactly one of two routes, and you should know which one you are claiming: either by changing
what gets replicated (retire the full-table stream, ship the aggregate instead), or, if a
region has no local replica and the dashboard queries back to a remote primary, by shrinking
the result bytes each query drags across the boundary. Booking a saving from "fewer queries"
while the full replication stream keeps running is how a cost model promises a reduction that
never shows up on the bill. Switching nightly backups to incremental (with a weekly full baseline) cuts
backup egress by a factor worth computing rather than hand-waving. Seven nightly fulls ship
7 times the dataset size F every week. One weekly full plus six incrementals at a daily change
rate d ships (1 + 6d) x F instead. At a 5% daily change rate that is 1.3F against 7F, an 81%
cut; even at a heavy 10% daily change rate it is 1.6F, still a 77% cut. The shape of that
formula is the useful part: the saving comes overwhelmingly from dropping six of the seven
fulls, and the daily change rate only moves you around inside a narrow band, 81% at a 5%
change rate, 77% at 10%, and 86% in the limit of a dataset that never changes at all. That is
why this lever is reliably large across very different workloads.
Stretching the full-backup interval past a week is a separate decision, and the percentage
framing actively hides how large it is. At the same 5% daily change rate a fortnightly full
ships 0.83F per week against the weekly scheme's 1.30F, a further 37% cut, and a monthly full
ships 0.57F per week, a further 56%. On the percent-of-original scale those same three
schemes read as 81%, 88% and 92%, which looks like diminishing returns while the bytes are
halving. Check which denominator a cost model is quoting before you trust its ranking. The
reason to stop near a week anyway is restore time, not egress: every extra day adds one more
incremental the restore has to replay in order, so size the interval against the recovery
time objective and take the egress saving as a side effect up to that limit.
Both changes reduce cross-region bytes moved without touching the dashboard's actual
freshness requirement (daily figures, not real-time).
Trade-offs and pitfalls
- Don't optimize the replication path while ignoring what's actually driving the queries
behind it. If the dashboard's real requirement is "yesterday's numbers," architecting
for real-time freshness anywhere in the pipeline is wasted cost. - Incremental backups reduce egress but increase restore complexity and time; make sure
the recovery time objective (RTO, how quickly you must be back up after an incident) still
holds with the new backup shape before adopting it purely for cost. - Consolidating read replicas trades latency for cost; validate that the affected
regions' users won't notice the difference before rolling it out broadly.
Design a globally distributed user profile service that must serve 500M users, prioritize low-read-latency (p95 < 50ms), and allow eventual consistency across regions. Include choices for data replication, read/write routing, conflict resolution (CRDTs vs last-write-wins), caching layers, and how to handle GDPR-style data deletion requests across regions.
Sample Answer
At 500 million users with a sub-50ms read target, the design's center of gravity is "read locally, write to a home region, replicate asynchronously," with conflict resolution split by field type (automatic merging where that's safe, deterministic last-write-wins where it isn't) and a deletion workflow that treats a GDPR-style (GDPR: the EU's General Data Protection Regulation, which gives users a legal right to have their personal data deleted) erasure request as a high-priority event every region must acknowledge, not an ordinary asynchronous update.
Data replication and read/write routing
A profile service like this is typically read-dominated, for example around 90 percent reads and 10 percent writes per user on a typical day, which is why the design below spends its complexity budget on making reads fast and cheap everywhere rather than on optimizing the comparatively rare write path. Each user is assigned a deterministic home region, and the assignment function matters more than it looks. Hashing the user id is deterministic and trivially rebalanced, but it throws away the one input that actually determines write latency and legal exposure, namely where the user is; a European user hashed into an Asia-Pacific home region pays a trans-continental round trip on every profile edit and stores personal data in a jurisdiction nobody chose. Assign the home region from the user's own locality at signup (with an explicit, auditable residency override where regulation requires one) and keep a hash only as the tie-breaker for users with no locality signal, so the mapping stays deterministic without being arbitrary. Whatever the function, once assigned it is recorded rather than recomputed, so a user who travels does not silently change home regions; writes go to the home region first, then replicate asynchronously to every other region via a change-log stream. Reads are always served from the requester's local region, backed by a local cache, which is what keeps the p95 (95th percentile: 95 percent of requests are faster than this number) under 50ms regardless of where the user's home region is, at the cost of a read from a non-home region potentially being a few seconds stale relative to a very recent write.
Conflict resolution: CRDTs versus last-write-wins
For fields where merging concurrent updates makes sense (a list of interests, notification preferences), use a CRDT (conflict-free replicated data type: a structure designed so concurrent updates made in different regions merge automatically into the same result without needing a coordinator), for example an add-wins set, so two regions adding different preferences at the same time both survive the merge. For single-value fields where merging doesn't make sense (a legal name, a primary email), use LWW (last-write-wins: a rule that keeps whichever update carries the latest timestamp and discards the other), tagged with a timestamp that accounts for clock differences across regions, accepting that the earlier of two truly concurrent edits is silently lost, the correct behavior for fields where keeping both isn't meaningful.
Caching
A regional in-memory cache serves most reads with a short TTL and stale-while-revalidate (serving the cached value immediately while refreshing it in the background), which is what makes the sub-50ms p95 achievable at billions of reads per day.
GDPR-style deletion across regions
Treat a deletion request as a high-priority event, not a normal write, and separate the three things that are usually collapsed into one, because collapsing them is what leaves data being served while everyone believes it is gone.
1. Suppress reads everywhere, immediately, on a channel that cannot be stuck behind replication. Publish the user identifier to a small, independently replicated suppression set that every region's read path consults before returning a profile, and invalidate that key in every regional cache in the same step. This has to bypass the ordinary change-log stream entirely, because the whole point is that the stream can be backlogged. It also has to bypass stale-while-revalidate: a suppressed key must be a hard miss that returns not-found, never a stale copy served while a refresh runs, since stale-while-revalidate is explicit permission to keep serving an expired value and that is exactly the wrong behaviour here.
2. Then run the acknowledgement protocol. Mark the record deleted in its home region, propagate the tombstone to every region ahead of ordinary replication traffic, and require an explicit acknowledgment from every region before the request is considered fulfilled. This step is what gives you PROOF, and proof is genuinely valuable, but be clear that it is an observability guarantee and not the thing that stops the data being served; step 1 is what stops the data being served.
3. Then purge. Only after every region confirms does a background job perform the actual permanent purge from storage, caches, and backups, while an audit log retains proof that the deletion happened, without retaining the deleted personal data itself, for compliance purposes.
Give the protocol a deadline as well as an acknowledgement requirement. A region that has not acknowledged within the internal target (minutes, not hours) is an incident with an owner, not a row on a dashboard, because the regulatory clock for responding to an erasure request runs in days and weeks while the backlog is measured in minutes; a design that can wait indefinitely for one region has no bound at all.
Worked example
A user in Europe requests deletion. The home region marks the record deleted and pushes a tombstone event to the other regions' replication streams within a few seconds under normal conditions. If a region has a backlog and takes 40 minutes to acknowledge, the deletion is not yet considered complete system-wide. Be precise about what that buys and what it does not. Waiting for every region to acknowledge is what makes the gap VISIBLE, and visibility is worth having, because a design that fired the delete and assumed success would have silently left personal data live in the backlogged region well past when compliance believed it was gone. What the acknowledgement protocol does NOT do on its own is stop the data being served: for those 40 minutes the backlogged region still answers reads with the profile, and if the purge is gated on full acknowledgement then even the regions that already acknowledged are still holding the value in cache. That is why the read-suppression step runs first and independently. With suppression in place the 40 minutes become a compliance-reporting problem (the purge has not finished, and someone is paged), rather than 40 minutes of a deleted user's personal data being returned to callers in every region.
Trade-offs and pitfalls
Asynchronous replication keeps reads fast everywhere but means a write is visible in its home region before anywhere else, fine for ordinary profile edits and explicitly not fine for a deletion, hence treating deletions as a separate, higher-priority path rather than reusing the ordinary replication SLA. The pitfall to avoid is forgetting backups: a record purged from live storage and every region's cache but still sitting in a nightly backup snapshot is not actually deleted for compliance purposes, so the deletion workflow has to reach backups on a defined schedule too, not just live storage.
You experienced a 3-hour partial outage in the European region that increased latency and generated client errors. As the SRE lead, outline the post-incident review you would run: what data to collect, how to reconstruct the timeline, approaches to root cause analysis, remediation tasks, stakeholder communication, and preventative measures to add to the runbook.
Sample Answer
Direct answer
A post-incident review after a regional partial outage should reconstruct exactly what happened before assigning blame, quantify the real impact, find the root cause and its contributing factors, and turn findings into tracked remediation with named owners and dates.
Framework
- Data to collect: the timeline of events (deploys, config changes, alerts fired, on-call actions), metrics for the outage window versus a normal baseline (error rate, p50/p95/p99 latency, meaning the response time at the median and the slower 95th and 99th percentiles, resource saturation, meaning how close a resource like CPU is running to its limit, regional traffic split), sampled logs and distributed traces from affected requests, support ticket volume, and the cloud provider's own status page history if a dependency was involved.
- Reconstructing the timeline: normalize every timestamp to UTC first. Different teams logging in local time is a common source of a timeline that contradicts itself. Merge events from monitoring, deploy tooling, and the incident chat into one ordered log, and anchor it against trace IDs so you can see exactly which requests were touched by which change.
- Root cause approaches: stay blameless. Use "5 whys" for a single linear cause chain, or a fishbone (Ishikawa) diagram (a branching diagram that groups candidate causes into categories, like people, process, and systems, feeding into a single spine that points at the effect) when several contributing factors combined, for example a config push plus an already-saturated connection pool (the fixed set of reusable database connections a service shares across requests) plus a slow health check. Separate the triggering event from the underlying weaknesses that let it cascade into a 3-hour outage instead of a 10-minute blip.
- Remediation tasks: rank by likelihood of recurrence times blast radius (how much of the system or how many users a failure could affect) times effort, not by who argues loudest in the review. Give each item an owner and a due date, and mark a small subset as blocking before the incident can be closed.
- Stakeholder communication: engineering gets the full technical timeline; leadership gets impact numbers (duration, users affected, any SLA exposure, SLA meaning the contractual reliability commitment made to customers) plus the top fixes; customers get a short, plain-language summary of what they experienced, with no internal jargon and no premature root-cause claims.
- Runbook additions: turn each remediation into either an automated guardrail (a canary check, a tighter alert threshold) or an explicit manual step with a decision tree, so the next responder doesn't have to re-derive today's judgment calls under pressure.
Worked example
During the reconstructed timeline, the region's connection pool was sized for 500 concurrent connections. A downstream DNS change broke connection reuse, exhausting the pool in roughly 4 minutes and pushing p95 latency from 180ms to 3.2 seconds before an alert fired at the 6-minute mark. Detection, though, is the first 6 minutes of a 180-minute outage. A review that stops there has explained about 3 percent of the incident and left the other 97 percent unaccounted for, which is the single most common way a post-incident review produces cheap action items and no durable improvement. Slice the remaining time the same way you sliced the timeline and attach an item to each slice:
- Minutes 6 to 35, triage. The responder saw elevated latency and started on the application tier, because nothing in the alerting pointed at the connection pool. Item: emit pool utilisation and pool wait time as first-class metrics on the service dashboard, so the next responder starts where the problem is.
- Minutes 35 to 80, mis-scoped mitigation. Restarting application instances briefly drained the pool and made the graphs recover, so the team believed it was fixed and stopped investigating until latency came back. Item: write down "a mitigation that works twice and fails the third time is not a fix" as an explicit escalation trigger, because a partial mitigation that keeps working is more dangerous to a timeline than one that plainly fails.
- Minutes 80 to 150, cross-team diagnosis. Identifying the downstream DNS change required the network team, who were not engaged until the second escalation. Item: add the network on-call to the initial page for any regional latency incident rather than waiting for the application team to rule itself out first.
- Minutes 150 to 180, recovery and verification. The rollback itself was quick; confirming recovery across every affected client was not, because the queries had to be written during the incident. Item: pre-build the "is it actually better yet" dashboard so verification is a glance.
The 6-minute detection gap still earns an item of its own, lower the alert threshold and add a connection-pool-exhaustion signal instead of relying on latency alone to catch it, but rank it honestly: it is the cheapest item on the list and worth at most 6 of the 180 minutes. The expensive time went into triage and cross-team engagement, and a review that bills its whole finding to detection has optimised the part that was already nearly free.
Trade-offs and pitfalls
Rushing to a single root cause when several factors usually combined is the most common mistake. Remediation items with no owner or date quietly die in the backlog. Treating the review as a courtroom instead of a blameless exercise teaches people to hide facts in the next incident, which is the opposite of what the review is for.
Design a globally distributed e-commerce checkout system that must prevent overselling inventory while providing low latency across three regions that can experience network partitions. Describe data placement, partitioning of inventory by SKU or region, options for synchronous cross-region consensus versus local reservations, reconciliation strategies, and operational procedures for failover and sale events.
Sample Answer
Direct answer
Split "reserve the inventory" from "confirm the payment," and default the checkout hot path to
fast local reservations with asynchronous replication rather than a synchronous cross-region
agreement on every order. Reserve synchronous cross-region coordination for the narrow case that
actually needs it (the last few units of a nearly sold-out SKU), and use a background
reconciliation job to catch and correct the rare oversell that local reservations allow.
Structured elaboration
Data placement and partitioning. Inventory is partitioned by SKU. Each SKU has a home region
(wherever it historically sells most), but its remaining-count is replicated to all three regions
so every region can serve fast reads. Ahead of a known sale, split the total stock into a soft
per-region quota (a fixed sub-allocation), so most decrements happen entirely locally with zero
cross-region calls.
Synchronous cross-region consensus vs. local reservations.
| Approach | Extra latency per checkout | Behavior during a network partition (regions unable to reach each other) | Overselling risk |
|---|---|---|---|
| Synchronous quorum write (majority of regions must acknowledge) | About 75-105ms, bound by the round trip to the nearest other region | Blocks or fails checkout in the affected region | Near zero |
| Local reservation, async replication | Under 10ms | Fully available | Bounded but nonzero, needs reconciliation |
Derive that latency row rather than guessing at it, because a quorum of 2 out of 3 only waits on
the leader's nearest peer, never on the farthest. us-east and eu-west are 5,466 km apart
great-circle, which over a realistic 1.4x cable path at the speed of light in fiber is a 75ms
round-trip floor; ap-south's nearest peer is eu-west at 7,603 km, a 104ms floor. Those are floors,
so real links sit at or above them and never below, and nothing in a three-region set like this can
plausibly reach 200ms or more on the nearest-peer path: even the widest pair here, us-east to
ap-south at 12,861 km, floors at about 176ms, and that pair is never the one a majority waits on.
Reconciliation strategies. Two-phase commit (2PC, a coordinator that locks every region's row
and only commits once all regions confirm) gives strong correctness but structurally cannot
survive a partition without blocking: if the coordinator can't reach a region, the transaction
holds its locks open, trading away the availability the question requires. A saga instead breaks
checkout into local steps (reserve stock locally, charge payment, confirm order), each committed
locally with a compensating action if a later step fails (release the reservation, issue a
refund); it tolerates partitions because no single step needs cross-region agreement, at the cost
of a brief window where state is only eventually consistent. Eventual reconciliation goes further:
accept optimistic local reservations, replicate lazily, and run a periodic job that compares the
true committed total against the SKU's real stock and cancels the newest oversold orders first.
Idempotency. Every checkout call carries a client-generated idempotency key (cart-session id
plus attempt number). A retry sent because a partition caused a timeout hits the same key and
returns the original reservation result instead of creating a second one, which is what makes the
saga's local-commit-then-retry pattern safe to use at all.
Operational procedures. Before a known sale event, pre-allocate the per-region quota with a
safety margin, canary (canary: route a small slice of real traffic through the new path first, to catch problems before full rollout) the flash-sale traffic path days ahead, and run a scripted failover drill:
mark a region degraded, freeze new reservations there, and reroute its traffic to the two healthy
regions before it matters for real.
Worked example
Take one SKU with 40 total units, quota-split 15/15/10 across us-east/eu-west/ap-south ahead of a
flash sale. Peak demand runs at 50 checkout attempts/sec in each of the three regions once the sale
opens globally; state the rate per region rather than globally, because that is the quantity the
formula below consumes. Replication lag is L=0.2 seconds between regions. If we had instead pooled a single shared counter with async
replication and no quota, the worst-case transient oversell across the other 2 regions before
us-east's decrement is visible is r×L×(N−1)=50×0.2×2=20 units,
literally half the stock. The hard per-region quota avoids this: us-east burns its 15-unit quota in
15/50 = 0.3 seconds and can locally reject its 16th reservation with zero cross-region calls, and
every attempt after that 0.3-second mark is refused locally in under 10ms. Under the
synchronous-consensus alternative each of those same attempts would wait on a cross-region round
trip of roughly 75ms before being told no, and the same 75ms tax lands on every checkout for every
other SKU in the catalog, including the overwhelming majority that are nowhere near selling out and
will never contend for a last unit. Be careful how you frame that last point for this SKU
specifically: 40 units against, say, 5,000 attempts means 4,960 of them (99.2%) cannot get stock no
matter what the design does, so the argument here is not "most attempts never contend," it is "the
contention is resolved locally in under 10ms instead of remotely in 75ms." The "most attempts never
contend" argument is the one that applies across the catalog, not inside a sold-out flash sale.
Trade-offs & pitfalls
Quotas can strand demand when one region runs out while pooled stock still exists elsewhere;
mitigate with a lightweight, off-hot-path "quota nearly exhausted, can I borrow N" signal between
regions rather than putting that check on every checkout. Decide a fairness rule (first-committed
wins vs. random) before the sale, not after reconciliation finds an oversell, or support will give
customers inconsistent explanations. Two-phase commit is the pitfall people default to because it
"sounds correct"; it is the one option here that structurally cannot survive a partition without
blocking, so treat it as a last resort, not the starting design.
flowchart LR
C[Client checkout request] --> R1[us-east: local quota check]
R1 -->|quota ok| Reserve[Local reservation with idempotency key]
Reserve --> Pay[Payment charge]
Pay --> Confirm[Order confirmed]
Reserve -.async replication.-> R2[eu-west view]
Reserve -.async replication.-> R3[ap-south view]
Recon[Reconciliation job] --> R1
Recon --> R2
Recon --> R3
Recon -->|oversold found| Cancel[Cancel and refund newest order]
Unlock Full Question Bank
Get access to all Multi-Region and Geo-Distributed Systems interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.