devHọc Dev
EN
Bài học

Tuần 4 - Ngày 1: Multi-AZ vs Multi-Region, DR Strategies, Backup/Restore và Route 53 Failover

Tuần 4 – Ngày 1

Bài này gộp 4 chủ đề: Multi-AZ vs Multi-Region, DR Strategies (4 Patterns), Backup và Restore Patterns, Route 53 Failover Patterns.

Mục tiêu học tập

  • Phân biệt Multi-AZ và Multi-Region architectures
  • Hiểu trade-offs: cost, complexity, RTO/RPO
  • Áp dụng pattern phù hợp cho từng workload
  • Hiểu 4 DR patterns: Backup/Restore, Pilot Light, Warm Standby, Multi-Site
  • Phân biệt RTO/RPO trade-offs
  • Áp dụng pattern phù hợp cho từng business requirement
  • Apply AWS Backup cho centralized backup strategy
  • Hiểu service-specific backup options
  • Nắm restore procedures và test
  • Hiểu Route 53 Failover routing
  • Áp dụng Health Checks cho automatic failover
  • Phân biệt Active-Passive vs Active-Active
  • Hiểu DNS TTL impact on failover speed

Phần 1: Multi-AZ vs Multi-Region

1. High Availability Concepts

Định nghĩa

  • High Availability (HA): minimize downtime (~99.9-99.99%)
  • Fault Tolerance: zero downtime, system continues during failure
  • Disaster Recovery (DR): recover from major disaster (region-wide)

Key metrics

  • RTO (Recovery Time Objective): max acceptable downtime
  • RPO (Recovery Point Objective): max acceptable data loss
  • SLA (Service Level Agreement): uptime guarantee

Common SLA examples

  • 99% = ~3.65 days downtime/year
  • 99.9% = ~8.77 hours/year
  • 99.99% = ~52.6 minutes/year
  • 99.999% (5 nines) = ~5.26 minutes/year

2. AWS Failure Domains

Hierarchy

Region├──AvailabilityZone1│├──DataCenterA│└──DataCenterB├──AvailabilityZone2│└──...└──AvailabilityZone3└──...

Failure scenarios

FailureAffectedMitigation
Instance failure1 EC2Auto Scaling Group (auto-replace)
Hardware failure1 hostPlace instances in spread placement group
AZ failure (rare)All resources in AZMulti-AZ deployment
Region failure (very rare)All resources in regionMulti-Region deployment

3. Multi-AZ Architecture

Pattern

Regionus-east-1:├──AZ-1a:Webtier(EC2)────►RDSPrimary├──AZ-1b:Webtier(EC2)────►RDSStandby(syncreplication)└──AZ-1c:Webtier(EC2)↓LoadBalancer(spansAZs)

Components

  • ALB: span multiple AZs (built-in HA)
  • ASG: spread across AZs
  • RDS Multi-AZ: primary + standby in different AZ
  • DynamoDB: auto multi-AZ replicate
  • EFS: multi-AZ
  • S3: multi-AZ (Standard storage class)

Benefits

  • Tolerate AZ failure
  • Low latency between AZs (< 10ms)
  • No cross-region data transfer cost
  • Simpler than multi-region

Trade-offs

  • Does NOT protect against region failure
  • Limited to 1 region's services

Typical SLA: 99.99%

4. Multi-Region Architecture

Pattern

Regionus-east-1(Primary):Regioneu-west-1(DR):├──Activeworkload├──Standby(oractive)├──RDSPrimary├──RDSReadReplica└──S3bucket└──S3CRRdestinationRoute53(global):└──Failover/Latencyrouting→usersroutedtonearesthealthyregion

Benefits

  • Tolerate region failure (major disaster)
  • Lower latency cho global users
  • Compliance (data residency per region)

Trade-offs

  • Higher cost (resources in multiple regions)
  • Higher complexity (replication, failover)
  • Eventually consistent between regions (lag)
  • Cross-region data transfer cost

Typical SLA: 99.999%+

5. DR Strategies (Recap — chi tiết xem Phần 2)

StrategyRTORPOCost
Backup & RestoreHoursHours$
Pilot Light10 min - hourMin$$
Warm StandbyMinutesMin$$$
Multi-Site (Active-Active)SecondsNone$$$$

6. Multi-AZ Decision Matrix

Always Multi-AZ for production

  • RDS, Aurora (Multi-AZ deployment)
  • ElastiCache (cluster mode)
  • EFS (Standard)
  • Application servers (ALB + ASG across AZs)

Single-AZ OK for

  • Dev/test environments
  • Stateless workloads (can rebuild)
  • Cache (data can be regenerated)
  • Compute-only workload với data elsewhere

7. Multi-Region Use Cases

When multi-region needed

  • Global users with latency requirements
  • Mission-critical (banks, healthcare)
  • Regulatory compliance (data residency)
  • Tolerate region failure (rare but possible)

When NOT needed

  • Single-region users
  • Cost-sensitive (overhead 2x+)
  • App not designed for distributed state
  • Acceptable to have hours of downtime

8. Service Availability Patterns

Stateless services

  • Easy to multi-AZ/multi-region (deploy in each)
  • Examples: EC2 web tier, Lambda

Stateful services

  • Harder — need data replication
  • Examples: databases, file systems
Strategies cho stateful
  • Multi-AZ replication: RDS Multi-AZ, ElastiCache Redis Multi-AZ
  • Cross-region replication: S3 CRR, DynamoDB Global Tables, Aurora Global DB
  • Manual replication: backup + restore in DR region

9. Data Replication Options

Synchronous replication

  • Write to primary + replica before ACK
  • Zero RPO (no data loss)
  • Higher latency (limited to ~10ms = same region)
  • Examples: RDS Multi-AZ, Aurora replicas (same region)

Asynchronous replication

  • Write to primary, replica eventually
  • Some RPO (data loss possible, seconds-minutes)
  • Lower latency (cross-region possible)
  • Examples: RDS Read Replicas, S3 CRR, DynamoDB Global Tables

Combined

  • Within region: sync (HA)
  • Cross-region: async (DR)

10. Common Architecture Patterns

Pattern 1: Multi-AZ web app

Route53──►ALB(Multi-AZ)├──ASG(Webtier,3AZs)├──ASG(Apptier,3AZs)└──RDSMulti-AZ(Primary+Standby)

Pattern 2: Multi-Region active-passive

Route53(Failoverrouting)/\(active)/\(passive)/\us-east-1eu-west-1││ALB+ASG(resourcesspunRDSPrimaryuponlyonfailover)│▲└──CRR────────────┘└──DynamoDBGlobal┘

Pattern 3: Multi-Region active-active

Route53(Latency-based)/\/\us-east-1eu-west-1(active)(active)││ALB+ASGALB+ASGAuroraGlobal◄─────►ReadreplicasDynamoDBGlobal◄───►DynamoDB

11. Cost Considerations

Multi-AZ

  • ~2x cost for stateful (RDS Multi-AZ = 2x)
  • ~1x cost for stateless (already in multiple AZs)

Multi-Region

  • ~2x+ cost (duplicate everything)
  • Cross-region data transfer ($)
  • Plus replication setup/maintenance

Optimize

  • Multi-AZ for HA, not multi-region if not needed
  • Use Aurora Global Database instead of full duplication (cheaper)
  • DynamoDB Global Tables (pay per region)
  • Active-passive cheaper than active-active (DR region scaled down)

Phần 2: DR Strategies (4 Patterns)

1. RTO và RPO

Định nghĩa

  • RTO (Recovery Time Objective): max acceptable downtime (how long can we be down?)
  • RPO (Recovery Point Objective): max acceptable data loss (how much data can we lose?)

Example

  • Online banking: RTO = 1 hour, RPO = 0 (no data loss)
  • Internal blog: RTO = 24 hours, RPO = 1 day

Trade-off

  • Lower RTO/RPO → higher cost
  • Balance: spend $$ proportionally to business impact

2. The 4 DR Strategies

                         RTO   RPO  Cost
Backup & Restore        Hours  Hours  $
Pilot Light             10 min-1h  Min  $$
Warm Standby            Minutes  Min  $$$
Multi-Site Active/Active Seconds  Zero  $$$$

3. Strategy 1: Backup & Restore

Architecture

PrimaryRegion(active):├──EC2,RDS,S3(working)└──Backup→S3(withCRRtoDRregion)DRRegion:└──Empty(norunningresources)└──BackupsinS3+AMIsWhendisaster:1.SpinupinfrastructureinDRregion(fromCloudFormation)2.Restorefrombackup3.UpdateDNStopointtoDRregion4.Test5.Resumeoperations

RTO: Hours to days

RPO: Hours (depending on backup frequency)

Setup

  • Daily backups to S3 with CRR
  • AMI snapshots cross-region
  • Database snapshots cross-region
  • CloudFormation templates ready in DR region

Cost

  • Lowest: only pay for backup storage in DR region
  • No compute running in DR

Use case

  • Non-critical apps
  • Long RTO/RPO acceptable
  • Cost-sensitive

4. Strategy 2: Pilot Light

Architecture

PrimaryRegion(active):├──Fullproduction(EC2,RDS,etc.)└──ReplicatetoDRDRRegion(minimal):├──CriticalinfrastructureRUNNING:│└──RDSReadReplica(orrestored)│└──MinimalEC2(orjustAMIsready)└──ResourcesscaledDOWNWhendisaster:1.PromoteRDSreplicatoprimary2.ScaleupEC2(orlaunchfromAMIs)3.UpdateDNS

RTO: 10 minutes - 1 hour

RPO: Minutes (continuous replication)

Setup

  • Continuous DB replication (e.g., Aurora cross-region replica)
  • AMIs current in DR region
  • Network setup pre-configured
  • Auto Scaling templates ready

Cost

  • Medium: minimal compute running, DB replica costs
  • Still pay for DB replica + minimal EC2

Use case

  • Important apps but not mission-critical
  • Acceptable < 1 hour downtime

5. Strategy 3: Warm Standby

Architecture

PrimaryRegion(active):├──FullproductionDRRegion(running,smallerscale):├──Fullarchitecturerunning├──Smallerinstancesizes(orfewerinstances)├──DBreplicacontinuouslysynced└──Receivingsometesttraffic(optional)Whendisaster:1.ScaleUPDRresources2.UpdateDNS3.Resumefulloperations

RTO: Minutes (< 30 min)

RPO: Minutes

Setup

  • Smaller version of production in DR
  • Continuous replication
  • Optionally serve % traffic for warmup

Cost

  • Higher: full architecture running (smaller scale)

Use case

  • Critical apps
  • Need fast recovery
  • Budget for redundancy

6. Strategy 4: Multi-Site Active-Active

Architecture

PrimaryRegion(active):├──FullproductionreceivingtrafficDRRegion(active):├──Fullproductionreceivingtraffic├──BothregionsactivelyserveusersRoute53Latency-basedrouting:├──Users→nearestregion└──Autofailoverif1regiondownData:bi-directionalreplication(DynamoDBGlobalTables,AuroraGlobal)

RTO: Seconds (auto-failover)

RPO: Near-zero

Setup

  • Both regions full production
  • Bi-directional data replication
  • Route 53 latency-based + health checks
  • Aurora Global Database / DynamoDB Global Tables

Cost

  • Highest: 2x+ infrastructure
  • 2x compute, 2x storage, cross-region transfer

Use case

  • Mission-critical (financial, healthcare)
  • Global users (low latency benefit too)
  • Compliance requires multi-region

7. Comparison Table

StrategyRTORPOCostComplexity
Backup & RestoreHours-daysHours$Low
Pilot Light10 min-1hMinutes$$Medium
Warm Standby< 30 minMinutes$$$Medium-High
Multi-Site A/ASecondsNear-zero$$$$High

8. Choosing Strategy

Decision matrix

Workloadcriticality?│├──Low(internaltool,dev)│└──Backup&Restore│├──Medium(businessapp,<houroutageOK)│├──AcceptableRTO1hour││└──PilotLight│└──RTO15-30min│└──WarmStandby│└──Mission-critical(financial,healthcare,e-commerce)└──Multi-SiteActive-Active

Cost vs benefit

  • Calculate cost of downtime per hour
  • If $1000/hr downtime cost, paying $500/month for HA is worth it

9. DR Testing

Regular drills required

  • Test DR procedure quarterly
  • Validate RTO/RPO actually meet objectives
  • Update runbooks after tests

Game days

  • Simulated outages
  • Practice for ops team
  • Find gaps before real incident

AWS Resilience Hub

  • Automated DR testing tool
  • Continuous validation
  • Recommendations based on Well-Architected Framework

10. Common AWS Services for DR

Compute

  • EC2 + AMI cross-region copy
  • ASG with multi-region patterns
  • Lambda (regional, easy redeploy)

Storage

  • S3 Cross-Region Replication (CRR)
  • EBS snapshot cross-region copy
  • AWS Backup cross-region

Databases

  • RDS cross-region read replica → promote
  • Aurora Global Database (sub-second cross-region)
  • DynamoDB Global Tables (multi-master)
  • ElastiCache global datastore (Redis)

Network

  • Route 53 Failover routing
  • Route 53 health checks
  • Global Accelerator (anycast)
  • Transit Gateway peering

Orchestration

  • CloudFormation templates (rebuild)
  • AWS Backup (centralized backup management)
  • AWS Resilience Hub (DR validation)

11. Specific Service DR Capabilities

S3

  • Same-region replication (SRR)
  • Cross-region replication (CRR)
  • S3 RTC: 99.99% replicated within 15 min

RDS

  • Multi-AZ: synchronous, intra-region
  • Read replicas: async, cross-region
  • Automated backups: PITR
  • Snapshots: manual, cross-region copy

Aurora

  • Aurora Global Database: < 1 min RTO, < 1 sec RPO

DynamoDB

  • Global Tables: multi-region active-active

Lambda

  • Stateless, regional
  • DR: deploy in DR region (CloudFormation/IaC)

12. Common Patterns

Pattern 1: SaaS web app

  • Multi-AZ in primary region
  • Warm Standby in DR region (smaller)
  • Aurora cross-region replica
  • S3 CRR for assets
  • Route 53 failover with health check

Pattern 2: E-commerce global

  • Multi-Site Active-Active
  • DynamoDB Global Tables
  • Aurora Global Database
  • Route 53 latency routing
  • CloudFront for static content

Pattern 3: Compliance archive

  • Backup & Restore
  • S3 Glacier with cross-region replication
  • Quarterly restore drills

Pattern 4: Critical internal tool

  • Pilot Light
  • Daily DB backups + CRR
  • AMI ready in DR
  • Documented manual failover procedure

Phần 3: Backup và Restore Patterns

1. Backup Strategy Tiers

Tier 1: Service-native backup

  • Mỗi service có backup tự native (RDS snapshots, EBS snapshots)
  • Configure per service
  • Manual or automatic

Tier 2: AWS Backup (centralized)

  • Single service quản lý backup cho mọi service supported
  • Backup plans, policies, vault management
  • (Chi tiết ở Tuần 1 Ngày 5, Phần 3)

Tier 3: Third-party tools

  • Veeam, Commvault, Cohesity
  • Integration với AWS

2. Backup Components Review

Backup Plan

  • Schedule (cron)
  • Lifecycle (warm + cold transitions)
  • Cross-region copy

Backup Vault

  • Storage container
  • KMS encryption
  • Access policy
  • Vault Lock (immutable WORM)

Backup Job

  • Instance of backup execution

Restore Job

  • Restore from recovery point to new resource

3. Service-Specific Backup Options

EBS Snapshots

  • Incremental backup to S3
  • Cross-region copy
  • Cross-account share (with KMS key share)
  • DLM (Data Lifecycle Manager) automation

RDS Snapshots

  • Automated (daily, retention 0-35 days, PITR)
  • Manual (indefinite retention)
  • Cross-region/cross-account copy

DynamoDB Backups

  • PITR (35 days continuous backup)
  • On-demand backup (indefinite)
  • AWS Backup integration

S3

  • Versioning (track changes, recover from accidental delete)
  • Replication (SRR, CRR)
  • Object Lock (WORM)

Aurora

  • Continuous backup to S3 (1-35 days PITR)
  • Snapshots
  • Cross-region snapshots

EFS

  • Backup automatic via AWS Backup
  • Per-file restore

4. Backup Strategy Best Practices

3-2-1 Rule

  • 3 copies of data
  • 2 on different storage media
  • 1 offsite (cross-region)

AWS implementation

  • Production: live in S3 + EBS + RDS
  • Backup vault: AWS Backup vault same region
  • DR copy: AWS Backup vault cross-region

Test restore regularly

  • "Untested backup = no backup"
  • Quarterly restore test
  • Document time taken (validate RTO)

Vault Lock

  • Compliance Mode (immutable, even root)
  • Use for compliance archives
  • Ransomware protection

5. Cross-Region Backup

Setup AWS Backup CRR

  • Backup Plan with copy action
  • Destination vault in DR region
  • Lifecycle for cross-region copy
  • Separate KMS keys per region

Cost

  • Cross-region data transfer charge
  • Storage cost in both regions

Use case

  • DR (region-wide failure)
  • Compliance (data in multiple geos)

6. Cross-Account Backup

Use case

  • Ransomware protection (attacker in prod can't delete backups in security account)
  • Compliance (separation of duties)

Setup (with Organizations)

  1. Enable AWS Backup at organization level
  2. Backup plan in management/delegated account
  3. Backup copies to central vault account

Vault in central account

  • Vault Lock Compliance Mode
  • Only backup admin role can manage
  • Prod account compromise doesn't lose backups

7. Database Specific

RDS PITR (Point-in-Time Recovery)

  • Restore to any second within retention (default 7 days)
  • Restore creates NEW DB instance (cannot restore in-place)
  • New endpoint → update app config

Aurora Backtrack (MySQL)

  • "Rewind" cluster to previous timestamp (up to 72 hours)
  • In-place (no new cluster)
  • Faster than PITR

DynamoDB PITR

  • Last 35 days
  • Restore to new table

Choice

  • PITR: standard, granular (any second)
  • Backtrack: Aurora only, faster but only 72 hours
  • Manual snapshot: long-term retention, after major changes

8. EBS Snapshot Patterns

DLM (Data Lifecycle Manager)

DLM Policy:
  Target: tag Environment=production
  Schedule:
    - Frequency: daily at 03:00 UTC
      Retention: 7 snapshots
    - Frequency: weekly Monday 04:00 UTC
      Retention: 4 weeks
    - Frequency: monthly 1st 05:00 UTC
      Retention: 12 months
  Copy across regions: us-west-2
  Encryption: customer-managed KMS key

Tags-based selection

  • Tag instances/volumes with Backup=true or Tier=production
  • DLM picks up automatically
  • No manual maintenance

9. S3 as Backup Destination

Use case

  • On-prem backup to S3 (replacing tape)
  • App-level backup logs/files
  • Database export

Tools

  • AWS Storage Gateway (Tape Gateway): emulate tape library
  • AWS Backup (with native sources)
  • AWS DataSync (file sync)
  • Custom scripts (aws s3 sync)

Storage class tiering

  • Recent: S3 Standard or Standard-IA
  • Older: Glacier Instant Retrieval
  • Archive: Glacier Deep Archive

Cost optimization

  • Lifecycle rules transition automatically
  • Use S3 Object Lock Compliance Mode for immutability

10. Restore Best Practices

Document procedures

  • Step-by-step runbook for each restore scenario
  • Include who has authority, dependencies

Test regularly

  • Quarterly: simulate failure, restore from backup
  • Measure: actual RTO/RPO vs target

Restore environment

  • Often restore to isolated environment first (verify)
  • Then move to production once validated

Communication

  • Document stakeholder notification process
  • Status updates during recovery

11. Backup Cost Optimization

Strategies

  1. Lifecycle to cold storage for old backups
  2. Right-size retention (don't keep forever unnecessarily)
  3. Skip dev/test backups (or shorter retention)
  4. Compress before backup if possible
  5. Deduplication (Storage Gateway, some tools)
  6. Avoid multiple backup tools (consolidate to AWS Backup)

Cost components

  • Storage in S3/Glacier ($)
  • Cross-region transfer ($)
  • API calls (small)
  • KMS API calls (encryption)

12. Common Patterns

Pattern 1: SaaS app

  • AWS Backup daily for EC2, RDS, EFS
  • Lifecycle to cold storage after 30 days
  • Cross-region copy for DR
  • Vault Lock Governance for production

Pattern 2: Compliance archive

  • AWS Backup with Compliance Mode Vault Lock
  • 7-year retention
  • Cross-region for redundancy
  • Backup Audit Manager reports

Pattern 3: Ransomware protection

  • Cross-account backup to security account
  • Vault Lock Compliance Mode
  • Production can backup TO but not delete FROM

Pattern 4: Critical DB

  • RDS Multi-AZ (HA)
  • Automated backups + PITR (35 days)
  • Cross-region snapshot copy (DR)
  • Aurora Global Database for fast recovery

Phần 4: Route 53 Failover Patterns

1. Failover Routing Recap

Active-Passive

  • Primary + Secondary record
  • Health check on primary
  • If primary unhealthy → traffic to secondary

Architecture

Route53DNS:example.com→├──Primary:ALB-us-east-1(healthcheckOK)└──Secondary:ALB-eu-west-1(passive)User→DNSquery→ReturnsPrimaryIPIfPrimaryfailshealthcheck→ReturnsSecondaryIP

2. Health Checks

3 types

1. Endpoint Health Check
  • HTTP/HTTPS/TCP probe
  • ~15 AWS health checkers globally
  • Interval: 10s (fast) or 30s (standard)
  • Failure threshold: 1-10 (default 3)
  • Path, port, host configurable
2. Calculated Health Check
  • Combine 2-256 child health checks
  • AND, OR, NOT logic
  • Use case: "Healthy if 3+ regions healthy"
3. CloudWatch Alarm-based Health Check
  • Trigger when CloudWatch alarm state
  • Use case: alarm khi DynamoDB throttling → DNS failover

Cost

  • Endpoint within AWS: free 50 checks đầu (cùng account), sau đó $0.50/check/tháng
  • Endpoint outside AWS: $0.75/check/tháng
  • Optional features (HTTPS, string matching, fast interval...): $1-2/feature/tháng
  • Calculated: $1/check/tháng
  • CloudWatch alarm-based: $1/check/tháng

3. Health Check Best Practices

Endpoint design

  • Dedicated /health endpoint
  • Returns 200 if healthy, 503 if not
  • Check dependencies (DB connection, cache, external API)

Frequency

  • 10-second interval for critical apps (fast failover)
  • 30-second for less critical (lower cost)

Failure threshold

  • Higher (e.g., 5): less false positives, slower failover
  • Lower (e.g., 2): faster failover, more false positives
  • Recommended: 3-5

Multi-region health check

  • Place health checkers in DIFFERENT regions than target
  • Detect region-specific issues

4. DNS TTL and Failover Speed

Why TTL matters

  • TTL = how long resolvers cache DNS response
  • After failover, resolvers may serve OLD record until TTL expires
  • → Effective failover time = health check detection + TTL expiry

Trade-off

  • Low TTL (60 sec): fast failover, more DNS queries (cost)
  • High TTL (24 hour): cheap, slow failover

Recommendation

  • Stable apps: 300-3600s
  • HA apps: 60s
  • Before maintenance: pre-lower TTL 24h ahead

ALIAS record

  • AWS-managed TTL (usually 60 sec)
  • Optimal cho AWS resources
  • Recommended over CNAME

5. Active-Passive Failover Setup

Steps

  1. Tạo health check trên primary ALB
  2. Tạo primary record:
    • Routing policy: Failover
    • Failover type: Primary
    • Health check ID: từ step 1
    • Value: ALB-us-east-1 alias
  3. Tạo secondary record:
    • Routing policy: Failover
    • Failover type: Secondary
    • Health check optional
    • Value: ALB-eu-west-1 alias

Behavior

  • DNS query → R53 returns Primary IF healthy
  • If unhealthy → returns Secondary
  • When primary recovers → R53 returns Primary again

Combine với DR strategy

  • Pilot Light / Warm Standby: passive resources in DR region
  • Health check fail → DNS failover + (optionally) auto-scale DR

6. Active-Active Failover

Pattern: Multivalue Answer hoặc Weighted/Latency

  • Both regions actively serving
  • Each region has own health check
  • If 1 region unhealthy → DNS không return its record

Weighted Routing với health checks

example.com:├──RegionA(weight50,healthcheck)└──RegionB(weight50,healthcheck)Bothhealthy→50/50trafficAunhealthy→100%toB

Latency-based với health checks

  • Lowest-latency region returned
  • Skip unhealthy regions
  • Best for global apps

7. Multi-Region Failover Patterns

Pattern 1: Active-Passive with Aurora Global DB

PrimaryRegion:└──ALB→App→AuroraPrimaryDRRegion(passive):└──ALB(idle)→App(idle)→AuroraSecondary(read-only)Failover:1.Detectfailure(healthcheck)2.Route53→switchtoDRregionDNS3.PromoteAuroraSecondary→Primary4.(Optionally)scaleupDRresources

Pattern 2: Active-Active with DynamoDB Global Tables

RegionA:└──ALB→App→DynamoDBGlobalTableARegionB:└──ALB→App→DynamoDBGlobalTableB(bidirectionalsync)Route53Latency-based+healthchecksBothregionsactivesimultaneously

Pattern 3: Active-Active with Global Accelerator

StaticIP(anycast)→GlobalAccelerator├──EndpointRegionA(weight50)└──EndpointRegionB(weight50)GAbuilt-inhealthchecksAutofailoveratIPlevel(fasterthanDNS)

8. Route 53 vs Global Accelerator

Route 53 FailoverGlobal Accelerator
MechanismDNS (TTL-dependent)Anycast IP (TCP/UDP)
Failover timeHealth check + TTL< 1 minute (no DNS dependency)
ProtocolAny (DNS-resolved)TCP, UDP
Static IPNoYes (2 anycast IPs)
CachingDNS resolverNo
Cost$0.50/zone + queries$0.025/hour endpoint + data transfer

When to use GA over Route 53

  • Cần static IP cho whitelisting
  • Non-HTTP traffic (gaming, IoT)
  • Faster failover (< 1 min vs TTL-dependent)
  • Reduce DNS-related latency

9. Failover Testing

Test procedure

  1. Manually disable primary (stop ALB target group health)
  2. Observe DNS failover (use dig or online DNS tool)
  3. Measure time: health check detection + TTL expiry
  4. Verify app works on secondary
  5. Re-enable primary, observe failback

Tools

  • dig +short example.com (check current DNS)
  • AWS Console Route 53 health check status
  • CloudWatch metrics on health check

Game day exercise

  • Simulate region failure
  • Document actual RTO/RPO
  • Find gaps (e.g., manual steps that should be automated)

10. DNS Failover Limitations

Limitations

  • DNS resolvers may cache (TTL)
  • Browser DNS cache (separate from resolver, persistent across requests)
  • CDN edge caches DNS too
  • Some clients ignore TTL (rare)

Workarounds

  • Use Global Accelerator (no DNS)
  • Use CloudFront (origin failover at edge level)
  • Use client-side retry logic with multiple endpoints

11. CloudFront Origin Failover

Định nghĩa

CloudFront Origin Failover = primary + secondary origin in CloudFront distribution.

Setup

CloudFrontDistribution:├──OriginGroup:my-origins│├──Primary:ALB-us-east-1│└──Secondary:ALB-eu-west-1│Failovercriteria:5xxerrorsortimeout

Behavior

  • Edge tries primary, if fails → secondary
  • Sub-second failover (no DNS)
  • Use case: HTTP/HTTPS apps with multi-region origins

vs Route 53 Failover

  • CloudFront: faster failover, only HTTP/HTTPS, requires CloudFront
  • Route 53: any protocol, slower (TTL-dependent)

12. Common Patterns

Pattern 1: Web app multi-region failover

User→Route53(failover)├──Primary:CloudFront→ALBus-east-1└──Secondary:CloudFront→ALBeu-west-1Healthchecks:HTTPS/healthoneachALBTTL:60s

Pattern 2: API endpoint with static IP

APIconsumers(whitelistedIPs)→GlobalAccelerator(2staticIPs)├──NLBus-east-1└──NLBeu-west-1

Pattern 3: Database failover

App→AuroraGlobalDatabase└──DRscenario:1.Promotesecondarycluster→primary2.UpdateappDBconnection3.(OruseAuroraendpointthatfollowspromotion)

Câu hỏi ôn tập

  1. Khác biệt giữa Multi-AZ và Multi-Region?

    Xem đáp án

    Multi-AZ: redundancy trong cùng Region — protect against AZ failure (hardware, power, network). Failover automatic, fast (seconds to minutes). Multi-Region: redundancy across hai+ Regions — protect against Region failure (rare) hoặc serve users globally với low latency. Multi-Region phức tạp hơn, đắt hơn, nhưng cần cho highest availability requirements và global applications.

  2. Region failure có thường xuyên không?

    Xem đáp án

    Rất hiếm — AWS Region-wide failures cực kỳ rare. AZ failures xảy ra thỉnh thoảng. Multi-Region thường dùng cho: (1) Latency — serve users globally, (2) Compliance — data residency requirements, (3) Business continuity cho extreme availability requirements, không phải vì Region failure thường xuyên. Hầu hết applications chỉ cần Multi-AZ — Multi-Region là overkill và tốn kém cho hầu hết use cases.

  3. Khi nào nên dùng Multi-Region?

    Xem đáp án

    (1) Global user base cần low latency từ nhiều continents, (2) RTO/RPO gần zero — không thể chấp nhận downtime dù có failover, (3) Regulatory compliance — data phải replicate sang second Region, (4) Critical business applications với revenue loss cao mỗi phút downtime, (5) Sovereignty/Data residency requirements. Cost và complexity tăng đáng kể — justify chỉ khi business requirements rõ ràng.

  4. RDS Multi-AZ là sync hay async replication?

    Xem đáp án

    Synchronous replication — primary không acknowledge write cho application cho đến khi standby confirm đã replicate. Đảm bảo zero data loss (RPO = 0) khi failover. Tuy nhiên latency write cao hơn một chút so với single-AZ. Khác với Read Replicas dùng asynchronous replication — có thể có lag vài giây, nhưng ít ảnh hưởng đến write performance.

  5. SLA 99.99% nghĩa là downtime tối đa bao nhiêu/year?

    Xem đáp án

    ~52 phút/năm (52.6 phút). So sánh: 99.9% = ~8.7 giờ/năm, 99.95% = ~4.4 giờ/năm, 99.999% (five nines) = ~5 phút/năm. Công thức: downtime = (1 - SLA%) × 365 × 24 × 60 phút. Nhiều AWS services như S3, DynamoDB, ALB có SLA 99.99% hoặc cao hơn. Composite architecture SLA thấp hơn min component SLA — cần redundancy để đạt SLA tổng thể cao.

  6. 4 DR strategies từ rẻ nhất → đắt nhất là gì?

    Xem đáp án

    (1) Backup & Restore: rẻ nhất — backup data sang DR Region, restore khi disaster. RTO giờ-ngày. (2) Pilot Light: core components (DB replication) running, compute off — scale up khi cần. RTO phút-giờ. (3) Warm Standby: scaled-down production running — scale up khi failover. RTO phút. (4) Multi-Site Active-Active: đắt nhất — cả hai regions full capacity, traffic routed theo tỷ lệ. RTO ~0.

  7. Pilot Light có resources running ở DR region không?

    Xem đáp án

    Có — nhưng chỉ core components: database replication running (RDS cross-region replica, DynamoDB Global Tables). Compute (EC2, ECS) tắt hoặc scaled to minimum. Khi disaster: (1) Promote DB replica, (2) Scale up/launch compute, (3) Update DNS. Tên "Pilot Light" từ gas heater — flame nhỏ luôn cháy sẵn sàng đốt lên full. Rẻ hơn Warm Standby vì compute không running.

  8. Multi-Site Active-Active RTO khoảng bao nhiêu?

    Xem đáp án

    Gần 0 (zero downtime) — cả hai Regions đang serve traffic. Khi một Region fail, Route 53 hoặc Global Accelerator tự động route 100% traffic sang Region còn lại — không cần manual intervention. RTO thực tế phụ thuộc vào DNS TTL và health check intervals (thường < 1 phút). RPO cũng gần 0 nếu data replicated sync (Aurora Global Database) hoặc minutes nếu async.

  9. AWS Resilience Hub dùng để làm gì?

    Xem đáp án

    AWS Resilience Hub assess và improve resiliency của ứng dụng. Import application từ CloudFormation/Terraform/AppRegistry → define RTO/RPO targets → Hub analyze architecture → recommend gaps → generate resiliency score. Cũng có thể chạy resiliency drills (chaos engineering automated). Giúp teams biết application có đáp ứng DR objectives không — thay vì chỉ biết khi disaster thực sự xảy ra.

  10. Khi nào nên dùng Backup & Restore strategy?

Xem đáp án

Khi: (1) RTO/RPO requirements thấp (hours acceptable), (2) Budget hạn chế — không justify chạy infrastructure ở DR region liên tục, (3) Non-critical workloads — dev/test, batch processing, archives, (4) Data đã được backup đầy đủ và được test restore regularly, (5) Compliance requires offsite backup nhưng không yêu cầu fast failover. Không phù hợp cho production systems yêu cầu RTO < 1 giờ.

  1. 3-2-1 backup rule là gì?
Xem đáp án

3 copies của data, trên 2 loại media khác nhau, với 1 copy offsite. Trong AWS context: 3 copies (S3 tự replicate 3+, EBS snapshot), 2 media types (EBS + S3, hoặc S3 Standard + Glacier), 1 offsite (cross-Region backup). Nguyên tắc này đảm bảo: single hardware failure, site disaster, hoặc ransomware không xóa tất cả copies cùng lúc.

  1. RDS PITR cho phép restore in-place không?
Xem đáp án

Không — RDS Point-in-Time Recovery luôn tạo new DB instance. Không thể overwrite existing instance. Sau restore, cần update connection string trong application hoặc rename instances. PITR granularity: 1 giây (cho MySQL/Aurora), cần enabled automated backups, retention 1-35 ngày. Đây là safety feature — ngăn overwrite production DB khi restore.

  1. Aurora Backtrack max là bao lâu?
Xem đáp án

72 giờ (3 ngày) maximum backtrack window cho Aurora MySQL. Backtrack "rewind" cluster đến any point trong window — không cần restore snapshot (seconds to minutes, không cần new instance). Điểm khác biệt với PITR: Backtrack thực sự rewind in-place, rất nhanh. PITR tạo new instance. Backtrack chỉ cho Aurora MySQL, không có cho PostgreSQL.

  1. Vault Lock Compliance Mode khác Governance Mode?
Xem đáp án

Compliance Mode: immutable — không ai (root, AWS Support) thể delete hay modify vault lock sau khi confirmed, cho đến khi retention period hết. Phục vụ SEC Rule 17a-4(f), CFTC, FINRA requirements. Governance Mode: administrators với đặc quyền có thể override lock. Governance phù hợp khi cần operational flexibility; Compliance cho regulatory mandates không cho exception.

  1. Cross-account backup giúp bảo vệ chống gì?
Xem đáp án

Chủ yếu bảo vệ chống: (1) Ransomware — malware encrypt/delete production và backup trong cùng account, (2) Insider threat — malicious admin xóa cả backup, (3) Account compromise — attacker có full access account không thể xóa backup ở account khác, (4) Accidental deletion — vô tình xóa backup. Cross-account + Vault Lock = strongest protection cho backup integrity.

  1. Route 53 Failover yêu cầu gì cho primary record?
Xem đáp án

Primary record phải có Health Check associated. Route 53 monitor endpoint (HTTP/HTTPS/TCP) định kỳ (default 30s, hoặc 10s "Fast" health check). Khi primary health check fail (3 consecutive failures by default), Route 53 trả secondary record thay thế. Secondary record không bắt buộc có health check nhưng best practice là có. Health Check có thể monitor cả CloudWatch Alarm state.

  1. DNS TTL impact failover time như thế nào?
Xem đáp án

TTL cao = failover chậm. Khi DNS trả IP mới (sau failover), clients còn cache TTL cũ tiếp tục dùng IP cũ cho đến khi TTL hết. Ví dụ TTL 300s → failover visible sau tối đa 5 phút với users. Low TTL (60s hoặc ít hơn) = failover nhanh hơn nhưng nhiều DNS queries hơn = cost cao hơn. Trước planned maintenance, giảm TTL → maintenance → failover nhanh → tăng TTL lại.

  1. Global Accelerator failover khác Route 53 failover ở điểm gì?
Xem đáp án

Global Accelerator: failover ở network layer — anycast IPs tĩnh, routing thay đổi trong giây (< 1 phút, không phụ thuộc DNS TTL). Client không cần đổi IP. Route 53: failover qua DNS — tốc độ phụ thuộc TTL và DNS propagation (minutes). Global Accelerator phù hợp cho RTO requirements seconds; Route 53 failover phù hợp cho minutes. GA đắt hơn (~$18/accelerator/month + data fees).

  1. CloudFront Origin Failover hoạt động ở layer nào?
Xem đáp án

Layer 7 (HTTP) — CloudFront tự động retry origin request sang secondary origin khi primary origin trả HTTP 500, 502, 503, 504 (configurable). Transparent cho clients — client không thấy failover. Setup: Origin Group với primary + secondary origins. CloudFront attempt primary, nếu fail → try secondary. Phù hợp cho active-passive origins với automatic content failover.

  1. Tốc độ failover cho Active-Active so với Active-Passive?
Xem đáp án

Active-Active: failover gần như ngay lập tức — cả hai endpoints đang serve traffic, load balancer chỉ cần stop routing đến failed endpoint. RTO seconds. Active-Passive: cần promote passive region (launch instances, scale up, DNS update) — RTO minutes đến hours tùy strategy. Active-Active tốt hơn về RTO nhưng cần data sync real-time giữa regions (phức tạp và tốn kém hơn).

Bài tập thực hành

Phần 1: Multi-AZ vs Multi-Region

  • Vẽ architecture: Multi-AZ web app với ALB, ASG, RDS Multi-AZ
  • Setup S3 CRR sang region khác
  • Tạo Route 53 Failover routing primary/secondary
  • So sánh cost: same workload single-AZ vs Multi-AZ vs Multi-Region

Phần 2: DR Strategies (4 Patterns)

  • Tính toán RTO/RPO cho mỗi strategy cho 1 web app
  • Setup Backup & Restore: backup EC2 + RDS cross-region
  • Setup Pilot Light: Aurora read replica cross-region
  • Test Warm Standby failover procedure
  • (Optional) AWS Resilience Hub assessment

Phần 3: Backup và Restore Patterns

  • Setup AWS Backup plan: daily backup, 30 days retention, cross-region
  • Tag resources với Backup=true, observe backup jobs
  • Test PITR: restore RDS to 1 hour ago
  • Setup Vault Lock Governance Mode (test mode first)
  • Document restore procedure cho 1 critical service

Phần 4: Route 53 Failover Patterns

  • Setup Failover routing: primary + secondary với health check
  • Test: disable primary, measure failover time
  • Setup Latency-based với health checks (active-active)
  • Setup Global Accelerator với 2 regions
  • Setup CloudFront Origin Failover

Tài liệu tham khảo


Bài tiếp theo →