Scrivio Interview library
DesignAdvanced6 min read · updated 13 November 2026

A payments app serves users in North America and Europe. To keep writes local and meet residency rules, each user's data will live in a home region with its own primary, instead of in one global primary.

Design the home-region model: how users are assigned and found, how a payment between a European and an American user works, and how a user moves between regions.

Each user gets a home region at signup, recorded in a small global directory that is replicated everywhere and carried in the user's token, so most requests route straight to the right region without a lookup. A payment between a European and an American user is a cross-region workflow: a saga debits the payer in their home region and credits the payee in theirs, with a durable transfer record and idempotent steps, not a distributed transaction. Moving a user is a per-user migration: freeze, copy, verify, switch the directory entry, then delete the old copy where the law requires.

Why this question is asked

A single global primary is simple until two things push against it: European users pay a transatlantic round trip on every write, and residency rules say their data should live in Europe. A home-region model answers both, but it turns some operations that used to be one local transaction into workflows across regions. Interviewers ask this to see whether we can lay out the routing, the cross-region payment and the migration of a user without reaching for a distributed transaction. In this answer, we will design how users are assigned and found, follow a payment across regions, plan a user move, and look at the global features that need special care.

1The Architecture at a Glance

There are two regions, NA and EU, each with its own primary database for the users it owns, its own application services, and read replicas. On top sits a small global directory: a table from user id to home region. It is written rarely, at signup and during moves, and read everywhere, so we replicate it to every region and can even cache it in memory.

Requests arrive at an edge layer (a global load balancer or API gateway) in whichever region is closest to the user. That edge decides where to send each request, using the home region carried in the user's token.

Step throughHome-region payments architecture
  1. Edge / API gatewayreads home region from the token; forwards wrong-region requests
  2. Global directoryuser id -> home region; replicated everywhere, written rarely
  3. Regional services (NA, EU)accounts, payments, saga coordinator per region
  4. Regional primariesown each home user's data; residency boundary
  5. Read-only replicated copiespublic profile data of other users, for display

5 layers, from the top down. Step through them one at a time.

2Assigning and Finding a User's Home

The home region is assigned at signup from the user's residency and location, for example country of residence on the KYC form, falling back to IP location. We write the directory entry first, then create the account in that region. The directory is the only place that must agree globally, and because it is tiny and changes rarely, we can afford strong consistency for its writes.

To avoid looking up the directory on every request, the login service puts the home region into the session or token as a claim. The edge reads it and routes the request to the right region. If a request still lands in the wrong region, for instance from an old token or a client in another country, the region forwards it internally or answers with a redirect. Reads of other users' public data, such as a payee's display name, can come from read-only replicated copies, as long as those copies contain only data that may leave the region.

Java
// login: put the home region into the token so the edge can route without a lookup
String home = directory.homeRegion(userId); // "eu"
String token = jwt.issue(userId, Map.of("home", home)); // claim: home=eu
// edge: route by claim, forward if this is the wrong region
if (!claims.home().equals(localRegion)) {
return forwardTo(claims.home(), request); // or 307 redirect to eu.api.example.com
}

3A Payment Between a European and an American User

Suppose Elena (home EU) pays Nate (home NA) 100 EUR. Her balance lives in the EU primary and his in the NA primary. A single ACID transaction spanning both would need two-phase commit across an ocean, which holds locks for a round trip and blocks if either region is unavailable. We use a saga instead: a sequence of local transactions, each with a compensating action if a later step fails.

First, in EU, one local transaction debits Elena and writes a durable transfer record with status DEBITED and a unique transfer id. An outbox row in the same transaction ensures the next step is published. Then NA receives the credit request and, in one local transaction, credits Nate and records the transfer id as applied, so a duplicate message does nothing. NA confirms, and EU marks the transfer COMPLETED. If NA rejects the credit, say Nate's account is closed, EU runs the compensation: it refunds Elena and marks the transfer FAILED.

Every step is idempotent by transfer id, so retries after timeouts are safe, and the transfer record lets support and reconciliation jobs see exactly where any payment stands.

Step throughA cross-region payment as a saga
Elena (EU)EU paymentsNA paymentsNate (NA)
pay Nate 100 EUR
tx: debit Elena, transfer T1 = DEBITED, outbox
credit Nate for T1 (retried until acked)
tx: credit Nate once per T1
T1 credited
T1 = COMPLETED
you received 100 EUR

7 messages in order. Play them, or step through them one at a time.

If the credit is rejected, EU refunds Elena and marks T1 FAILED.

4Moving a User Between Regions

People move countries, so a user's home must change. We treat it as a per-user migration with clear steps. We freeze that user's writes, which for a payments app means briefly rejecting new payments and queueing inbound credits for a minute or two. We copy all of the user's rows from the old region to the new one, verify them with counts and checksums, then switch the directory entry, which is the moment the user's home changes. Tokens are refreshed so the new claim takes effect, and the freeze is lifted.

Only after a successful switch do we delete the data from the old region, where the residency law requires that, keeping whatever records the law requires us to retain, such as transaction history for audit, in the place the law says. If anything fails before the directory switch, we abort and the user simply stays where they were.

5Global Features and Residency

The danger in this model is the features that quietly assume all data is in one place. Search across users, fraud scoring, analytics dashboards and support tools each want data from both regions. If we simply copy everything into a global warehouse, we have broken the residency rule the whole design was built for.

So each needs an explicit design. Fraud scoring can run in each region on local data, with only model weights or aggregated, anonymised signals shared globally. Analytics can consume aggregated or pseudonymised feeds from each region. Support staff access EU users through tools that run in the EU region. Writing these down as part of the design is what keeps the residency promise true a year later.

6Follow-up questions

How do you keep the global directory available during a regional outage?

Every region holds a full replicated copy, and tokens already carry the home region, so routing for existing users keeps working from local data even if the directory's write path is down. Only signups and moves need a directory write; we place the authoritative copy in a store that spans regions with consensus, or accept that signups pause briefly, which is a small cost compared with blocking every request.

Why not two-phase commit for the cross-region payment?

Two-phase commit holds locks on both balances for at least a transatlantic round trip, and if the coordinator or one region fails at the wrong moment, the other side stays blocked. A saga with a durable transfer record keeps each step local and fast, and makes failures explicit and recoverable.

What does the user see while a payment is between regions?

The payer sees the transfer as pending immediately after the debit, and completed when the credit is confirmed, usually within a second. The transfer record makes this state honest instead of pretending the payment was instant.

7Conclusion

In this answer, we designed a home-region model: assignment at signup from residency, a small global directory replicated everywhere, and the home region carried in the token so the edge routes without a lookup, with wrong-region requests forwarded. A payment across regions became a saga of local transactions with a durable transfer record and idempotent steps, user moves became a freeze, copy, verify and switch migration, and global features like fraud and analytics got explicit designs so they do not copy residency-bound data out of its region.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd give every user a home region at signup based on residency, and keep a small global directory from user id to home region. It's written rarely, so I can afford strong consistency for writes, and it's replicated to every region for reads.

Then, if they want more

The login service puts the home region into the token, so the edge routes each request to the right region without a lookup, and a request that lands in the wrong region is forwarded or redirected. Other users' public data can be served from read-only replicated copies.

For a payment from a European user to an American one, I'd avoid a distributed transaction.

It's a saga: in the EU region one local transaction debits the payer and writes a durable transfer record plus an outbox message; the NA region credits the payee once per transfer id; then EU marks the transfer complete, or refunds the payer if the credit fails. Every step is idempotent by transfer id.

Moving a user is a per-user migration: freeze their writes briefly, copy, verify, switch the directory entry, refresh tokens, and only then delete from the old region where the law requires it. Finally, global features like search, fraud scoring and analytics need explicit designs, aggregated or anonymised feeds, so they don't quietly copy residency-bound data out of its region.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design the home-region model: how users are assigned and found, how a payment between a...": https://scrivio-interview-library.netlify.app/architecture/partitioning-and-replication/6250530c17/