Multi-Region and Geo-Distributed Systems Questions
Running a system across regions and continents: multi-region replication, data residency and sovereignty, geo-routing, cross-region consistency, and conflict resolution during failover. Covers the latency, cost, and consistency tradeoffs of going global and how to keep regional failures isolated. Global distribution strategy at the service layer.
List the key metrics and alerts you would implement to monitor multi-region system health: include replication lag, cross-region RTT, leader-election events, error rates by region, and region-level capacity. Also outline which remediation steps should be automated versus human-in-the-loop.
Sample Answer
High-level goal: ensure cross-region availability, data consistency, performance and capacity while minimizing blast radius. I’d implement these metrics/alerts and map remediation to automated vs human-in-the-loop.
Key metrics (per region + global):
- Replication lag (ms/seconds; 95/99th percentiles, and max) — track per-replica and per-shard
- Cross-region RTT (p50/p95/p99) between region pairs and to global edge
- Leader-election events (count, rate, duration, cause tags)
- Error rates by region (5xx/4xx rate, per-service, per-endpoint)
- Region-level capacity (CPU, memory, disk IOPS, connection/socket counts, thread pools)
- Throughput and queue depth (requests/s, inflight requests, backlog)
- SLO indicators: request latency SLO compliance, availability per region
- Topology health: replica counts, quorum status, partition skew
Alerting rules + thresholds:
- Replication lag: warn at sustained >500ms p95; critical at >5s or >SLA window; include rate-of-change alerts
- RTT: warn when p95 > baseline*2; critical if packet loss >1% or p99 > SLA
- Leader-election: alert on >N events/min or long leaderless periods
- Error rate: warn at 2x baseline; critical at absolute >1% of requests or >SLO breach window
- Capacity: warn at 70-80% utilization; critical at 90%+ or when resource exhaustion errors appear
- Quorum loss / replica down: immediate critical
- SLO burn rate: high burn-rate alerts (e.g., 4x) for rapid escalation
Alert context and enrichment:
- Attach recent logs, traces, topology map, runbook link, recent deploys, and recent config changes
- Correlate cross-metrics (e.g., spike in RTT plus replication lag) in alert payload
Automated remediation (fast, deterministic, reversible):
- Circuit-breakers / rate-limiting when per-region error rates spike
- Read-only failover to healthy replicas if replication lag within acceptable window
- Automated leader re-election retries with backoff if single transient failure
- Auto-scale stateless services (add/remove instances) based on CPU, RPS, and queue depth
- Traffic steering: shift % of traffic away from degraded region via global load balancer / DNS with health checks and gradual rollout
- Restart unhealthy worker processes when ephemeral health checks fail a configured number of times
Human-in-the-loop (require investigation/approval):
- Full region failover (promote new master) if replication lag > critical threshold or quorum loss — require manual confirmation
- Data repair / conflict resolution after split-brain or long-lag scenarios
- Capacity provisioning for stateful storage (add shards, change replication factor)
- Schema migrations, major configuration changes, or change of topology
- Post-incident RCA and runbook updates
Runbook and playbooks:
- For each critical alert include: impact, likely causes, quick checks, rollback steps, automated actions taken, escalation path, runbook link, and expected MTTR.
Trade-offs:
- Balance automation aggressiveness to avoid cascading failovers; prefer staged automated actions (warning -> partial traffic shift -> full shift) and require confirmation for destructive operations. Use canaries and gradual traffic steering.
This provides observability, fast containment through automation, and safe human oversight for high-risk operations.
Estimate bandwidth and peering requirements for a global streaming service with 10M concurrent viewers evenly distributed across regions and three profiles (1.5Mbps, 4Mbps, 8Mbps). Propose peering/CDN strategy, origin placement, and approaches to control inter-region egress costs while maintaining quality.
Sample Answer
Requirements & assumptions (clarify): 10M concurrent viewers globally, evenly across regions (assume 10 regions → 1M concurrent/region). Profiles distribution: assume mix A=50%@1.5Mbps, B=35%@4Mbps, C=15%@8Mbps (adjustable). Use bits/sec.
- Bandwidth estimation:
- Per-user average bitrate = 0.51.5 + 0.354 + 0.15*8 = 0.75 + 1.4 + 1.2 = 3.35 Mbps
- Total global egress = 10,000,000 * 3.35 Mbps = 33,500,000 Mbps ≈ 33,500 Gbps ≈ 33.5 Tbps
- Per-region egress (even): 1,000,000 * 3.35 = 3,350 Gbps ≈ 3.35 Tbps
Add overheads: +10% for TLS, manifest/ads/splicing → global ≈ 36.85 Tbps.
- Peering / CDN strategy:
- Primary delivery via multi-CDN strategy (2–3 CDN partners plus own edge POPs in major markets) to avoid single-vendor risk and optimize cost/latency.
- Use CDN PoP footprint close to ISPs; negotiate private peering (PIP/Direct Connect) with top ISPs in high-volume regions to reduce transit fees and latency.
- Active steering: use RTT/bandwidth-aware routing and edge health signals to select CDN per request.
- Origin placement:
- Multi-region origin topology: regional origin clusters placed in 3–5 strategic regions (e.g., NA, EU, APAC, LATAM, MENA). Use origin-pull + regional replication of chunks via object storage (S3-compatible) and origin caches.
- Use geo-replication of manifest and key CDN caches; only cold-misses hit origin.
- Control inter-region egress & cost:
- Favor intra-CDN regional delivery; keep content replicated close to viewers to minimize cross-region origin pulls.
- Use origin-authenticated multi-tenant caching and long-lived cache-control for VOD; chunk-level dedup and CDN-stored edge caches.
- Implement origin shielding (a regional cache layer) to reduce multi-pop origin traffic.
- Intelligent encoding: ABR ladder optimization per region (lower avg bitrate where bandwidth constrained), use per-title/per-device encoding to reduce average bitrate while maintaining QoE.
- Use CDN cost-aware routing: failover to lower-cost CDN when performance within SLA.
- Employ peering + paid-peering mix: private peering for top-ISPs carrying ~70–80% traffic; transit for tail ISPs.
- Operational considerations & KPIs:
- Plan capacity headroom 20–30% for flash events → design for ~45 Tbps global peak.
- Monitor: 95th-percentile egress per region, cache hit ratio, origin request rate, startup latency, rebuffering rate.
- Trade-offs: More replication reduces egress but increases storage/replication cost; private peering reduces egress cost but requires capital + negotiation.
Summary: design for ~36–45 Tbps with regional origins + multi-CDN + private peering to major ISPs, aggressive edge caching, optimized ABR ladders, and routing policies that balance cost and QoE. Adjust estimates with real profile mix and regional viewer distribution.
Design a multi-region, active-active architecture for a customer-facing microservice that must serve 10,000 RPS globally with p95 read latency under 150ms and eventual consistency for user profile updates. Describe components (edge, regional clusters, global load balancing), data replication strategy, conflict resolution approach, read vs write routing, failover behavior, and the impact on developer workflows, testing, and deployment.
Sample Answer
Requirements:
- 10,000 RPS global, p95 read <150ms, eventual consistency for profile updates, active-active multi-region.
High-level architecture:
- Global DNS + anycasted edge (Cloud CDN/WAF) → Global LB (Route 53/GCP Cloud DNS + Traffic Director) → Regional clusters in 3+ regions (K8s/EKS/GKE) running service instances + read replicas of DB → Regional caches (Redis/ElastiCache or local CDN) → Persistent storage per region (replicated DB).
Components and responsibilities:
- Edge: CDN + WAF for TLS termination, DDoS, caching static/profile image assets.
- Global load balancer: Geo-routing + latency-based traffic distribution, health-aware.
- Regional clusters: API pods, local cache, read-replicas, worker queues for async replication.
- Data stores: Primary-per-region pattern using a distributed datastore optimized for multi-master (e.g., Cassandra, DynamoDB Global Tables) or single writable leader per region with async replication.
- Message backbone: Kafka or durable queue for cross-region change propagation.
Data replication strategy:
- Use multi-master replication with per-record last-writer-wins (LW V) plus causal metadata (vector clocks or logical timestamps) OR DynamoDB Global Tables with conditional writes.
- Writes are accepted in any region and appended to an immutable change log; change events are asynchronously propagated to other regions via CDC/Kafka with at-least-once delivery.
Conflict resolution:
- Deterministic automatic resolution: application-level merge where possible (merge profile fields by last-update-per-field with timestamps and source priority), plus user-level version numbers to prevent lost updates.
- For high-risk fields, use optimistic concurrency (compare-and-swap) with client-visible version conflict errors surfaced to clients for manual resolution.
- Maintain an audit/compensation queue to reconcile anomalies and allow manual review.
Read vs write routing:
- Read: Serve from local region’s cache/read-replica for sub-150ms p95. Cache TTL tuned per field; strongly-consistent reads available optionally by routing to the origin region/service.
- Write: Accept locally, enqueue change events, apply locally (fast), replicate asynchronously. For critical writes that require stronger guarantees, route to a single-writer region or use synchronous conditional writes with higher latency.
Failover behavior:
- Regional failure: Global LB reroutes traffic away from unhealthy region; other regions absorb traffic via autoscaling. Replication log ensures eventual convergence when region returns.
- Partial outages: degrade to reading from next-closest region; flag increased latency SLA. For split-brain risk, rely on deterministic conflict resolution and monotonically-increasing logical timestamps to avoid loss.
- Disaster recovery: periodic backups, cross-region snapshots, and ability to promote a region for heavy write load.
Impact on developer workflows, testing, deployment:
- CI/CD: Region-aware deployments, progressive (canary) rollouts by region, automated chaos testing.
- Testing: Integration tests for replication (fault injection, network partitions), contract tests for conflict resolution logic, load tests at global scale, and synthetic latency tests to validate p95 SLAs.
- Observability: Distributed tracing, per-region metrics, replication lag dashboards, conflict-rate alerts.
- Developer patterns: Idempotent writes, include version metadata, prefer field-level updates, and expose optional read-after-write strong read APIs for clients that need it.
- Operational playbooks: Clear runbooks for failover, reconciliation scripts, and SLA-driven scaling policies.
Trade-offs:
- Eventual consistency enables low-latency local writes but requires careful conflict handling and increases testing complexity.
- Multi-master reduces cross-region write latency but increases complexity vs single-writer with synchronous replication.
This design meets 10k RPS by scaling regional clusters and caches, keeps p95 reads <150ms through local caching/replicas, and provides clear replication and conflict-resolution strategies suitable for a customer-facing profile service.
Design an automated cross-region failover orchestration for a stateful service that must meet RTO = 2 minutes and RPO = 5 seconds. Explain detection methods, safety gates, how data consistency is guaranteed during failover, the orchestration steps and rollback strategies, and how to test the system.
Sample Answer
Requirements (clarify): RTO ≤ 2 minutes, RPO ≤ 5s, cross-region, stateful service (strong consistency needed), automated orchestration with safety gates, rollback, auditable logs.
Detection
- Multi-layer detection: (1) Local health probes (liveness/readiness), (2) Distributed heartbeats to monitoring cluster, (3) Data-plane checks: quorum read/write latency and last-committed LSN/Timestamp, (4) Synthetic transactions validating end-to-end requests.
- Escalation logic: transient failures filtered by short backoff + majority of detectors before triggering failover.
Safety gates (pre-failover checks)
- Verify primary unreachable by ≥2 independent networks and control-plane signals.
- Confirm secondary candidate's replication lag ≤ RPO (<=5s) and WAL/OPLOG applied.
- Ensure no split-brain: write-lease or leader epoch token on primary expired and not reachable.
- Quiesce incoming writes via global traffic-control (feature-flag + DNS/anycast + edge routing) only after checks pass.
Data consistency guarantees
- Use synchronous or semi-sync replication with durable commit acknowledgments; for geo latency trade-off use async with durable logs + 5s bounded replication.
- Maintain monotonic leader epoch and a globally stored leader token (distributed consensus like etcd/RAFT or cloud-managed locking) to prevent dual-writes.
- Preserve durable commit position (LSN/Timestamp) as single source of truth; apply cutover only when secondary’s applied LSN ≥ primary’s last durable commit.
Orchestration steps (automated)
- Detect — aggregate detectors and validate safety gates.
- Freeze writes — place global routing into read-only/queue mode; accept in-flight drains (max drain window << RTO).
- Validate target — pick healthiest secondary with appliedLSN ≥ cutoverLSN and sufficient capacity.
- Promote — acquire leader token via consensus; promote node to primary, enable write path.
- Reconfigure DNS/load-balancer/edge routes with short TTL and health-aware routing; rotate certificates/roles.
- Warm services — run smoke tests (synthetic write/read) and monitor metrics for 30s.
- Cut traffic gradually (canary then 100%) — complete within RTO.
- Post-cutover reconciliation — replicate missing transactions (if any), create incident ticket and snapshot.
Rollback strategies
- Automatic rollback window: if promoted primary fails pre-defined health checks within 30–60s, revoke leader token and revert traffic to previous standby if still valid.
- If original primary resurfaces with conflicting writes, block auto-merge; require manual reconciliation using preserved WAL segments, point-in-time-restore, or application-level conflict resolution.
- Maintain immutable backups and snapshots for safe manual rollback.
Testing
- Chaos testing: simulated region outage, network partitions, control-plane failures.
- Failure injection: delayed replication, increased latency, storage failures, leader token loss.
- DR runbooks automated in staging: full failover rehearsals with RTO/RPO measurement (measure time to detection, promotion, and resume writes; verify last commit ≤5s).
- Automated recovery drills monthly + production “Game Day” with stakeholders. Validate observability: logs, audit trail, and SLIs/SLOs.
Trade-offs and notes
- Achieving 5s RPO cross-region often requires semi-sync or tuned replication; balance latency vs durability.
- Governance: require automated runbooks plus manual override for conflict-heavy scenarios.
This design provides deterministic cutover, enforces safety gates to avoid split-brain, guarantees RPO via replication checks, meets RTO with pre-warmed secondaries and automated routing, and includes clear rollback and testing plans.
Design a federated identity service: each region manages local users but the system must support global lookup within 500ms and respect data residency rules. Discuss global identifiers, regional ownership, replication scope, aggregation APIs, conflict resolution for duplicate accounts, and privacy controls.
Sample Answer
Requirements & constraints:
- Local user management per region (data residency), global lookup ≤500ms, strong privacy/compliance, handle duplicate accounts and conflicts, support auditability.
High-level architecture:
- Regions own canonical local user stores (regionally hosted DBs). A global read-index (distributed, geo-replicated) provides sub-500ms lookups.
- Use a stable, opaque Global User ID (GUID) generated at first authoritative creation; GUID maps to one or more regional principals.
Key components:
- Regional Identity Service: CRUD, local policies, verifies residency; emits change events (CDC).
- Change Stream & Replicator: Filters fields allowed to replicate (data residency policy), applies transformation/pseudonymization, forwards to global index.
- Global Read Index (search + cache): Sharded, read-optimized (Elasticsearch or Cockroach/Spanner read replicas + CDN cache) for <500ms global lookup.
- Aggregation API: Accepts queries (email/phone/name) and returns aggregated view of matched principals with provenance and confidence scores.
- Conflict Resolver / Linker: Rules-based + ML deduplication that proposes merges or links; human-in-the-loop for high-risk merges.
- Policy Engine & Masking Service: Enforces per-region residency, masking, consent, and legal hold.
Global identifiers & ownership:
- GUID assigned by region of origin; GUID persists. Regional principal IDs remain authoritative for local data.
- Mapping table in global index: GUID -> list of region principals (with source region, last-updated, replication-scope flags).
Replication scope:
- Default: non-sensitive metadata (display name, GUID, username) replicates globally.
- Sensitive attributes (PII, address, SSN) either remain in-region with pointers, or replicate only if explicit consent/contract allows; when replicated, store only hashed/pseudonymized derivatives for lookup.
Aggregation APIs:
- Query by identifier or attributes returns:
- Matched GUIDs with provenance, confidence, and allowed attribute subset per requester's authorization.
- Option to fetch full regional profile by calling regional service (authorized, logged).
Conflict resolution for duplicates:
- Multi-stage: deterministic matching (same email/phone), probabilistic scoring (ML), business rules (same org). If score > high threshold -> auto-link; between thresholds -> create linked-aliases and surface to admin workflow; < low -> separate.
- Merges are append-only operations with reversible linkage tokens; audit trail stored in immutable log.
Privacy & compliance:
- Policy-first replication: replication policies per region + per-attribute tags.
- Consent and legal hold honored: Policy engine blocks replication or un-masks only upon valid authorization.
- Encryption-at-rest and in-transit; tokenized or hashed PII in global index; RBAC + attribute-based access control for API.
- Regular audits, data subject access APIs, and region-specific deletion workflows (coordinate purge across index and regional stores).
Scalability & latency:
- Global index in multiple read-regions, edge caches, and smart routing to nearest replica; use async replication with near-real-time CDC and eventual consistency for non-critical fields; critical lookups served from global index to meet 500ms SLA.
- Trade-offs: stricter residency reduces searchable attributes and increases remote calls to region (higher latency). Balance by pre-computing hashed lookup keys and selective replication.
Operational considerations:
- Monitoring for replication lag, false-match rates, and privacy breaches.
- SRE runbooks for split-brain/link conflicts; legal/compliance workflows.
This design provides sub-500ms global lookup for permitted attributes while keeping authoritative data regional, respecting residency and offering robust conflict resolution and privacy controls.
Unlock Full Question Bank
Get access to all Multi-Region and Geo-Distributed Systems interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.