Why this matters
- Topology choice drives failover behavior, write conflict resolution, and operational runbooks.
- ShardPay uses leader-follower per shard for CP writes — the pattern most financial systems standardize on.
- Multi-leader and leaderless topologies solve real problems (geo latency, partition tolerance) but introduce reconciliation costs ShardPay avoids on the ledger.
- Database track articles implement these patterns in storage engines — this article frames when to pick each.
Three topologies
ShardPay's ledger shard has one leader and two followers in the primary region, plus one async read replica in a secondary region. Cross-region replica lags 100–500ms but offloads merchant history queries. Multi-leader replication was evaluated and rejected: concurrent balance updates in two regions require conflict resolution that violates ShardPay's "no negative balance" invariant without expensive locking.
Topology comparison
- Leader-follower (primary-secondary) — Single writer (leader) accepts all mutations; followers replicate the log and serve read traffic. ShardPay's default: one Raft leader per shard handles all debits and credits; followers catch up via append-only log replication.
- Multi-leader (multi-primary) — Multiple nodes accept writes, often per region. ShardPay's EU and US notification services use multi-leader local outboxes — conflicts merge by
transferId, not by balance arithmetic. - Leaderless (Dynamo-style) — Any replica may accept reads/writes subject to quorum rules; no fixed leader role. ShardPay's session cache layer uses leaderless quorums for idempotency key storage where last-write-wins on TTL keys is safe.
- Synchronous vs asynchronous replication — Sync replication waits for follower ack before commit (higher durability, higher latency). ShardPay sync-replicates within the primary region (W=3 of 3 local replicas) and async-replicates to the DR region for read scaling only — DR replica is not in the write quorum.
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 2 sections
- Leader-follower in production
- When ShardPay uses other topologies
Test yourself
Answer these before moving on — recall is what makes it stick.