Ravindra BagaleCourses & study guides मराठी Track your progress

Multi-Region Serverless Architecture Patterns Explained

Multi-region serverless means users still check out when ap-south-1 hiccups — or when latency to another continent hurts. It is Route 53/health checks, data replication choices, idempotent writes, and a rehearsed failover — not just copying a SAM stack twice.

What you'll learn in this chapter

  • Name active-active vs active-passive
  • Pick data patterns (Global Tables vs async)
  • Wire DNS health checks thoughtfully
  • State RPO/RTO with product
  • Avoid split-brain writes

1. Everyday example: festival traffic + one AZ scare

Rohan in Pune (INR) serves India from ap-south-1. Leadership asks for ap-southeast-1 for SEA users and DR. Copying Lambdas is easy; copying correct stock counts without double-sell is the hard part.

DNS failover: Route 53 health checks (console/CLI). Data: DynamoDB and DynamoDB Global Tables. Compute stays Lambda per region.

2. Why multi-region?

Why do we need this?

Single-region is fine until compliance, latency, or a regional event hurts revenue. Multi-region without a data story creates silent corruption. Agree RPO (how much data loss) and RTO (how fast back) with product first.

What is it?

Active-passive = warm standby; fail over DNS. Active-active = both serve traffic; needs conflict rules. Global Tables = multi-region DynamoDB replication. Stateless Lambdas deploy in each region.

3. Vertical diagram

Users -> DNS policy -> regional API/Lambda -> replicated data -> runbookIdempotency keys across regions
Rehearse failover on a calendar
Region AAPI+Lambda+DDB Region BAPI+Lambda+DDB Route 53 / Global Accelerator / latency DNS Data: Global Tables / async replicate Failover runbook + health checks RPO/RTO explicit with product Active-active is a product decision
Multi-region is more than two stacks.

4. How: pattern table

How to do it (step by step)

PatternWhenHard part
Active-passiveDR / compliance cold-ishHealth check + data lag
Active-active readRead-heavy globalCache invalidation
Active-active writeRare; high barConflict resolution
Pilot lightCost-sensitive DRBring-up time vs RTO

5. Commands

List hosted zones (DNS inventory)

aws route53 list-hosted-zones --query 'HostedZones[].{N:Name,Id:Id}' --output table

Meaning: Know where failover records would live.

Describe a DynamoDB table stream/replica feel

aws dynamodb describe-table --region ap-south-1 --table-name Orders \
  --query 'Table.{S:TableStatus,R:Replicas,Stream:StreamSpecification}' 

Meaning: Check replicas if Global Tables in play.

Health check list

aws route53 list-health-checks --query 'HealthChecks[].{Id:Id,Type:HealthCheckConfig.Type}' --output table

Meaning: Empty list = no automated DNS failover yet.

Lambda same name other region?

aws lambda get-function --function-name checkout-api --region ap-southeast-1 2>&1 | head -5

Meaning: Confirm twin deploy exists before claiming DR.

6. Data and idempotency

  • Prefer append-only events with deterministic ids.
  • Global Tables: last-writer-wins — design for it.
  • Never assume sticky sessions across regions.
  • Secrets and parameters replicated or fetched per region.
  • Warm concurrency separately per region.

7. Industries

  • Fintech (Aisha, Lagos, NGN): active-passive with strict ledger replay.
  • Ecommerce (Rohan, Pune, INR): Global Tables for carts carefully; stock = hard.
  • Media (Kenji, Osaka, JPY): read replicas / regional caches for assets.
  • SaaS (Priya, Bengaluru, INR): tenant pin to home region + DR.
  • Travel (Mei, Singapore, SGD): latency-based routing for booking reads.

8. Lab

9. Lab - design on paper first

Do this in ap-south-1 (Mumbai) unless your org forbids it. Set a budget alert first.

How to do it (step by step)

  1. Write RPO and RTO in one sentence with product.
  2. List what must replicate vs rebuild.
  3. Sketch DNS failover + one health check target.
  4. Name the idempotency key for cross-region orders.

Cleanup (stop billing)

  1. Do not flip prod DNS in lab.
  2. Delete any lab health checks.

10. Same pattern across industries

  • Fintech (Aisha, Lagos): payment webhooks → SQS → Lambda; never block the bank callback thread.
  • Ecommerce (Rohan, Pune): checkout API on API Gateway+Lambda; inventory fan-out on SNS.
  • Healthcare (Mei, Singapore): appointment SMS via SNS; PHI stays in DynamoDB with fine-grained IAM.
  • EdTech (Diego, São Paulo): nightly cleanup EventBridge → Lambda on student drafts.
  • Logistics (Fatima, Casablanca): package scan events on EventBridge bus; Step Functions for customs saga.
  • Media (Kenji, Osaka): S3 upload → Lambda thumbnails; fan-out to moderation + CDN invalidate.
  • SaaS multi-tenant (Priya, Bengaluru): Cognito groups + DynamoDB partition per tenant.
  • Gov portal (Omar, Amman): strangler fig — peel one PDF form route per sprint to Lambda.

11. Troubleshooting checklist

  1. Confirm region (ap-south-1 vs us-east-1 for CloudFront/ACM quirks).
  2. Check CloudWatch Logs for the function name and request id.
  3. Verify IAM execution role allows the API you call.
  4. For async: check DLQ depth and SQS age of oldest message.
  5. For APIs: curl -v and compare status, CORS headers, body.
  6. For workflows: open Step Functions execution event history.
  7. Re-read the linked deep chapter before reinventing a service.
  8. If cost spikes: check concurrency, retries, and provisioned capacity.

12. Common errors and fixes

Each row is a real mistake students and juniors hit. Read the fix before you panic.

Error / symptomFix
Copied stack, forgot dataPlan replication or restore; test it.
Active-active stock double-sellSingle writer or strong conflict rules.
Health check on deep dependencyCheck the API users hit; avoid false failovers.
No runbookWrite and rehearse failover steps.
Secrets only in primaryReplicate or create per region.
Ignoring eventual consistencyUX and retries tolerate lag.
Same IAM role ARN assumptionsRoles are regional; pipelines deploy both.
Never tested failoverGame day quarterly.
RTO fantasyMeasure restore; set honest RTO.

13. FAQ

Q. Is multi-region required?

Only if product/compliance/latency demands — cost is real.

Q. Global Tables vs Streams+Lambda copy?

GT managed; custom = more control/complexity.

Q. What about Aurora Global?

Great for relational; different chapter — still need app failover.

Q. Pilot light vs warm standby?

Pilot = minimal; warm = almost ready — cost vs RTO.

Q. Link Route 53?

amazon-route-53-dns-routing-health-checks-and-failover-basics.

14. Interview Q&A (Beginner / Mid / Senior + MNC)

Q. Beginner: active-passive?

One region serves; other waits for failover.

Q. Beginner: RPO/RTO?

Data loss tolerance / time to recover.

Q. Mid: why idempotency multi-region?

Retries and failover can duplicate writes.

Q. Mid: health check design?

Check user-visible endpoint; sensible thresholds.

Q. Senior: conflict strategy?

LWW, CRDTs, or single-writer regions.

Q. MNC: evidence?

Game-day reports, RPO/RTO signed, DNS change tickets.

15. Tips in English, Marathi and Hindi

Ravindra Bagale's Tip (EN)

Agree RPO/RTO, pick data truth, automate DNS carefully, rehearse — then claim multi-region.

Ravindra Bagale's Tip (MR)

RPO/RTO, data truth, DNS, rehearse — मग multi-region claim.

Tip (HI)

RPO/RTO, data truth, DNS, rehearse — फिर multi-region claim।

Try at home

  1. Write RPO and RTO one-liners.
  2. List health checks in the account.

In short

  1. Start from a real story, then name the AWS services.
  2. Link existing chapters — do not copy their labs.
  3. Design for failure: retries, DLQ, idempotency, rollback.
  4. Measure before you buy provisioned concurrency or multi-region.

16. Architecture decision checklist

  1. Write the user journey in five bullets with no AWS names.
  2. Mark each step sync (user waits) or async.
  3. Name failure mode: retry, DLQ, compensate, or alert-only.
  4. Name the idempotency key for every write.
  5. Pick data store from access patterns (link DynamoDB modeling).
  6. Estimate monthly cost at 1x and 10x traffic (USD and INR).
  7. Confirm account concurrency and service quotas in ap-south-1.
  8. Decide auth: Cognito, IAM, Lambda authorizer, or none.
  9. Name on-call and which CloudWatch alarm pages them.
  10. Link the deep chapter you will not rewrite.
  11. Only then open console or IaC.

17. Copy-paste quick commands (read-only first)

# Region and identity
aws configure get region
aws sts get-caller-identity

# Lambda landscape
aws lambda list-functions --region ap-south-1 --max-items 20 \
  --query 'Functions[].{N:FunctionName,R:Runtime,T:Timeout,M:MemorySize}' --output table
aws lambda get-account-settings --region ap-south-1

# API Gateway (HTTP APIs)
aws apigatewayv2 get-apis --region ap-south-1 --query 'Items[].{N:Name,Id:ApiId,Ep:ProtocolType}' --output table

# Queues and topics
aws sqs list-queues --region ap-south-1
aws sns list-topics --region ap-south-1 --query 'Topics[].TopicArn'

# Event buses and state machines
aws events list-event-buses --region ap-south-1
aws stepfunctions list-state-machines --region ap-south-1 --query 'stateMachines[].name'

# DynamoDB tables (names only)
aws dynamodb list-tables --region ap-south-1

Run these in a sandbox account. Prefer read-only IAM while learning.

18. More industry and stack stories

  • Fintech (Aisha, Lagos, NGN): bank webhooks must return 200 fast — SQS absorbs spikes; ledger Lambda is idempotent on paymentId.
  • Ecommerce (Rohan, Pune, INR): Black Friday — API Gateway throttle + SQS order intake; SNS fans inventory, email, analytics.
  • Healthcare (Mei, Singapore, SGD): appointment reminders via SNS SMS; PHI only in DynamoDB with condition keys.
  • EdTech (Diego, São Paulo, BRL): EventBridge nightly cleanup of draft quizzes; Lambda timeout 30s, not 15 min.
  • Logistics (Fatima, Casablanca, MAD): package scans on custom EventBridge bus; Step Functions customs saga.
  • Media (Kenji, Osaka, JPY): S3 → Lambda thumbnails; never write thumbs to the watched prefix.
  • SaaS (Priya, Bengaluru, INR): Cognito groups + DynamoDB PK tenantId; one Lambda authorizer for all routes.
  • Gov (Omar, Amman, JOD): strangler — peel one PDF form route per sprint from the monolith.
  • Startup (Sofia, Sofia, EUR): start with Function URL for demos; move to HTTP API when partners need JWT.
  • Retail (Luis, Mexico City, MXN): store POS sync via SQS FIFO when order matters; Standard when it does not.
  • Python: handlers thin; put domain logic in plain modules for unit tests without Lambda.
  • Node: prefer async/await; never block the event loop on sync DNS.
  • Java: SnapStart for cold starts; keep dependencies lean.
  • .NET: AspNetCoreServer for low-traffic tenants; watch package size.
  • Go: single static binary; great for SQS workers.
  • PHP: keep Laravel queues on ECS; Lambda for S3/webhooks glue.

19. Glossary (short)

TermMeaning
Cold startFirst invoke pays init; later invokes reuse the env
IdempotencySame request twice → same effect
DLQDead-letter queue for failed messages
ChoreographyServices react to events; no central conductor
OrchestrationCentral workflow (Step Functions) directs steps
Fan-outOne event → many consumers
Fan-inMany branches join before next step
Strangler figPeel routes from monolith gradually
SagaDistributed tx via steps + compensations
Provisioned concurrencyKeep N envs warm; you pay for ready capacity

20. Practice: explain out loud

  1. 60 seconds: everyday story for multi-region serverless.
  2. 60 seconds: sync vs async with a checkout example.
  3. 60 seconds: when you refuse Lambda.
  4. 60 seconds: DLQ + idempotency in one breath.
  5. Record once; cut fillers; record again.

21. Safe lab hygiene

  • Tag every lab resource with owner and expiry date.
  • Set a monthly AWS Budget alarm in INR or USD before experiments.
  • Prefer read-only commands first; mutate in a sandbox account.
  • Delete queues, APIs, tables you created — DynamoDB and APIGW leave footprints.
  • Never put production secrets in env vars or screenshots.
  • Do not enable provisioned concurrency for a hello-world.

23. Myths to drop

MythReality
Serverless means zero serversServers exist; you do not manage them
Always cheaper than EC2Steady high load can favor EC2/Savings Plans
No Ops neededYou own IAM, data, alarms, cost, incidents
One Lambda per app is fineBounded contexts scale better
Queues are optional decorationQueues are the load leveler and blast-radius wall

24. Error budget thinking for serverless

If your monthly error budget is 0.1% on checkout, a fan-out that retries aggressively can burn the budget with duplicate emails while money stays correct. Separate business correctness SLOs from notification SLOs.

  1. Write two SLOs: money-correct and notify-delivered.
  2. Retries on money path: bounded + idempotent.
  3. Retries on notify path: best-effort + DLQ.
  4. Page humans on money DLQ; ticket on notify DLQ.

25. Regional notes (ap-south-1)

  • Build labs in Mumbai (ap-south-1) unless your org mandates elsewhere.
  • Some services launch first in us-east-1 — check feature availability.
  • Data residency for INR fintech may require in-region only.
  • Latency to end users in India usually favors ap-south-1.

26. Naming conventions that save incidents

# Suggested prefixes
# Lambda:  pay-intake-prod, pay-worker-prod
# SQS:     pay-orders.fifo / pay-orders-dlq
# SNS:     pay-order-events
# EB bus:  pay.domain
# SFN:     pay-refund-saga
# DDB:     pay-orders-prod

Include env (dev/stage/prod) and domain. Future you grepping CloudWatch will thank present you.

27. Pre-mortems (ten minutes)

  1. Imagine tomorrow headline: double charge in AED. What broke?
  2. Imagine DLQ depth 50,000 after a bad deploy. How do you drain?
  3. Imagine Cognito outage. Do APIs fail closed or serve read-only?
  4. Write answers in the runbook before go-live.

28. Currency and locale in examples

Rotate currencies in designs: INR, USD, EUR, AED, NGN, BRL, JPY, SGD. Rotate names: Aisha, Rohan, Mei, Diego, Fatima, Kenji, Priya, Omar, Sofia, Luis. This keeps mental models global — not one-country samples.

29. Worked story: SEA latency + Mumbai primary

  1. Product sets RPO 5 min, RTO 30 min.
  2. Active-passive ap-southeast-1 with GT for read models.
  3. Route 53 failover + health on /healthz.
  4. Game day: promote, redrive, postmortem.

30. Anti-patterns

  • Two regions writing stock without rules.
  • Failover never rehearsed.
  • Copying prod data to DR without encryption/access review.

Revision, interview and comparison cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Revision card: Agree RPO/RTO first. Copying stacks twice is not a DR story. RPO = data loss tolerance; RTO = time to recover — product signs both. Pick active-passive or active-active; design data conflicts explicitly. Rohan writes RPO 5 min / RTO 30 min before touching Route 53.
Revision card: Agree RPO/RTO first · Download PNG · Open card page
Revision card: Rehearse failover. Paper runbooks fail on game day. Health checks on user-visible /healthz; DNS failover with sane thresholds. Idempotency keys stop double-sell across regions. Quarterly game day: promote, redrive, postmortem.
Revision card: Rehearse failover · Download PNG · Open card page
Comparison: Active-passive vs Active-active writes. Active-passive: Primary serves; standby for failover. Active-active writes: Both regions accept writes; need conflict rules.
Comparison: Active-passive vs Active-active writes · Download PNG · Open card page
Comparison: Copy stacks only vs Stacks + data plan. Copy stacks only: Deploy twin Lambdas; forget data. Stacks + data plan: Replication/restore tested against RPO/RTO.
Comparison: Copy stacks only vs Stacks + data plan · Download PNG · Open card page
Interview card: Active-passive?. One region serves; standby waits for failover. Simpler than active-active writes; watch replica lag vs RPO. MNC: last successful failover drill date?
Interview card: Active-passive? · Download PNG · Open card page
Interview card: Global Tables?. Managed multi-region DynamoDB replication with LWW caveats. Design for last-writer-wins; do not dual-write stock blindly. MNC: conflict example you accept?
Interview card: Global Tables? · Download PNG · Open card page
Interview card: Health check design?. Hit the API users hit; avoid flapping on deep deps. Thresholds + enough healthy hosts before failback. MNC: false failover incident?
Interview card: Health check design? · Download PNG · Open card page
Interview card: Why cross-region idempotency?. Retries and failover can duplicate writes. Deterministic ids on orders/payments across regions. MNC: show the key fields.
Interview card: Why cross-region idempotency? · Download PNG · Open card page

More cards: Ravi Sir's Cards.

Practice Tasks

About this scenario

Amravati Agro Market is a agriculture business in Amravati. Anjali Thakre looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 16

Easy RPO data loss — 1

Why: Idea.

What to do: Enter 1 if RPO is how much data loss you tolerate.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy RTO recover time — 1

Why: Idea.

What to do: Enter 1 if RTO is time to recover service.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Active-passive — 1

Why: Idea.

What to do: Enter 1 if active-passive means one region serves.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy AA writes hard — 1

Why: Idea.

What to do: Enter 1 if active-active writes need conflict rules.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Global Tables — 1

Why: Idea.

What to do: Enter 1 if DynamoDB Global Tables replicate multi-region.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Route53 failover — 1

Why: Idea.

What to do: Enter 1 if Route 53 can fail over with health checks.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy LWW caveat — 1

Why: Idea.

What to do: Enter 1 if Global Tables last-writer-wins needs design care.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Health user-facing — 1

Why: Idea.

What to do: Enter 1 if DNS health checks should hit user-visible endpoints.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Idempotency cross-region — 1

Why: Idea.

What to do: Enter 1 if cross-region retries need idempotency keys.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Data plan required — 1

Why: Idea.

What to do: Enter 1 if copying Lambdas without a data plan fails DR.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Game day — 1

Why: Idea.

What to do: Enter 1 if failover must be rehearsed on a game day.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium Pilot light — 1

Why: Idea.

What to do: Enter 1 if pilot light trades cost for longer bring-up.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Medium RPO RTO lines

Why: Agree.

What to do: YAML: rpo_minutes: 5 and rto_minutes: 30.

How:
  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.

Medium List hosted zones

Why: DNS inventory.

What to do: List Route 53 hosted zones

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard No dual stock writers — 1

Why: Idea.

What to do: Enter 1 if dual unconstrained stock writers risk double-sell.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard Secrets per region — 1

Why: Idea.

What to do: Enter 1 if secrets must exist or replicate per region.

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.