Working with Geo-Distribution
1. Understanding Multi-Region Architectures
| Pattern | Detail |
|---|---|
| Active-Passive | One write region; failover to standby |
| Active-Active | All regions accept writes; conflict resolution |
| Region pinning | User pinned to home region |
| Follow-the-sun | Active region rotates with traffic |
2. Implementing Geographic Replication
| Tech | Mode |
|---|---|
| Postgres logical / physical | Async streaming |
| MySQL GTID | Async, semi-sync |
| Kafka MirrorMaker 2 | Cross-cluster topic mirror |
| DynamoDB Global Tables | Multi-master, last-writer-wins |
| Spanner / CockroachDB / YugabyteDB | Synchronous global consistency |
3. Implementing Read Replicas Across Regions
| Property | Detail |
|---|---|
| Pro | Local reads, low latency |
| Con | Replication lag → stale reads |
| Read-your-writes | Sticky to primary or session token |
| Lag monitoring | Alert if > threshold |
4. Understanding Latency-Based Routing
| Tool | Detail |
|---|---|
| Route 53 latency policy | Pick lowest RTT region |
| Cloudflare Argo | Smart routing |
| Anycast | Same IP advertised globally; BGP picks closest |
| GeoDNS | Country/region-based |
5. Implementing Global Load Balancing
| Layer | Tool |
|---|---|
| DNS | Route 53, NS1, Cloudflare |
| Anycast L4 | GCP GLB, AWS Global Accelerator |
| L7 proxy | Cloudflare, Fastly |
| Health-aware | Drain unhealthy region |
6. Implementing Data Residency Compliance
| Requirement | Mechanism |
|---|---|
| GDPR (EU) | Store EU user data in EU regions |
| Data sovereignty | Per-country DBs (e.g., China, Russia) |
| Tag at ingest | Region label per record; enforce at write |
| Encryption + KMS | Keys stay in jurisdiction |
7. Handling Cross-Region Failover
| Step | Detail |
|---|---|
| Detect | Health checks fail in primary |
| Promote replica | Replica becomes new primary |
| Update DNS / GLB | Steer traffic |
| Reconcile | Old primary recovers as replica |
| Risk | Split-brain; STONITH needed |
8. Understanding Consistency Across Regions
| Model | Cost |
|---|---|
| Synchronous (Spanner) | +RTT per write; strong |
| Async | Fast; eventual / read-stale |
| CRDT | Mergeable, conflict-free; weaker semantics |
| Single-region writes | Lowest complexity; HA via failover |
9. Implementing CDN for Global Delivery
| Provider | Notes |
|---|---|
| Cloudflare | Edge + workers |
| CloudFront | AWS-native |
| Fastly | VCL, instant purge |
| Akamai | Largest footprint |
| Strategy | Long-TTL static; short-TTL HTML; signed URLs |
10. Implementing Edge Computing Patterns
| Platform | Detail |
|---|---|
| Cloudflare Workers | V8 isolates, sub-ms cold start |
| Fastly Compute@Edge | WASM |
| AWS Lambda@Edge / CloudFront Functions | Per-request mutate |
| Use cases | A/B routing, auth, personalization, image resize |