Multi-Regional Deployment of a Web Application
Multi-regional deployment reduces latency for users in different geographic zones, ensures failover for regional outages, and can be required by data localization rules (GDPR, 152-FZ).
Architectural Patterns
Active-Passive — one region is primary, second gets traffic only on failure. Simple, but failover not instant (15–60 seconds).
Active-Active — both regions take traffic simultaneously. More complex: need data sync, write conflict resolution.
Read Replicas — writes only in primary region, reads from nearest. Suits most read-heavy web apps.
AWS Multi-Region with Route 53
# Terraform: two EKS clusters
module "eks_eu" {
source = "terraform-aws-modules/eks/aws"
region = "eu-west-1"
cluster_name = "myapp-eu"
cluster_version = "1.29"
vpc_id = module.vpc_eu.vpc_id
subnet_ids = module.vpc_eu.private_subnets
managed_node_groups = {
main = {
instance_types = ["m6i.xlarge"]
min_size = 2
max_size = 10
desired_size = 3
}
}
}
module "eks_us" {
source = "terraform-aws-modules/eks/aws"
region = "us-east-1"
# similarly
}
# Route 53: Latency-based routing
resource "aws_route53_record" "api" {
zone_id = var.hosted_zone_id
name = "api.mysite.com"
type = "A"
set_identifier = "eu-west-1"
latency_routing_policy {
region = "eu-west-1"
}
alias {
name = aws_lb.eu.dns_name
zone_id = aws_lb.eu.zone_id
evaluate_target_health = true
}
}
Database: Replication Between Regions
PostgreSQL with logical replication:
-- PRIMARY (eu-west-1)
CREATE PUBLICATION myapp_pub FOR ALL TABLES;
-- REPLICA (us-east-1)
CREATE SUBSCRIPTION myapp_sub
CONNECTION 'host=eu-primary.rds.amazonaws.com user=replicator password=secret dbname=myapp'
PUBLICATION myapp_pub;
AWS Aurora Global Database — managed variant:
Primary Region: eu-west-1 (write + read)
Secondary: us-east-1 (read-only, ~1s lag)
Secondary: ap-southeast-1 (read-only)
Aurora Global failover: ~1 minute, automatic via Route 53.
Kubernetes: Multi-Regional Deployment
# ArgoCD ApplicationSet: deploy to multiple clusters
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp
namespace: argocd
spec:
generators:
- list:
elements:
- cluster: eks-eu-west-1
region: eu-west-1
db_host: aurora-eu.cluster.rds.amazonaws.com
- cluster: eks-us-east-1
region: us-east-1
db_host: aurora-us.cluster.rds.amazonaws.com
template:
metadata:
name: 'myapp-{{region}}'
spec:
project: default
source:
repoURL: https://github.com/myorg/myapp
targetRevision: HEAD
path: helm/myapp
helm:
values: |
region: {{region}}
database:
host: {{db_host}}
destination:
server: '{{cluster}}'
namespace: myapp
Stateless Application
For multi-regional deployment the app must be stateless:
// DON'T store state in process memory
// BAD:
const sessions = new Map<string, Session>(); // lost on restart
// GOOD: Redis (with replication)
import { Redis } from '@upstash/redis';
const redis = new Redis({
url: process.env.UPSTASH_REDIS_URL!, // Upstash supports multi-region
token: process.env.UPSTASH_REDIS_TOKEN!,
});
async function getSession(sessionId: string): Promise<Session | null> {
return redis.get<Session>(`session:${sessionId}`);
}
Vercel/Netlify: Edge Network
For Next.js/Nuxt simplest multi-regional deploy — Vercel Edge Network:
// Server components and API routes deploy as Edge Functions
// automatically to 30+ regions worldwide
// app/api/config/route.ts
export const runtime = 'edge'; // deploy to edge nodes worldwide
export async function GET() {
const region = process.env.VERCEL_REGION ?? 'unknown';
return Response.json({ region });
}
Latency overhead for EU→US: 100–150ms. Edge deployment: 5–20ms to user.
Monitoring Multi-Regional Deployment
# Prometheus: metrics by region
labels:
region: eu-west-1
cluster: eks-eu
# Grafana dashboard: Request Rate by Region, Latency by Region
# Alertmanager: alert if one region unavailable
Setting up Active-Active multi-regional deployment in two AWS regions with Aurora Global Database — 5–10 working days.







