Bird
Raised Fist0
Kafkadevops~10 mins

Event choreography vs orchestration in Kafka - Visual Side-by-Side Comparison

Choose your learning style10 modes available
Process Flow - Event choreography vs orchestration
Start Event
↓
Event Choreography
↓
Multiple Services Listen & React
↓
Each Service Emits Events
↓
Other Services React
↓
No Central Controller
↓
Start Event
↓
Event Orchestration
↓
Central Orchestrator Service
↓
Orchestrator Sends Commands
↓
Services Perform Tasks
↓
Orchestrator Tracks Progress
↓
Process Ends
Event choreography lets services react to events independently without a central controller, while orchestration uses a central controller to direct service actions.
Execution Sample
Kafka
1. Service A emits 'OrderCreated' event
2. Service B listens and emits 'PaymentProcessed'
3. Service C listens and emits 'OrderShipped'

// Orchestration example
1. Orchestrator sends 'ProcessPayment' to Service B
2. Service B replies 'PaymentDone'
3. Orchestrator sends 'ShipOrder' to Service C
Shows event flow in choreography where services emit and listen to events, and orchestration where a central orchestrator commands services.
Process Table
StepEvent/CommandService ActionEmitted EventNext Listener/Action
1'OrderCreated' emittedService A emits event'OrderCreated'Service B listens
2'OrderCreated' receivedService B processes payment'PaymentProcessed' emittedService C listens
3'PaymentProcessed' receivedService C prepares shipment'OrderShipped' emittedNo further listeners
4Process endsNo central controller, flow ends naturallyNo eventNo action
5'ProcessPayment'Orchestrator sends command to Service BNo eventService B processes payment
6'PaymentDone' replyService B replies to orchestratorNo eventOrchestrator sends 'ShipOrder' to Service C
7'ShipOrder' commandService C ships orderNo eventOrchestrator waits for completion
8Process endsOrchestrator confirms completionNo eventProcess complete
💡 Choreography ends when no more events are emitted; orchestration ends when orchestrator confirms all tasks done.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 5After Step 6After Step 7Final
Events in Kafka[]['OrderCreated']['OrderCreated', 'PaymentProcessed']['OrderCreated', 'PaymentProcessed', 'OrderShipped']['OrderCreated', 'PaymentProcessed', 'OrderShipped']['OrderCreated', 'PaymentProcessed', 'OrderShipped']['OrderCreated', 'PaymentProcessed', 'OrderShipped']['OrderCreated', 'PaymentProcessed', 'OrderShipped']
Orchestrator Commands[][][][]['ProcessPayment']['ProcessPayment', 'PaymentDone']['ProcessPayment', 'PaymentDone', 'ShipOrder']['ProcessPayment', 'PaymentDone', 'ShipOrder', 'Completed']
Service StatesIdleService A emitted eventService B processed paymentService C shipped orderIdleService B processed paymentService C shipped orderAll tasks done
Key Moments - 3 Insights
Why does event choreography not have a central controller?
Because each service listens and reacts independently by emitting events, as shown in execution_table rows 1-4, no single service controls the flow.
How does the orchestrator know when to send the next command?
The orchestrator waits for replies from services before sending the next command, as seen in execution_table rows 5-7 where commands and replies coordinate the flow.
Can events in choreography cause infinite loops?
Yes, if services keep emitting events in response to each other without stopping, but usually design prevents this; the execution_table shows a natural end at step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what event does Service B emit after receiving 'OrderCreated'?
A'OrderShipped'
B'PaymentProcessed'
C'ProcessPayment'
D'PaymentDone'
💡 Hint
Check execution_table row 2 under 'Emitted Event'
At which step does the orchestrator send the 'ShipOrder' command?
AStep 7
BStep 5
CStep 6
DStep 8
💡 Hint
Look at execution_table row 7 under 'Event/Command'
If Service C never emits 'OrderShipped' in choreography, what happens?
AThe process ends normally
BService B emits 'OrderShipped' instead
CThe event flow may stall or wait indefinitely
DOrchestrator takes over automatically
💡 Hint
Refer to execution_table rows 3 and 4 about event flow ending
Concept Snapshot
Event Choreography:
- Services emit and listen to events independently
- No central controller
- Flow driven by events

Event Orchestration:
- Central orchestrator sends commands
- Orchestrator tracks progress
- Flow controlled centrally
Full Transcript
Event choreography means services talk by sending events to each other without a boss. Each service listens for events and reacts by doing work and sending new events. This creates a chain of reactions. Event orchestration means one central service controls the process. It sends commands to other services and waits for replies before sending the next command. In Kafka, events are messages on topics. In choreography, services produce and consume events freely. In orchestration, the orchestrator sends commands and listens for responses. The execution table shows how events flow step-by-step in both styles. Variables track events in Kafka, commands from orchestrator, and service states. Key moments explain why choreography has no controller and how orchestrator manages flow. The quiz checks understanding of event emissions and command steps. Remember, choreography is like a dance where everyone follows the music, orchestration is like a conductor leading the orchestra.

Practice

(1/5)
1. What is the main difference between event choreography and event orchestration in Kafka-based systems?
easy
A. Choreography lets services react independently; orchestration uses a central controller.
B. Choreography requires a central controller; orchestration lets services react independently.
C. Both use a central controller but differ in message format.
D. Choreography is synchronous; orchestration is asynchronous.

Solution

  1. Step 1: Understand event choreography

    Event choreography means each service listens and reacts to events on its own without a central manager.
  2. Step 2: Understand event orchestration

    Event orchestration means a central controller tells services what to do and when, managing the flow.
  3. Final Answer:

    Choreography lets services react independently; orchestration uses a central controller. -> Option A
  4. Quick Check:

    Choreography = independent reaction, Orchestration = central control [OK]
Hint: Choreography = no boss; orchestration = boss controls flow [OK]
Common Mistakes:
  • Confusing which uses a central controller
  • Thinking both require central control
  • Mixing synchronous and asynchronous concepts
2. Which Kafka component is typically used in event orchestration to coordinate services?
easy
A. Kafka Topics with independent consumers
B. A central orchestrator service producing commands
C. Kafka Connect for data integration
D. Kafka Streams for independent event processing

Solution

  1. Step 1: Identify orchestration role

    Orchestration needs a central service to control and send commands to other services.
  2. Step 2: Match Kafka components

    Kafka Topics and Streams are used for event flow, but orchestration requires a central orchestrator producing commands.
  3. Final Answer:

    A central orchestrator service producing commands -> Option B
  4. Quick Check:

    Orchestration = central orchestrator service [OK]
Hint: Orchestration needs a central command sender [OK]
Common Mistakes:
  • Choosing Kafka Topics as the controller
  • Confusing Kafka Connect with orchestration
  • Thinking Kafka Streams alone orchestrates
3. Given this Kafka event flow in choreography style:
Service A publishes event 'OrderCreated' to topic 'orders'.
Service B listens to 'orders' and publishes 'PaymentProcessed' to topic 'payments'.
Service C listens to 'payments' and updates inventory.

What happens if Service B fails to publish 'PaymentProcessed' event?
medium
A. Service C will not update inventory because it never receives the event.
B. Service C updates inventory anyway because it listens to 'orders'.
C. Service A retries publishing 'OrderCreated' event automatically.
D. A central orchestrator will resend 'PaymentProcessed' event.

Solution

  1. Step 1: Trace event flow in choreography

    Service A publishes 'OrderCreated', Service B reacts and publishes 'PaymentProcessed', Service C listens to 'payments'.
  2. Step 2: Analyze failure impact

    If Service B fails to publish 'PaymentProcessed', Service C never receives that event and cannot update inventory.
  3. Final Answer:

    Service C will not update inventory because it never receives the event. -> Option A
  4. Quick Check:

    Missing event means downstream service does not act [OK]
Hint: In choreography, missing event stops downstream actions [OK]
Common Mistakes:
  • Assuming Service C listens to 'orders' directly
  • Thinking Service A retries automatically
  • Expecting a central orchestrator in choreography
4. You have this orchestration code snippet controlling Kafka services:
orchestrator.sendCommand('ServiceB', 'ProcessPayment')
orchestrator.sendCommand('ServiceC', 'UpdateInventory')

But Service C updates inventory before Service B processes payment. What is the likely problem?
medium
A. Service C is ignoring commands from the orchestrator.
B. Service B is not subscribed to the correct Kafka topic.
C. Commands are sent asynchronously without waiting for Service B to finish.
D. Kafka topics are misconfigured causing message loss.

Solution

  1. Step 1: Understand orchestration command flow

    Orchestrator sends commands to services in order, expecting sequential execution.
  2. Step 2: Identify asynchronous issue

    If commands are sent asynchronously without waiting for Service B to complete, Service C may act too early.
  3. Final Answer:

    Commands are sent asynchronously without waiting for Service B to finish. -> Option C
  4. Quick Check:

    Orchestration needs ordered, awaited commands [OK]
Hint: Orchestration requires waiting for each command to finish [OK]
Common Mistakes:
  • Blaming Kafka topic subscription
  • Assuming Service C ignores commands
  • Thinking message loss causes order issue
5. You want to design a Kafka system for an online store where payment processing must strictly happen before inventory update, but you want to avoid a central orchestrator. Which approach fits best and how to ensure order?
hard
A. Use choreography but rely on manual retries to fix order issues.
B. Use event orchestration with a central controller sending commands in order to services.
C. Use orchestration but allow services to process events independently without waiting.
D. Use event choreography with services emitting events and consumers processing in sequence using Kafka partitions and consumer groups.

Solution

  1. Step 1: Identify requirement

    Payment must happen before inventory update, but no central orchestrator allowed.
  2. Step 2: Choose choreography with ordering

    Event choreography fits because services react independently. To ensure order, use Kafka partitions and consumer groups to process events in sequence.
  3. Final Answer:

    Use event choreography with services emitting events and consumers processing in sequence using Kafka partitions and consumer groups. -> Option D
  4. Quick Check:

    Choreography + Kafka ordering = correct sequence without central control [OK]
Hint: Choreography + Kafka partitions ensure order without central control [OK]
Common Mistakes:
  • Choosing orchestration despite no central controller allowed
  • Ignoring Kafka partition ordering
  • Relying on manual retries for order
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard