Working with Geo-Distribution

1. Understanding Multi-Region Architectures

PatternDetail
Active-PassiveOne write region; failover to standby
Active-ActiveAll regions accept writes; conflict resolution
Region pinningUser pinned to home region
Follow-the-sunActive region rotates with traffic

2. Implementing Geographic Replication

TechMode
Postgres logical / physicalAsync streaming
MySQL GTIDAsync, semi-sync
Kafka MirrorMaker 2Cross-cluster topic mirror
DynamoDB Global TablesMulti-master, last-writer-wins
Spanner / CockroachDB / YugabyteDBSynchronous global consistency

3. Implementing Read Replicas Across Regions

PropertyDetail
ProLocal reads, low latency
ConReplication lag → stale reads
Read-your-writesSticky to primary or session token
Lag monitoringAlert if > threshold

4. Understanding Latency-Based Routing

ToolDetail
Route 53 latency policyPick lowest RTT region
Cloudflare ArgoSmart routing
AnycastSame IP advertised globally; BGP picks closest
GeoDNSCountry/region-based

5. Implementing Global Load Balancing

LayerTool
DNSRoute 53, NS1, Cloudflare
Anycast L4GCP GLB, AWS Global Accelerator
L7 proxyCloudflare, Fastly
Health-awareDrain unhealthy region

6. Implementing Data Residency Compliance

RequirementMechanism
GDPR (EU)Store EU user data in EU regions
Data sovereigntyPer-country DBs (e.g., China, Russia)
Tag at ingestRegion label per record; enforce at write
Encryption + KMSKeys stay in jurisdiction

7. Handling Cross-Region Failover

StepDetail
DetectHealth checks fail in primary
Promote replicaReplica becomes new primary
Update DNS / GLBSteer traffic
ReconcileOld primary recovers as replica
RiskSplit-brain; STONITH needed

8. Understanding Consistency Across Regions

ModelCost
Synchronous (Spanner)+RTT per write; strong
AsyncFast; eventual / read-stale
CRDTMergeable, conflict-free; weaker semantics
Single-region writesLowest complexity; HA via failover

9. Implementing CDN for Global Delivery

ProviderNotes
CloudflareEdge + workers
CloudFrontAWS-native
FastlyVCL, instant purge
AkamaiLargest footprint
StrategyLong-TTL static; short-TTL HTML; signed URLs

10. Implementing Edge Computing Patterns

PlatformDetail
Cloudflare WorkersV8 isolates, sub-ms cold start
Fastly Compute@EdgeWASM
AWS Lambda@Edge / CloudFront FunctionsPer-request mutate
Use casesA/B routing, auth, personalization, image resize