Event-Driven Serverless: Choreography vs Orchestration Explained
At a wedding, either every relative reacts when they hear the dhol (choreography), or one stage manager cues each act (orchestration). Event-driven serverless uses both. This chapter helps you pick: EventBridge/SNS reactions vs Step Functions as the conductor — and how to avoid spaghetti events.
What you'll learn in this chapter
- Explain choreography vs orchestration with a wedding story
- Place EventBridge/SNS vs Step Functions on a decision table
- Spot spaghetti events and missing ownership
- Design one order-flow both ways on paper
- Link EventBridge and Step Functions chapters
1. Everyday example: wedding cues
When the dhol starts, the photographer shoots, the caterer plates, the DJ fades talk music — nobody waits for a central WhatsApp from the host for each micro-step. That is choreography. When the host needs the pheras exactly after the vows, a stage manager sequences it. That is orchestration. Diego in São Paulo models order-paid the same way: inventory and email can react to an event; refund+stock rollback wants a visible workflow.
Deep service chapters: EventBridge, Step Functions, SQS/SNS. This page is the decision layer.
2. Why the distinction matters
Why do we need this?
If everything is choreography, nobody sees the whole story when a step fails at 2 AM. If everything is orchestration, every small notification becomes a state machine you hate to change. Grown systems mix both.
What is it?
Choreography: producers emit events; consumers subscribe; no central brain. Orchestration: a workflow engine tells each step when to run and what to do on failure.
3. Vertical comparison
4. Decision table
| Question | Prefer choreography | Prefer orchestration |
|---|---|---|
| Many independent reactions? | Yes — SNS/EventBridge | No |
| Need one visible timeline? | Maybe not | Yes — Step Functions |
| Need compensations / saga? | Hard — invent correlation | Built-in patterns |
| Team owns one small side effect? | Subscribe and go | Central team owns flow |
| Audit for regulators? | Need good log design | Execution history helps |
5. How to design an order-paid flow both ways
How to do it (step by step)
Choreography sketch
- Order service emits OrderPaid on EventBridge bus.
- Inventory rule → Lambda reserve stock.
- Email rule → Lambda send receipt (INR/BRL).
- Analytics rule → firehose/Lambda.
- Each consumer owns retries + DLQ.
Orchestration sketch
- API returns 202 and StartExecution on state machine.
- Task ReserveStock → Task Charge → Task Email.
- Catch on Charge → Task ReleaseStock.
- One execution ARN in support tickets.
List event buses
aws events list-event-buses --region ap-south-1
Meaning: Default bus always exists; custom buses isolate domains.
List state machines
aws stepfunctions list-state-machines --region ap-south-1 --query 'stateMachines[].{N:name,A:stateMachineArn}'
Meaning: See what orchestrations already exist before adding another.
6. Spaghetti events — symptoms and fixes
| Symptom | Fix |
|---|---|
| Everyone listens to almost every event | Event storms |
| No owner for an event schema | No owner |
| Silent fail in one consumer | Silent fail |
| Circular events A→B→A | Cycles |
| Cannot answer where is my order | Where is order? |
7. Worked mini-examples
Python: choose mode
def mode(needs_saga, many_side_effects, need_timeline):
if needs_saga or need_timeline:
return "orchestrate"
if many_side_effects:
return "choreograph"
return "either"
print(mode(True, True, False))
print(mode(False, True, False))
Output: orchestrate / choreograph. Meaning: saga/timeline push you to Step Functions.
EventBridge rule shape (concept)
{
"source": ["shop.orders"],
"detail-type": ["OrderPaid"],
"detail": {"currency": ["INR", "BRL"]}
}
Meaning: filter early so the inventory Lambda never wakes for EUR-only analytics noise.
8. Lab: paper both designs + read-only console
Do this in ap-south-1 (Mumbai) unless your org forbids it. Set a budget alert first.
How to do it (step by step)
- Draw choreography for OrderPaid with three consumers.
- Draw orchestration with one compensation.
- Console: EventBridge rules count (read-only).
- Console: one state machine definition preview if any.
- Write which design you pick for refunds and why.
Cleanup (stop billing)
- No creates required; delete any bus/rule you added.
- Delete lab state machines.
9. Hybrid: the usual adult answer
Orchestrate the money path (pay, reserve, refund). Choreograph the fan-out notifications (email, push, analytics). Fatima in Casablanca does exactly that for customs: saga in Step Functions, notifications on a bus.
10. Per-concept commands
Put a sample event (sandbox)
aws events put-events --region ap-south-1 --entries '[{
"Source":"shop.orders","DetailType":"OrderPaid",
"Detail":"{"orderId":"o-1","currency":"INR"}"}]'
Meaning: Only in sandbox; watch which rules fire.
Describe a state machine
aws stepfunctions describe-state-machine --state-machine-arn $ARN --region ap-south-1 --query 'definition' --output text | head
Meaning: Read definition before changing.
11. 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.
12. Troubleshooting checklist
- Confirm region (ap-south-1 vs us-east-1 for CloudFront/ACM quirks).
- Check CloudWatch Logs for the function name and request id.
- Verify IAM execution role allows the API you call.
- For async: check DLQ depth and SQS age of oldest message.
- For APIs: curl -v and compare status, CORS headers, body.
- For workflows: open Step Functions execution event history.
- Re-read the linked deep chapter before reinventing a service.
- If cost spikes: check concurrency, retries, and provisioned capacity.
13. Common errors and fixes
Each row is a real mistake students and juniors hit. Read the fix before you panic.
| Error / symptom | Fix |
|---|---|
| All notifications as SFN states | Emit event; let email subscribe. |
| No DLQ on EventBridge targets | Add SQS DLQ per target. |
| Unversioned event payloads | Add version field; consumers tolerate. |
| Circular event storm | Break with orchestration or redesign. |
| Using SNS when you need content filters + buses | Prefer EventBridge for rich filters. |
| Mega state machine for everything | Split by domain. |
| Ignoring execution history costs | Log levels; short retention where OK. |
| No correlation id in choreography | Pass orderId everywhere. |
| Assuming at-least-once never duplicates | Idempotent consumers. |
| Editing prod rules without dry-run | Stage bus first. |
14. FAQ
Q. Is EventBridge better than SNS?
Different: EB has rich filters/buses/archive; SNS is simple fan-out/SMS.
Q. Is Step Functions expensive?
Pay per transition; fine for business flows; not for millions of tiny ticks.
Q. Can I mix both?
Yes — normal.
Q. What about SQS?
Buffer between; works under both styles.
Q. Where is the order workflow project?
build-order-workflow — orchestration example.
Q. Choreography testing?
Contract tests per consumer + replay from archive.
15. Interview Q&A (Beginner / Mid / Senior + MNC)
Q. Beginner: choreography in one line?
Services react to events without a central conductor.
Q. Beginner: orchestration?
A workflow engine sequences steps.
Q. Mid: when SFN over EB?
Saga, compensations, single timeline.
Q. Mid: DLQ ownership?
Each target owns its DLQ and alarm.
Q. Senior: prevent event spaghetti?
Schema ownership, versioning, filters, domain buses.
Q. MNC: audit story?
SFN history for money path; immutable logs for choreography side effects.
16. Tips in English, Marathi and Hindi
Ravindra Bagale's Tip (EN)
Orchestrate money; choreograph noise. Draw both before you pick.
Ravindra Bagale's Tip (MR)
Money = orchestrate; noise = choreograph. दोन्ही कागदावर.
Tip (HI)
पैसे orchestrate करें; notify choreograph करें। दोनों कागज़ पर बनाएं।
Try at home
- Pick one flow at work; label orchestrate vs choreograph.
- Name the event owner team.
In short
- Start from a real story, then name the AWS services.
- Link existing chapters — do not copy their labs.
- Design for failure: retries, DLQ, idempotency, rollback.
- Measure before you buy provisioned concurrency or multi-region.
17. Correlation and causation ids
In choreography, every event should carry orderId (correlation) and a unique eventId (causation chain). Support engineers paste one id and reconstruct the story across logs.
{"eventId":"e-9f","orderId":"o-1","type":"OrderPaid","currency":"AED","version":1}
18. When to introduce a custom bus
- Domain isolation: payments vs marketing.
- Different archive/replay policies.
- Least-privilege put-events per team.
19. Step Functions patterns cheat sheet
| Pattern | Use |
|---|---|
| Task + Retry + Catch | Most Lambda tasks |
| Parallel | Fan-out inside orchestration |
| Map | Process array with capped concurrency |
| Wait | Callbacks, human delay, SLA pause |
| Choice | Branch on currency or risk score |
20. Architecture decision checklist
- Write the user journey in five bullets with no AWS names.
- Mark each step sync (user waits) or async.
- Name failure mode: retry, DLQ, compensate, or alert-only.
- Name the idempotency key for every write.
- Pick data store from access patterns (link DynamoDB modeling).
- Estimate monthly cost at 1x and 10x traffic (USD and INR).
- Confirm account concurrency and service quotas in ap-south-1.
- Decide auth: Cognito, IAM, Lambda authorizer, or none.
- Name on-call and which CloudWatch alarm pages them.
- Link the deep chapter you will not rewrite.
- Only then open console or IaC.
21. 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.
22. 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.
23. Glossary (short)
| Term | Meaning |
|---|---|
| Cold start | First invoke pays init; later invokes reuse the env |
| Idempotency | Same request twice → same effect |
| DLQ | Dead-letter queue for failed messages |
| Choreography | Services react to events; no central conductor |
| Orchestration | Central workflow (Step Functions) directs steps |
| Fan-out | One event → many consumers |
| Fan-in | Many branches join before next step |
| Strangler fig | Peel routes from monolith gradually |
| Saga | Distributed tx via steps + compensations |
| Provisioned concurrency | Keep N envs warm; you pay for ready capacity |
24. Practice: explain out loud
- 60 seconds: everyday story for choreography vs orchestration.
- 60 seconds: sync vs async with a checkout example.
- 60 seconds: when you refuse Lambda.
- 60 seconds: DLQ + idempotency in one breath.
- Record once; cut fillers; record again.
25. 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.
26. How this chapter links others
- Compute depth: Lambda.
- HTTP edge: API Gateway.
- Data modeling: DynamoDB.
- Messaging: SQS/SNS.
- Events: EventBridge.
- Workflows: Step Functions.
- Project chapters (build-*): worked assemblies — link, do not paste.
27. Myths to drop
| Myth | Reality |
|---|---|
| Serverless means zero servers | Servers exist; you do not manage them |
| Always cheaper than EC2 | Steady high load can favor EC2/Savings Plans |
| No Ops needed | You own IAM, data, alarms, cost, incidents |
| One Lambda per app is fine | Bounded contexts scale better |
| Queues are optional decoration | Queues are the load leveler and blast-radius wall |
28. 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.
- Write two SLOs: money-correct and notify-delivered.
- Retries on money path: bounded + idempotent.
- Retries on notify path: best-effort + DLQ.
- Page humans on money DLQ; ticket on notify DLQ.
29. 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.
30. 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.
31. Pre-mortems (ten minutes)
- Imagine tomorrow headline: double charge in AED. What broke?
- Imagine DLQ depth 50,000 after a bad deploy. How do you drain?
- Imagine Cognito outage. Do APIs fail closed or serve read-only?
- Write answers in the runbook before go-live.
32. 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.
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.








More cards: Ravi Sir's Cards.
Practice Tasks
London Legal LLP is a law business in London. Oliver Hughes looks after its IT and cloud work. They count money in GBP and run their AWS resources in the eu-west-2 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 Choreography no conductor — 1
Why: Style.
What to do: Enter 1 if choreography means services react without a central conductor.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Orchestration has engine — 1
Why: Style.
What to do: Enter 1 if orchestration uses a workflow engine to sequence steps.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Refund saga → SFN — 1
Why: Fit.
What to do: Enter 1 if a refund saga with compensations fits Step Functions.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Side effects choreography — 1
Why: Fit.
What to do: Enter 1 if fan-out email/analytics side effects often fit choreography.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy List EventBridge rules
Why: CLI.
What to do: List rules on default bus
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Styles YAML
Why: Map.
What to do: YAML: choreography: bus, orchestration: sfn.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.
Easy Filters reduce noise — 1
Why: Hygiene.
What to do: Enter 1 if event filters reduce unnecessary invocations.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Spaghetti everyone listens — 1
Why: Smell.
What to do: Enter 1 if spaghetti events mean everyone listens to almost every event.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium EventBridge filters — 1
Why: Tool.
What to do: Enter 1 if EventBridge offers richer filters, buses, archive/replay than basic SNS.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Correlation id — 1
Why: Trace.
What to do: Enter 1 if a correlation id helps reconstruct a story across consumers.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Break A→B→A — 1
Why: Anti.
What to do: Enter 1 if circular A→B→A events should be broken by redesign or orchestration.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Hybrid YAML
Why: Split.
What to do: YAML: money: sfn, notify: bus.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.
Hard Hybrid money vs notify — 1
Why: Adult.
What to do: Enter 1 if you orchestrate money path and choreograph notifications.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Each target owns DLQ — 1
Why: Ops.
What to do: Enter 1 if each EventBridge target should own its DLQ and alarm.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Schema ownership — 1
Why: Contract.
What to do: Enter 1 if event schemas need clear owners.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Delete lab same day — 1
Why: Hygiene.
What to do: Enter 1 if lab-spc-events should be deleted same day.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.