Skip to main content
Designing a Multi-Region Payment System — Anselm Fowel
AI & Technology

Designing a Multi-Region Payment System

11 min read
803 views
Share:

The first time I lived through a regional outage in production, we lost an entire availability zone in Frankfurt for about forty minutes on a Tuesday afternoon. Authorizations kept flowing because we had a warm standby in Dublin, but settlement files were half-written, and reconciliation the next morning took three engineers and most of a pot of coffee to untangle. Nobody lost money. But I remember thinking: we got lucky, and luck is not an architecture.

Designing a Multi-Region Payment System
Designing a Multi-Region Payment System

Multi-region for payments is not the same problem as multi-region for a social feed. If your timeline is a few seconds stale, nobody files a chargeback. If you double-capture a card because two regions both thought they were in charge, you have a very different Tuesday. This is a post about the decisions that actually matter, and the ones people obsess over that don't.

Why you actually need it, and why you might not

Let me start with an unpopular opinion: most companies reach for multi-region a year or two before they have any business doing it. A single well-run region with three availability zones will give you more nines than your payment partners can honor anyway. Card networks have their own downtime. Your acquirer has maintenance windows. Chasing five nines in your own stack while your acquirer offers three and a half is like fitting racing tyres to a car with a governor.

The real reasons to go multi-region are narrower and more honest than "high availability." Data residency is the big one for us: German merchant data that must physically stay in the EU, and increasingly specific rules per market. Latency to the authorizing bank matters when you are adding 120 milliseconds of transatlantic round trip to a flow with a hard timeout. And genuine disaster recovery, the kind where a region is gone for hours, not minutes. If none of those apply to you yet, spend the effort on your incident response instead.

When you do commit, commit for a reason you can write on one line. "We keep EU cardholder data in the EU and can survive the loss of any one region for up to four hours with no lost transactions." That sentence drove more of our design than any diagram did.

Active-active is a trap most of the time

Everyone wants active-active. It sounds efficient, it sounds mature, and it means no idle hardware. For a stateless API that reads from a cache, sure. For the part of your system that holds the authoritative ledger, active-active means two regions can accept writes for the same account at the same time, and now you own a distributed consensus problem that you did not want and probably cannot afford to get wrong.

We run active-passive for the ledger and active-active for everything in front of it. Gateways, tokenization, fraud scoring, the risk engine, the merchant dashboard read paths: all active in every region. The moment a request needs to change money, it is routed to the region that currently owns that account's shard. This is less elegant on a slide and far easier to reason about at 3 a.m. I would rather explain a slightly slower failover to an auditor than explain how two regions both decremented the same balance.

The question is never "can we run in two places at once." It is "what happens the instant they disagree." If you cannot answer that crisply for money movement, you are not ready to be active-active.

Idempotency is the whole ballgame

If I could tattoo one thing on every new payments engineer, it would be this: every write that moves money must be idempotent, and the idempotency key must be chosen by the caller, not generated by you. When a region fails over mid-request, the client retries. When a network blip drops the response but not the request, the client retries. If the second attempt creates a second charge, you have built a machine for generating chargebacks.

The key has to be stored with the result of the operation, not just as a lock. We learned this the hard way when an early version used a distributed lock with a TTL; the lock expired during a slow acquirer call, a retry slipped through, and we captured a payment twice. The fix was boring and correct: persist the key and the outcome in the same transaction as the money movement, and return the stored outcome on any replay.

-- Idempotent capture: the key and the effect commit together
BEGIN;

INSERT INTO idempotency_keys (key, account_id, status)
VALUES (@key, @accountId, 'in_progress')
ON CONFLICT (key) DO NOTHING;

-- If the row already existed, return the stored result and stop.
SELECT status, capture_id
FROM idempotency_keys
WHERE key = @key AND status = 'completed';

-- Otherwise perform the capture and record it atomically
UPDATE accounts
SET balance = balance - @amount
WHERE account_id = @accountId AND balance >= @amount;

UPDATE idempotency_keys
SET status = 'completed', capture_id = @captureId
WHERE key = @key;

COMMIT;

Notice there is no cross-region call in that transaction. The account lives in exactly one region at a time, so the idempotency guarantee is local and strong. Cross-region correctness is then just a routing problem, which is a much friendlier problem than a consensus one.

Partition by account, not by geography alone

People assume multi-region means "EU customers in the EU region, US customers in the US region," and geography does drive residency. But your real partition key is the account, or more precisely the ledger shard that owns an account. We shard the ledger and pin each shard to a home region. A German merchant's shard lives in Frankfurt with a synchronous replica in another EU zone and an asynchronous replica outside the region for disaster recovery only.

Routing then becomes a lookup: given an account, which region owns its shard right now. We keep that map small, cache it aggressively, and treat it as the single source of truth for write routing. It changes only during a deliberate failover or a planned shard migration, both of which are rare and both of which are logged like the serious events they are.

Enjoying this article?

Get more like it in your inbox — practical engineering leadership, fintech, and AI. No spam, unsubscribe anytime.

The trade-off I want to be honest about: cross-shard operations are painful. A payout that touches two merchants in two regions is a saga, not a transaction, and sagas are more code and more failure modes. We keep those rare by designing flows so a single money movement stays within one shard wherever we can. When we can't, we accept the compensating-transaction complexity and we test the compensation paths harder than the happy path.

Pick your consistency per data type, deliberately

Not all data deserves the same guarantees, and pretending it does makes everything slow. We sorted our data into tiers and gave each an explicit model:

  • The ledger and balances: strongly consistent, single-writer per shard, synchronous replication within the region. No exceptions, no eventual anything.
  • Tokenization and card vault: strongly consistent within region, replicated to other regions for read only, never writable remotely.
  • Fraud signals and velocity counters: eventually consistent and that is fine; a fraud score that is 200 milliseconds stale is still useful, and we design the rules to tolerate it.
  • Merchant configuration and pricing: eventually consistent with a propagation delay we document, because a new fee taking three seconds to reach every region hurts nobody.

The discipline is refusing to let convenience blur these lines. The pressure always comes to make one more thing writable in two places "just for this feature." Say no. Every time we bent this rule we paid for it in a reconciliation bug three sprints later.

Failover is a business decision, not a health check

Automatic failover for the ledger sounds great until you imagine it triggering on a thirty-second network partition and promoting a replica that was two writes behind. Now you have split-brain and a very expensive apology to write. For the money-moving core, we made failover a deliberate action with a human in the loop and a strict runbook, targeting a recovery time under fifteen minutes rather than under fifteen seconds.

The trick is making the safe choice the fast choice. Our failover promotes a synchronous replica, which by definition has every committed write, so we never lose a transaction. We fence the old primary hard, so even if it comes back it cannot accept a single write. And we rehearse it. Every quarter we fail Frankfurt over to its sibling zone during business hours, on purpose, with the whole team watching. The first rehearsal took fifty-one minutes and surfaced four bugs. The most recent took nine.

Everything in front of the ledger, though, fails over automatically and instantly, because those services are stateless or read-only and getting it wrong just serves a slightly stale fraud score. Match the aggressiveness of your failover to the cost of getting it wrong.

Clocks lie, so order events explicitly

Wall clocks across regions drift, and even with good NTP you cannot trust that a timestamp from Dublin is comparable to one from Frankfurt to the millisecond. For anything that depends on ordering, we assign a monotonic sequence per shard at the point of write, and we treat cross-region timestamps as advisory only. If two events need a definitive order and they touch the same money, they are on the same shard, so the shard's local sequence settles it.

This sounds academic until you are doing reconciliation and a settlement file from one region appears to happen before an authorization that logically preceded it. We chased a "time-travelling refund" for two days once, and the answer was a 400ms clock skew combined with an ordering assumption we should never have made. Now the rule is simple: never make a correctness decision by comparing timestamps from two different regions. Use sequences, use causality, use the shard.

Test the failures you are afraid of

You do not really have a multi-region system until you have deliberately broken it and watched it hold. Game days are not optional here. We inject region loss, we drop the link between regions to simulate a partition, we slow the replication stream, and we kill the primary mid-transaction. Each one has a documented expected behavior, and any surprise is a bug we file before we go home.

Observability has to be built around the money, not the machines. CPU graphs are fine, but the dashboards I actually watch during an incident are authorization success rate per region, replication lag per shard in milliseconds, and the count of in-flight money movements that have not yet reached a terminal state. That last one is the canary. If it climbs and does not drain, something is stuck holding real money in limbo, and that matters more than any host metric.

One more thing that pays for itself: a continuous, automated reconciliation job that compares the ledger against your acquirer's records every few minutes rather than once a day. Finding a discrepancy while it is one transaction old is a fix. Finding it the next morning is an incident.

Anselm Fowel, CTO and fintech architect
Anselm Fowel — CTO & fintech architect

The part everyone skips

If you take one idea from this, make it this: the hard part of multi-region payments is not the replication, and it is not the topology diagram everyone loves to draw. It is being honest about which surface can actually lose money, and keeping that surface small, boring, and sacred. The clever bits are rarely where you get hurt. The place you get hurt is the seam where two regions briefly disagree about who owns an account, and you had never decided what should happen there.

So rehearse the failover before you need it. The team that has failed over on a calm Tuesday afternoon, coffee in hand, is a completely different team from the one meeting split-brain for the first time at 3 a.m. with the acquirer on hold. Pick which team you want to be, then go book the game day on the calendar. Nobody ever regretted the drill they ran on a quiet afternoon.

Enjoyed this article? Share it with others!

Share:

Get new posts in your inbox

Occasional, practical notes on engineering leadership, fintech, and building with AI. No spam, unsubscribe anytime.

Comments (0)

Leave a Comment

Comments are moderated and will appear after review.

No comments yet. Be the first to comment!

About the author

Anselm Fowel

Anselm Fowel

Chief Technology Officer & fintech architect. 16+ years leading engineering across AlliancePay, Mondu, Transalliance, Global Accelerex, and Fidelity Bank — writing here about engineering leadership, fintech architecture, and AI in production.

Read next