Designing Multi-Region Active-Active APIs
The practical trade-offs behind active-active APIs, including routing, idempotency, data ownership, replication lag, and conflict resolution.
The Problem
Active-active sounds like a simple reliability upgrade: run the service in two regions and route users to the closest one. The hard part is writes.
Why It Matters
Multi-region systems add cost, replication delay, operational complexity, and conflict handling. They are justified for latency, regulation, or resilience requirements, not as a default starting architecture.
Core Concepts
There are three common models. Single-writer keeps writes in one region. Partitioned ownership assigns each tenant or user to a home region. True active-active accepts writes in multiple regions and resolves conflicts.
Implementation
Prefer partitioned ownership when possible:
tenant_id -> home_region
reads -> nearest healthy replica
writes -> tenant home region
failover -> promote backup region for affected tenants
For true active-active, every write needs a conflict strategy: last-write-wins, merge, version vector, operational transform, or manual review.
Real Project Scenario
A notes product can merge edits from two regions because conflicts are visible and recoverable. An inventory system cannot safely use last-write-wins because two regions may sell the same item. A banking ledger should usually avoid active-active conflicting writes entirely and route each account to a single writer.
Production Setup
Define the consistency model per business object. User profile updates, shopping carts, ledgers, audit logs, and inventory do not need the same conflict rule. Add metrics for replication lag, conflict count, reconciliation failures, and regional write routing.
Common Mistakes
- Calling the system active-active while all writes still depend on one database.
- Ignoring idempotency across regions.
- Using wall-clock timestamps for financial or inventory conflict resolution.
- Forgetting that failback is harder than failover.
Production Considerations
Write regional runbooks. Test region evacuation, DNS changes, queue draining, replication catchup, and reconciliation. Track conflict counts as a first-class metric.
Security
Regional data rules matter. A failover plan that moves regulated data to the wrong region can violate compliance even if the service stays online.
Performance
Local reads are easy. Local writes are the expensive part. Be explicit about which requests need strong consistency and which can tolerate replication delay.
Summary
Active-active APIs are a data design problem first and an infrastructure problem second. Start with ownership, consistency, and conflict rules before buying more regions.
The weekly engineering digest
Production-grade engineering writing in your inbox. No spam, unsubscribe anytime.