81. How would you design cross-region replication for a mission-critical database?
Define the workload write pattern, consistency requirement, approved RTO and RPO, and regional failure model. Compare synchronous and asynchronous options, replication lag, read routing, failover trigger, fencing, endpoint changes, backup independence, encryption keys, failback, conflict handling, and verification that only the intended primary accepts writes.
I would first define the write pattern, consistency, RTO, RPO, and regional failure model. I would usually keep one writable primary, replicate cross-region, monitor lag, fence the old primary before promotion, redirect clients safely, maintain independent backups, and regularly test failover and failback.
A critical database must keep serving the business even if an entire location becomes unavailable. The first decision is how quickly another location must take over and how much recent information the business can afford to lose. I would learn where changes are made, how quickly users must see them, and what should happen if the locations cannot communicate. Then I would design a safe standby location, keep separate recovery copies, control which location may accept changes, and test switching over and switching back. The main goal is safe recovery without creating two competing copies of the truth.
- Is the application normally writing in one region, or must multiple regions accept writes at the same time?
- What are the approved RTO and RPO? How long may recovery take, and how much recent committed data may be lost?
- What consistency does the application require after a write? Must every read immediately see the newest committed value?
- Is the failure model a database-instance failure, an availability-zone failure, a complete regional outage, or a network partition between regions?
- What normal write latency is acceptable?
- May the surviving region continue accepting writes when connectivity to the original primary region is uncertain?
- Are there data-residency, retention, or compliance restrictions on where replicas and backups may exist?
- How should applications discover the active writer: a stable database endpoint, proxy, service discovery, or configuration change?
- How much replication lag is acceptable before failover must be blocked or require human approval?
- Does the selected database support multi-primary writes, and if so, what conflict-resolution guarantees does it provide?
I would not choose a replication topology until I know the business requirements.
RTO, or Recovery Time Objective, is the maximum acceptable time to restore service after a failure. RPO, or Recovery Point Objective, is the maximum acceptable amount of recent committed data that may be unavailable or lost after recovery.
I would also define the workload's write pattern, read pattern, required consistency, acceptable latency, throughput, durability, availability, data-residency requirements, retention requirements, encryption requirements, and expected cost limits where those affect the design.
A single-primary design has one region authorized to accept writes. Other regions normally contain replicas. A multi-primary design allows writes in multiple regions and therefore requires explicit rules for concurrent updates and conflicts.
With synchronous replication, a write is acknowledged only after the database has met its configured remote replication or quorum requirement. This can provide stronger protection for acknowledged writes, but the exact RPO depends on the database's documented commit, quorum, and failure guarantees. Cross-region network latency becomes part of the write path, and some failures or network partitions can reduce write availability.
With asynchronous replication, the primary can acknowledge a write before the remote region has received it. This usually gives lower write latency and keeps normal writes less dependent on a distant region, but the remote replica can lag behind. That delay is replication lag. If the primary region is lost before recent committed changes reach the replica, those changes may not be available after failover.
For many mission-critical systems, a practical design is synchronous high availability within the primary region when supported, combined with asynchronous replication to a geographically separate disaster-recovery region. I would choose synchronous cross-region replication only when the required RPO justifies its latency and availability tradeoffs and the selected database supports the required guarantees.
My default design is one writable primary region and one or more remote replicas that do not accept normal application writes.
This makes ownership clear and greatly reduces conflict risk. The application should know which endpoint is writable rather than attempting writes against arbitrary replicas.
For reads, I would route traffic according to the consistency requirement. Read-only or stale-tolerant workloads may use regional replicas. Reads that must observe a just-completed write should use a database path that provides the required read-after-write or strong-consistency behavior instead of blindly reading from an asynchronous replica.
If multiple regions genuinely must accept writes, I would select a database whose supported replication model provides that capability. I would explicitly define how concurrent changes to the same logical data are detected and resolved. Conflict behavior must match business semantics; I would not assume that last-writer-wins is safe for every workload.
I would continuously monitor replication lag, replication errors, replica availability, storage capacity, throughput, failed replication operations, and the freshness of the last replicated transaction or checkpoint when the database exposes that information.
A replica being online does not prove it is ready for promotion. Before failover, I need to know whether its data state satisfies the approved RPO.
If replication lag exceeds the recovery policy, the system should alert. Automatic promotion may need to stop and require human approval if promoting that replica could violate the approved RPO.
A local synchronous replica can improve availability for instance or availability-zone failures, but that is different from surviving a complete regional failure.
Cross-region replication is also not a backup. Accidental deletion, a bad application update, malicious changes, or logical corruption can be replicated to the standby region.
I would therefore maintain independent backups or snapshots and point-in-time recovery when the database supports them. Backup retention and location should satisfy recovery, residency, and compliance requirements. I would test restoration regularly because a backup is only useful if it can actually be restored within the required recovery window.
I would not promote another region because of one failed health check.
A regional failover decision should use multiple signals, such as database health, application connectivity, control-plane health, regional infrastructure status, and how long the failure has persisted.
The system must distinguish a real regional outage from an inter-region network partition. During a partition, the original primary might still be healthy and accepting writes locally. Promoting another writable primary without controlling the first one can create split brain.
Depending on the business risk, failover can be automatic, manually approved, or partly automated with a human decision before promotion.
Fencing means preventing the previous primary from accepting application writes before or as another region becomes authoritative.
This is one of the most important safety controls in the design. Without fencing, a network partition can leave two regions accepting writes independently. Those histories may later conflict or be impossible to merge correctly.
The exact fencing mechanism depends on the database and platform. It may use database role transitions, leases, quorum ownership, write-access revocation, application access controls, network controls, or another mechanism supported by the architecture.
The required outcome is unambiguous: only the intended primary is permitted to accept writes.
After the failover conditions are satisfied and write ownership is safe, I would promote the selected replica using the database's supported process.
Applications should reach the active writer through a controlled mechanism such as a stable database endpoint, proxy, service-discovery record, or managed connection endpoint. I would avoid hard-coding a specific regional database address throughout application code.
Endpoint changes alone are not enough. Existing application connection pools can contain stale connections to the former primary. Applications should use bounded connection and request timeouts, remove failed or stale connections, and reconnect to the current writer.
Retries also need care. A client may not know whether a write succeeded before the connection failed. Write operations should therefore be idempotent where possible, or use transaction identifiers, uniqueness rules, or another database-supported mechanism to prevent duplicate business effects.
Replication traffic should be protected in transit, and database data and backups should be encrypted at rest according to organizational requirements.
The disaster-recovery region must also be able to use the required key-management infrastructure, identities, certificates, secrets, and authorization policies while the original region is unavailable. I would verify that the recovery path does not secretly depend on a regional key, identity service configuration, secret, certificate, or administrative process that disappears with the failed region.
Encryption does not replace authorization. The promoted database should still use least-privilege permissions for applications, administrators, backup processes, and replication identities.
Failback is not simply changing the endpoint back to the recovered region.
When the original region returns, its database may be stale. I would keep it fenced from application writes and rebuild or resynchronize it from the current authoritative primary using a database-supported process.
After replication becomes healthy and the data is verified, I can consider moving write ownership back. That transition should use the same safeguards as failover: verify health and lag, fence the current writer at the appropriate point, perform a controlled switchover or promotion, change routing, refresh application connections, and validate the resulting topology.
With a correctly fenced single-primary architecture, normal failover avoids concurrent-write conflicts because only one region owns writes at a time.
In a multi-primary architecture, or in a design that intentionally lets isolated regions continue writing during a network partition, conflicts are part of normal operation. The database and application must have explicit semantics for concurrent changes.
Possible mechanisms include optimistic concurrency using versions, conditional writes, database-provided conflict resolution, application-level reconciliation, or another technique appropriate to the selected data model. I would choose the rule according to business meaning instead of assuming that one generic conflict policy works for all records.
After promotion, I would verify more than simple endpoint reachability.
I would confirm that the new primary accepts writes, the previous primary cannot accept writes, application reads return the expected data, transactions work correctly, connection pools have moved to the new writer, replication state is understood, authorization and encryption work, backups continue, and monitoring reflects the new topology.
A useful explicit safety test is to attempt a controlled write through every path that could reach a database writer and verify that only the intended primary can commit it.
I would run planned regional-failure exercises rather than relying only on documentation.
The tests should measure actual RTO, observed data loss against RPO, replication lag before promotion, fencing effectiveness, endpoint or service-discovery changes, application reconnection behavior, retry safety, backup restoration, security dependencies, and the complete failback process.
The main design principle is safe ownership of writes. Fast failover is useful only when the system also prevents split brain, respects the approved RPO, preserves independent recovery options, and can prove which database is authoritative.
- Define the workload read and write patterns, consistency requirement, acceptable write latency, throughput, durability, availability, residency, retention, encryption, RTO, RPO, and cost constraints that affect the design.
- Define the regional failure model, including complete regional outage and inter-region network partition scenarios.
- Prefer one authoritative write region unless simultaneous multi-region writes are a real business requirement.
- Compare synchronous and asynchronous cross-region replication against the required RPO, write latency, and availability tradeoffs.
- Deploy the remote replica or replicas using the database's supported replication mechanism.
- Define read routing so stale-tolerant reads may use replicas while consistency-sensitive reads use a path that meets their consistency requirement.
- Continuously monitor replication lag, replication health, replica availability, and data freshness.
- Maintain independent backups and point-in-time recovery when supported, and test restoration separately from replication failover.
- Ensure encryption keys, identities, certificates, secrets, authorization policies, and backup access remain usable during a regional outage.
- Define failover signals and specify when automation must stop for human approval.
- Verify the selected replica satisfies the approved RPO before promotion when the database exposes enough information to make that determination.
- Fence the former primary so it cannot accept writes when the replacement region becomes authoritative.
- Promote the selected replica using the database's supported role-change procedure.
- Update the application-facing endpoint, proxy, or service-discovery mechanism and force stale connection pools to reconnect.
- Make retries safe by using idempotency, transaction identifiers, uniqueness constraints, conditional writes, or another appropriate mechanism.
- Verify that only the intended primary accepts writes and validate reads, writes, transactions, authorization, encryption, monitoring, and backups.
- When the old region returns, keep it fenced until it is rebuilt or resynchronized from the current authoritative primary.
- Perform controlled failback only after synchronization and verification are complete.
- Regularly exercise the entire process and compare measured recovery time and data loss with the approved RTO and RPO.
The important costs here are operational, latency, storage, and network costs rather than algorithmic time complexity. Cross-region replication requires another copy of the data and usually consumes inter-region network bandwidth. Synchronous cross-region replication puts distant network delay into the write path and may reduce write availability during communication failures, depending on the database's quorum and commit rules. Asynchronous replication usually keeps normal writes faster but allows replication lag, so the newest committed changes may be unavailable after a sudden primary-region loss. Read replicas can add read capacity but create consistency concerns when they lag. Independent backups add storage, retention, and restore-testing costs, but they remain necessary because replicas can copy logical errors and destructive changes. Multi-primary systems usually have the highest operational complexity because they require conflict handling, stronger testing, and more complicated recovery procedures. Ongoing costs also include monitoring, failover drills, endpoint management, security controls, backup verification, and failback testing.
This design is used for databases supporting services that must survive a complete regional outage, such as customer-facing transaction systems, account and identity platforms, order-processing services, business-critical SaaS products, payment-related workflows, and important internal platforms. A single-primary cross-region design is especially appropriate when data correctness and clear write ownership are more important than accepting writes independently in every region. Multi-primary replication is appropriate only when the workload genuinely requires regional write locality or simultaneous regional writes and the selected database and application have well-defined conflict semantics.
This question tests whether the candidate can design database disaster recovery rather than simply enable replication. The interviewer wants to see judgment around write ownership, consistency, replication lag, RTO and RPO, regional failure modes, failover safety, split-brain prevention, read routing, endpoint changes, backups, encryption, conflict handling, failback, and recovery verification. A strong answer distinguishes replication from backup and explains how application behavior, database behavior, and control-plane actions work together during a regional outage.
Common mistakes include enabling replication before defining RTO and RPO; assuming asynchronous replication provides zero data loss; assuming synchronous replication always guarantees zero data loss without checking the database's exact commit and failure guarantees; choosing synchronous cross-region replication without considering write latency and partition behavior; allowing both regions to accept writes accidentally; promoting a replica without fencing the old primary; failing over because of a single health check; promoting a replica whose lag violates the approved RPO; routing consistency-sensitive reads to lagging replicas; treating replication as a backup; forgetting independent point-in-time recovery or restore testing; keeping encryption keys, identities, certificates, or secrets dependent on the failed region; changing an endpoint without handling stale connection pools; retrying writes in a way that can create duplicate business effects; applying a generic last-writer-wins conflict policy without checking business semantics; and having a failover plan without a safe resynchronization and failback procedure.
Lead with the write pattern, consistency requirement, RTO, RPO, and failure model instead of naming a product. Then compare synchronous and asynchronous replication and walk through failover in order: detect, check replica freshness, fence, promote, redirect clients, reconnect safely, and verify write ownership. Explicitly state that replication does not replace backups and that both failover and failback must be tested.




