Event-Driven Serverless: Choreography vs Orchestration सोप्या भाषेत
लग्नात सगळे ढोल ऐकून प्रतिक्रिया देतात (choreography) किंवा एक stage manager cue देतो (orchestration). Serverless दोन्ही वापरतो. EventBridge/SNS vs Step Functions — spaghetti events टाळा.
या chapter मध्ये तुम्ही काय शिकाल
- Wedding story
- EB/SNS vs SFN
- Spaghetti events
- Order-flow both ways
- Link EB + SFN
1. रोजचे उदाहरण: लग्नाचे cues
ढोल = choreography. Pheras sequence = orchestration. Diego (São Paulo) order-paid: inventory/email react; refund saga = workflow.
Deep chapters: EventBridge, Step Functions, SQS/SNS.
2. फरक का महत्त्वाचा
हे का लागतं?
सगळं choreography = 2 AM गोंधळ. सगळं orchestration = प्रत्येक notify = state machine. Mix.
हे काय आहे?
Choreography: events + subscribers. Orchestration: workflow engine.
3. Vertical comparison
4. Decision table
| प्रश्न | Choreography | Orchestration |
|---|---|---|
| Independent reactions? | SNS/EB | No |
| Visible timeline? | Maybe not | SFN |
| Saga? | Hard | Built-in |
| Small side effect? | Subscribe | Central |
| Audit? | Logs | History |
5. Order-paid दोन्ही मार्गांनी
कसं करायचं (step by step)
Choreography sketch
- OrderPaid event.
- Inventory consumer.
- Email consumer.
- Analytics.
- Per-consumer DLQ.
Orchestration sketch
- StartExecution.
- Tasks.
- Compensate.
- Support ARN.
Event buses
aws events list-event-buses --region ap-south-1
अर्थ: Default bus; custom = isolate.
State machines
aws stepfunctions list-state-machines --region ap-south-1 --query 'stateMachines[].{N:name,A:stateMachineArn}'
अर्थ: Existing SFN बघा.
6. Spaghetti events
| लक्षण | Fix |
|---|---|
| Filter rules; smaller event types | Filters |
| Schema registry / version field + owning team | Owner+version |
| DLQ + alarm per target | DLQ |
| Architecture review; break with orchestration | Break cycles |
| Correlation ids or move to SFN | Correlation/SFN |
7. Mini-examples
Python choose
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. अर्थ: saga/timeline → SFN.
Rule shape
{
"source": ["shop.orders"],
"detail-type": ["OrderPaid"],
"detail": {"currency": ["INR", "BRL"]}
}
अर्थ: early filter = कमी noise.
8. Lab: दोन्ही designs
Org block नसेल तर ap-south-1 (Mumbai). आधी budget alert.
कसं करायचं (step by step)
- Choreography draw.
- Orchestration + compensate.
- Rules count.
- SFN preview.
- Refunds choice.
Cleanup (billing थांबवा)
- Cleanup if created.
- SFN delete.
9. Hybrid
Money path = orchestrate. Notify = choreograph. Fatima (Casablanca) तसेच.
10. Commands
Put events
aws events put-events --region ap-south-1 --entries '[{
"Source":"shop.orders","DetailType":"OrderPaid",
"Detail":"{"orderId":"o-1","currency":"INR"}"}]'
अर्थ: Sandbox only.
Describe SFN
aws stepfunctions describe-state-machine --state-machine-arn $ARN --region ap-south-1 --query 'definition' --output text | head
अर्थ: Change आधी definition.
11. एकाच pattern — वेगवेगळ्या industries
- Fintech (Aisha, Lagos): payment webhooks → SQS → Lambda.
- Ecommerce (Rohan, Pune): checkout API; inventory SNS fan-out.
- Healthcare (Mei, Singapore): SNS SMS; PHI + fine-grained IAM.
- EdTech (Diego, São Paulo): EventBridge nightly cleanup.
- Logistics (Fatima, Casablanca): EventBridge + saga.
- Media (Kenji, Osaka): S3 → Lambda thumbs + fan-out.
- SaaS (Priya, Bengaluru): Cognito + per-tenant partition.
- Gov (Omar, Amman): strangler fig per form route.
12. Troubleshooting checklist
- Region confirm करा.
- CloudWatch Logs + request id.
- Execution role permissions.
- DLQ + oldest message age.
- curl -v + CORS.
- SFN event history.
- Linked chapter पुन्हा वाचा.
- Cost: concurrency/retries.
13. सामान्य errors आणि fixes
प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.
| Error / लक्षण | Fix |
|---|---|
| Notify as SFN | Choreograph notify. |
| No DLQ | DLQ. |
| No version | version field. |
| Circular | Break. |
| SNS vs EB | EB filters. |
| Mega SFN | Split. |
| History cost | Retention. |
| No correlation | orderId. |
| Duplicates | Idempotent. |
| Edit prod rules | Stage bus. |
14. FAQ
प्र. EB vs SNS?
Filters vs simple.
प्र. SFN cost?
Per transition.
प्र. Mix?
हो.
प्र. SQS?
Buffer.
प्र. Order workflow?
build-order-workflow.
प्र. Test choreography?
Contracts+replay.
15. Interview Q&A (Beginner / Mid / Senior + MNC)
प्र. Beginner choreography
Events, no conductor.
प्र. Orchestration
Workflow engine.
प्र. Mid SFN
Saga/timeline.
प्र. DLQ
Per target.
प्र. Senior spaghetti
Ownership+version.
प्र. MNC audit
SFN+logs.
16. Tips — English, मराठी आणि हिंदी
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 करें। दोनों कागज़ पर बनाएं।
घरी करून बघा
- Work flow label.
- Event owner.
थोडक्यात सांगायचं तर
- गोष्टी पासून सुरू, मग services.
- Existing chapters link — labs copy नको.
- Failure साठी design.
- Measure → मग पैसे.
17. Correlation ids
प्रत्येक event: orderId + eventId. Support एक id paste करून story.
{"eventId":"e-9f","orderId":"o-1","type":"OrderPaid","currency":"AED","version":1}
18. Custom bus कधी
- Domain isolation.
- Archive policy.
- IAM per team.
19. SFN cheat sheet
| Pattern | Use |
|---|---|
| Task+Retry+Catch | Lambda tasks |
| Parallel | Fan-out in SFN |
| Map | Array + cap |
| Wait | Wait/callback |
| Choice | Branch |
20. Architecture decision checklist
- User journey 5 bullets, no AWS names.
- Sync vs async mark.
- Failure mode.
- Idempotency key.
- Data from access patterns.
- Cost 1x and 10x.
- Quotas ap-south-1.
- Auth decision.
- On-call + alarm.
- Deep chapter link.
- मग console/IaC.
21. Copy-paste quick commands
# 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
Sandbox + read-only IAM.
22. अजून industry आणि stack stories
- Fintech Lagos: webhook → SQS → idempotent ledger.
- Ecommerce Pune: throttle + fan-out.
- Healthcare SG: SNS + PHI IAM.
- EdTech: EventBridge cleanup.
- Logistics: bus + saga.
- Media: avoid recursive S3.
- SaaS: tenant partition.
- Gov: strangler peel.
- Startup: Function URL → HTTP API.
- Retail: FIFO vs Standard.
- Python: thin handlers.
- Node: async/await.
- Java: SnapStart.
- .NET: package size.
- Go: static binary.
- PHP: hybrid.
23. Glossary
| Term | अर्थ |
|---|---|
| Cold start | पहिल्या invoke ची init |
| Idempotency | दोनदा = तोच effect |
| DLQ | Fail झालेले messages |
| Choreography | Events; conductor नाही |
| Orchestration | SFN central |
| Fan-out | एक → अनेक |
| Fan-in | अनेक → join |
| Strangler fig | Monolith peel |
| Saga | Steps + compensate |
| Provisioned concurrency | Warm N; pay |
24. Practice: मोठ्याने explain
- 60s: choreography vs orchestration गोष्ट.
- 60s: sync vs async checkout.
- 60s: Lambda नको कधी.
- 60s: DLQ + idempotency.
- Record ×2.
25. Safe lab hygiene
- Tag owner+expiry.
- Budget alarm आधी.
- Read-only first.
- Cleanup.
- No secrets in env/screenshots.
- No provisioned on hello.
26. या chapter च्या links
- Compute: Lambda.
- HTTP: API Gateway.
- Data: DynamoDB.
- Messaging: SQS/SNS.
- Events: EventBridge.
- Workflows: Step Functions.
- build-* projects link.
27. Myths
| Myth | खरं |
|---|---|
| Servers नाहीत | Servers आहेत; manage नको |
| नेहमी स्वस्त | Steady वर EC2 |
| No Ops | IAM/data/alarms |
| एक Lambda | Bounded contexts |
| Queues optional | Load leveler |
28. Serverless error budget
Checkout error budget 0.1% असेल तर aggressive retries email duplicates देऊन budget जाळू शकतात. Money SLO ≠ notify SLO.
- दोन SLOs.
- Money retries bounded.
- Notify best-effort.
- Money page; notify ticket.
29. Regional notes (ap-south-1)
- Labs Mumbai.
- Feature availability.
- Data residency.
- Latency India.
30. Naming conventions
# 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
env + domain नावात ठेवा. CloudWatch grep सोपा.
31. Pre-mortems
- Double charge headline.
- DLQ drain plan.
- Cognito outage mode.
- Runbook.
32. Currency / locale
Currencies आणि names rotate करा — global mental model.
उजळणी, मुलाखत आणि तुलना cards
हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.








अजून cards: Ravi Sir's Cards.
सराव Tasks
London Legal LLP हा लंडन मधला कायदा सेवा व्यवसाय आहे. Oliver Hughes त्यांचं IT व cloud काम पाहतात. त्यांचे पैसे GBP मध्ये मोजले जातात आणि AWS resources eu-west-2 Region मध्ये चालतात. खालच्या tasks मध्ये तुम्ही या lesson मध्ये शिकलेलं वापरून त्यांची खरी कामं करता. सगळी नावं, account IDs, IP addresses व numbers सरावासाठी काल्पनिक आहेत.
0 / 16
सोपं Choreo
का: Style.
काय करायचं: No conductor तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Orch
का: Style.
काय करायचं: Workflow engine तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Saga
का: Fit.
काय करायचं: SFN saga तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं Side
का: Fit.
काय करायचं: Choreo side effects तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
सोपं List-rules
का: CLI.
काय करायचं: list.
- Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
- aws लिहा, मग service चं नाव, मग operation (action शब्द).
- प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
- Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.
सोपं Styles
का: Map.
काय करायचं: choreography/orchestration.
- Task मधल्या top-level keys पासून सुरू करा.
- Child keys 2 spaces ने indent करा (tabs नकोत).
- प्रत्येक property मध्ये task मधली value भरा.
- Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.
सोपं Filter
का: Hygiene.
काय करायचं: Filters तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Spaghetti
का: Smell.
काय करायचं: Everyone listens तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम EB
का: Tool.
काय करायचं: EB filters तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Corr
का: Trace.
काय करायचं: Correlation तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Cycle
का: Anti.
काय करायचं: Break cycle तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
मध्यम Hybrid
का: Split.
काय करायचं: money/notify.
- Task मधल्या top-level keys पासून सुरू करा.
- Child keys 2 spaces ने indent करा (tabs नकोत).
- प्रत्येक property मध्ये task मधली value भरा.
- Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.
अवघड Hybrid
का: Adult.
काय करायचं: Money SFN notify bus तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
अवघड DLQ
का: Ops.
काय करायचं: Own DLQ तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
अवघड Schema
का: Contract.
काय करायचं: Schema owner तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.
अवघड Lab
का: Hygiene.
काय करायचं: Delete lab तर 1.
- Task मधले numbers लिहून घ्या.
- कागदावर step by step काढा.
- Box मध्ये फक्त final उत्तर लिहा.
- Check answer दाबा.