Advanced

Multi-Region Active-Active

Build a globally distributed application with automatic failover

Project Overview

Design and deploy an application that runs simultaneously in multiple AWS regions, providing low latency for global users and resilience against regional failures.

Difficulty: Advanced
AWS Services: Route 53, Global Accelerator, Aurora Global, DynamoDB Global Tables
Cost: ~$200-500/month (tear down after learning)

Prerequisites

  • Completed Three-Tier Web Application project
  • Strong understanding of VPC networking
  • Experience with RDS or DynamoDB
  • Infrastructure as Code skills

Architecture

🌐
Global Users
🌍
Global Accelerator
Anycast IP
Region A (us-east-1)
🖥
App Stack
🗃
DynamoDB
Replication
Region B (eu-west-1)
🖥
App Stack
🗃
DynamoDB

Global Tables provide automatic bi-directional replication

Step-by-Step Instructions

1

Deploy Application in Primary Region

  • Deploy your three-tier application in us-east-1
  • Use Infrastructure as Code for reproducibility
  • Ensure all resources are tagged for cost tracking
  • Document all configurations and dependencies
2

Set Up DynamoDB Global Tables

  • Convert your DynamoDB table to a Global Table
  • Add replica in secondary region (e.g., eu-west-1)
  • Understand eventual consistency implications
  • Plan for conflict resolution (last writer wins)
  • Monitor replication lag with CloudWatch
3

Deploy Application in Secondary Region

  • Run same IaC template in eu-west-1
  • Update configuration to use local DynamoDB replica
  • Ensure identical AMIs or container images
  • Verify application functions independently
4

Configure Global Traffic Management

  • Option A: Create AWS Global Accelerator
  • Option B: Use Route 53 latency-based routing
  • Add endpoints from both regions
  • Configure health checks for automatic failover
  • Set appropriate TTLs for DNS records
5

Implement Health Checks and Failover

  • Create Route 53 health checks for each region
  • Configure CloudWatch alarms for health metrics
  • Set up SNS notifications for failover events
  • Define recovery procedures and runbooks
6

Test Failover Scenarios

  • Simulate regional failure by stopping services
  • Verify traffic automatically routes to healthy region
  • Test data consistency after failover
  • Measure Recovery Time Objective (RTO)
  • Document findings and optimize

Tips

  • Use eventual consistency patterns - Design your application to handle temporary data inconsistencies
  • Monitor replication lag - Set up CloudWatch alarms for Global Tables replication metrics
  • Test regularly - Run game days to practice failover procedures
  • Consider data locality regulations - Some data may need to stay in specific regions

Code Examples

DynamoDB Global Tables Setup

Terminal Commands BASH
# Create DynamoDB table with Global Tables v2
aws dynamodb create-table \
    --table-name UserSessions \
    --attribute-definitions AttributeName=userId,AttributeType=S \
    --key-schema AttributeName=userId,KeyType=HASH \
    --billing-mode PAY_PER_REQUEST \
    --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
    --region us-east-1

# Add replica in eu-west-1
aws dynamodb update-table \
    --table-name UserSessions \
    --replica-updates "Create={RegionName=eu-west-1}" \
    --region us-east-1

Route 53 Latency-Based Routing

route53-latency.json JSON
{
    "Changes": [
        {
            "Action": "CREATE",
            "ResourceRecordSet": {
                "Name": "app.example.com",
                "Type": "A",
                "SetIdentifier": "us-east-1",
                "Region": "us-east-1",
                "AliasTarget": {
                    "HostedZoneId": "Z35SXDOTRQ7X7K",
                    "DNSName": "us-east-1-alb.example.com",
                    "EvaluateTargetHealth": true
                }
            }
        },
        {
            "Action": "CREATE",
            "ResourceRecordSet": {
                "Name": "app.example.com",
                "Type": "A",
                "SetIdentifier": "eu-west-1",
                "Region": "eu-west-1",
                "AliasTarget": {
                    "HostedZoneId": "Z32O12XQLNTSW2",
                    "DNSName": "eu-west-1-alb.example.com",
                    "EvaluateTargetHealth": true
                }
            }
        }
    ]
}

Global Accelerator CloudFormation

global-accelerator.yaml YAML
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  GlobalAccelerator:
    Type: AWS::GlobalAccelerator::Accelerator
    Properties:
      Name: multi-region-accelerator
      Enabled: true
      IpAddressType: IPV4

  Listener:
    Type: AWS::GlobalAccelerator::Listener
    Properties:
      AcceleratorArn: !Ref GlobalAccelerator
      Protocol: TCP
      PortRanges:
        - FromPort: 443
          ToPort: 443

  EndpointGroup1:
    Type: AWS::GlobalAccelerator::EndpointGroup
    Properties:
      ListenerArn: !Ref Listener
      EndpointGroupRegion: us-east-1
      TrafficDialPercentage: 50
      HealthCheckProtocol: HTTPS
      EndpointConfigurations:
        - EndpointId: !Ref USEastALB
          Weight: 100

  EndpointGroup2:
    Type: AWS::GlobalAccelerator::EndpointGroup
    Properties:
      ListenerArn: !Ref Listener
      EndpointGroupRegion: eu-west-1
      TrafficDialPercentage: 50
      EndpointConfigurations:
        - EndpointId: !Ref EUWestALB
          Weight: 100

Health Check with Route 53

Terminal Commands BASH
# Create health check for primary region
aws route53 create-health-check --caller-reference $(date +%s) \
    --health-check-config '{
        "IPAddress": "1.2.3.4",
        "Port": 443,
        "Type": "HTTPS",
        "ResourcePath": "/health",
        "FullyQualifiedDomainName": "us-east-1-alb.example.com",
        "RequestInterval": 10,
        "FailureThreshold": 3
    }'

# List health checks
aws route53 list-health-checks

What You'll Learn

  • Multi-region architecture design patterns
  • Global traffic management with Route 53 and Global Accelerator
  • Data replication strategies and consistency models
  • Conflict resolution patterns for distributed writes
  • Failover automation and disaster recovery testing