0
0
Microservicessystem_design~12 mins

Choreography vs orchestration in Microservices - Architecture Patterns Compared

Choose your learning style9 modes available
System Overview - Choreography vs orchestration

This system compares two ways microservices coordinate tasks: choreography and orchestration. Both handle multi-step processes but differ in control style. Choreography lets services react independently to events, while orchestration uses a central controller to manage the flow.

Architecture Diagram
Choreography Architecture:

User
  |
  v
Service A --- emits event ---> Event Bus --- notifies ---> Service B
  |                                         |
  |                                         v
  |------------------------------------> Service C


Orchestration Architecture:

User
  |
  v
API Gateway
  |
  v
Orchestrator Service
  |        |        |
  v        v        v
Service A Service B Service C

Components
User
client
Initiates requests to the system
Service A
microservice
Performs first step and emits events (choreography) or receives commands (orchestration)
Service B
microservice
Performs second step reacting to events or commands
Service C
microservice
Performs third step reacting to events or commands
Event Bus
message_queue
Distributes events between services in choreography
API Gateway
load_balancer
Receives user requests and forwards to orchestrator
Orchestrator Service
service
Central controller managing workflow and calling services in orchestration
Request Flow - 16 Hops
UserService A
Service AEvent Bus
Event BusService B
Service BEvent Bus
Event BusService C
Service CUser
UserAPI Gateway
API GatewayOrchestrator Service
Orchestrator ServiceService A
Service AOrchestrator Service
Orchestrator ServiceService B
Service BOrchestrator Service
Orchestrator ServiceService C
Service COrchestrator Service
Orchestrator ServiceAPI Gateway
API GatewayUser
Failure Scenario
Component Fails:Event Bus
Impact:In choreography, services cannot receive events, so the workflow stalls and no further steps happen. In orchestration, the orchestrator can still call services directly, so the process continues.
Mitigation:Use a highly available event bus with replication and fallback. For choreography, implement retry and dead-letter queues. For orchestration, fallback to direct calls if event bus is down.
Architecture Quiz - 3 Questions
Test your understanding
In choreography, how do services know when to perform their tasks?
AThey listen for events from other services
BA central orchestrator tells them what to do
CThey poll the database for changes
DUsers manually trigger each service
Design Principle
This comparison shows two coordination styles in microservices: choreography uses decentralized event-driven communication allowing loose coupling, while orchestration uses a central controller for explicit workflow management. Choosing between them depends on system complexity, control needs, and failure tolerance.