Ravindra BagaleCourses & study guides English Track your progress

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

Event -> Bus/Topic -> Many consumersChoreography
एक execution id नाही
Start -> SFN -> Task -> Task -> Endएक execution ARN
History मध्ये compensate

4. Decision table

प्रश्नChoreographyOrchestration
Independent reactions?SNS/EBNo
Visible timeline?Maybe notSFN
Saga?HardBuilt-in
Small side effect?SubscribeCentral
Audit?LogsHistory

5. Order-paid दोन्ही मार्गांनी

कसं करायचं (step by step)

Choreography sketch

  1. OrderPaid event.
  2. Inventory consumer.
  3. Email consumer.
  4. Analytics.
  5. Per-consumer DLQ.

Orchestration sketch

  1. StartExecution.
  2. Tasks.
  3. Compensate.
  4. 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 typesFilters
Schema registry / version field + owning teamOwner+version
DLQ + alarm per targetDLQ
Architecture review; break with orchestrationBreak cycles
Correlation ids or move to SFNCorrelation/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)

  1. Choreography draw.
  2. Orchestration + compensate.
  3. Rules count.
  4. SFN preview.
  5. Refunds choice.

Cleanup (billing थांबवा)

  1. Cleanup if created.
  2. 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

  1. Region confirm करा.
  2. CloudWatch Logs + request id.
  3. Execution role permissions.
  4. DLQ + oldest message age.
  5. curl -v + CORS.
  6. SFN event history.
  7. Linked chapter पुन्हा वाचा.
  8. Cost: concurrency/retries.

13. सामान्य errors आणि fixes

प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.

Error / लक्षणFix
Notify as SFNChoreograph notify.
No DLQDLQ.
No versionversion field.
CircularBreak.
SNS vs EBEB filters.
Mega SFNSplit.
History costRetention.
No correlationorderId.
DuplicatesIdempotent.
Edit prod rulesStage 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 करें। दोनों कागज़ पर बनाएं।

घरी करून बघा

  1. Work flow label.
  2. Event owner.

थोडक्यात सांगायचं तर

  1. गोष्टी पासून सुरू, मग services.
  2. Existing chapters link — labs copy नको.
  3. Failure साठी design.
  4. 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

PatternUse
Task+Retry+CatchLambda tasks
ParallelFan-out in SFN
MapArray + cap
WaitWait/callback
ChoiceBranch

20. Architecture decision checklist

  1. User journey 5 bullets, no AWS names.
  2. Sync vs async mark.
  3. Failure mode.
  4. Idempotency key.
  5. Data from access patterns.
  6. Cost 1x and 10x.
  7. Quotas ap-south-1.
  8. Auth decision.
  9. On-call + alarm.
  10. Deep chapter link.
  11. मग 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
DLQFail झालेले messages
ChoreographyEvents; conductor नाही
OrchestrationSFN central
Fan-outएक → अनेक
Fan-inअनेक → join
Strangler figMonolith peel
SagaSteps + compensate
Provisioned concurrencyWarm N; pay

24. Practice: मोठ्याने explain

  1. 60s: choreography vs orchestration गोष्ट.
  2. 60s: sync vs async checkout.
  3. 60s: Lambda नको कधी.
  4. 60s: DLQ + idempotency.
  5. Record ×2.

25. Safe lab hygiene

  • Tag owner+expiry.
  • Budget alarm आधी.
  • Read-only first.
  • Cleanup.
  • No secrets in env/screenshots.
  • No provisioned on hello.

27. Myths

Mythखरं
Servers नाहीतServers आहेत; manage नको
नेहमी स्वस्तSteady वर EC2
No OpsIAM/data/alarms
एक LambdaBounded contexts
Queues optionalLoad leveler

28. Serverless error budget

Checkout error budget 0.1% असेल तर aggressive retries email duplicates देऊन budget जाळू शकतात. Money SLO ≠ notify SLO.

  1. दोन SLOs.
  2. Money retries bounded.
  3. Notify best-effort.
  4. 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

  1. Double charge headline.
  2. DLQ drain plan.
  3. Cognito outage mode.
  4. Runbook.

32. Currency / locale

Currencies आणि names rotate करा — global mental model.

उजळणी, मुलाखत आणि तुलना cards

हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.

उजळणी card: Choreo vs orchestration. One style fails. Bus vs SFN. Money SFN; notify bus. Draw both.
उजळणी card: Choreo vs orchestration · PNG download करा · Card page उघडा
उजळणी card: Hybrid adult answer. Bloat SFN. Critical = SFN; sides = bus+DLQ. Split → SFN → bus. Hybrid interview.
उजळणी card: Hybrid adult answer · PNG download करा · Card page उघडा
तुलना: Choreography vs Orchestration. Choreography: No conductor. Orchestration: SFN conducts.
तुलना: Choreography vs Orchestration · PNG download करा · Card page उघडा
तुलना: Money path SFN vs Notify on bus. Money path SFN: SFN critical. Notify on bus: Bus notify.
तुलना: Money path SFN vs Notify on bus · PNG download करा · Card page उघडा
मुलाखत card: Choreography fit. Conductor bloat. Bus + filter + DLQ. One each.
मुलाखत card: Choreography fit · PNG download करा · Card page उघडा
मुलाखत card: Saga compensations. No compensate. SFN compensate. Compensate sketch.
मुलाखत card: Saga compensations · PNG download करा · Card page उघडा
मुलाखत card: Correlation id. No story. Propagate corr id. Envelope field.
मुलाखत card: Correlation id · PNG download करा · Card page उघडा
मुलाखत card: Per-target DLQ. Mixed DLQ. Own DLQ + alarm. DLQ alarm.
मुलाखत card: Per-target DLQ · PNG download करा · Card page उघडा

अजून cards: Ravi Sir's Cards.

सराव Tasks

या scenario बद्दल

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.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Orch

का: Style.

काय करायचं: Workflow engine तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Saga

का: Fit.

काय करायचं: SFN saga तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Side

का: Fit.

काय करायचं: Choreo side effects तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं List-rules

का: CLI.

काय करायचं: list.

कसं करायचं:
  1. Task वाचा आणि ते कोणत्या AWS service बद्दल आहे ते ठरवा.
  2. aws लिहा, मग service चं नाव, मग operation (action शब्द).
  3. प्रत्येक आवश्यक flag (--name) व त्यापुढे task मधली value लिहा.
  4. Flags कोणत्याही क्रमाने चालतात. Check answer दाबा.

सोपं Styles

का: Map.

काय करायचं: choreography/orchestration.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

सोपं Filter

का: Hygiene.

काय करायचं: Filters तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Spaghetti

का: Smell.

काय करायचं: Everyone listens तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम EB

का: Tool.

काय करायचं: EB filters तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Corr

का: Trace.

काय करायचं: Correlation तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Cycle

का: Anti.

काय करायचं: Break cycle तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Hybrid

का: Split.

काय करायचं: money/notify.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

अवघड Hybrid

का: Adult.

काय करायचं: Money SFN notify bus तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड DLQ

का: Ops.

काय करायचं: Own DLQ तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Schema

का: Contract.

काय करायचं: Schema owner तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Lab

का: Hygiene.

काय करायचं: Delete lab तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.