The decision logic for the orchestration pattern should be centralized.
Orchestration is the process where multiple services which are taking part in transaction should be managed by a central authority.
Orchestration way is good for complex workflows which includes lots of steps. But this makes single point-of-failure with centralized controller microservices and need implementation of complex steps.
Central Service takes care of calling different services in the right order and if failure then it would know how to do compensation action between services that are already called.
The process is mainly used for the Synchronous operation.
Saga Orchestration Diagram
The Orchestration Saga design pattern is a widely used approach for managing distributed transactions in a microservices architecture. In this pattern, the orchestration of the workflow and coordination between services is handled by a central orchestrator, often implemented in the Order Service.
Here’s a structured explanation of the process:
Orchestration Saga Process
- Customer Places an Order
- The process begins when a customer places an order.
- The Order Service orchestrates the subsequent steps to ensure the order is processed and completed.
- Payment Processing
- The Order Service calls the Payment Gateway API to charge the customer for the order.
- If the payment is successful, the process moves to the next step.
- If the payment fails, the saga terminates with a failure.
- Inventory Deduction
- After successful payment, the Order Service calls the Inventory API to deduct the ordered items from the inventory.
- If this step succeeds, the process advances.
- If it fails, the payment is reverted using a compensation step.
- Shipping the Product
- The Order Service calls the Shipping API to arrange for the product to be shipped to the customer.
- If shipping succeeds, the order is marked as completed.
- If shipping fails, the orchestrator initiates compensation steps.
Compensation Logic for Failures
- If any step fails, the orchestrator must undo the previous actions to maintain consistency.
- Shipping Failure:
- 1st Compensation Service: Call the Inventory API to add the items back to the inventory.
- 2nd Compensation Service: Call the Payment Gateway API to refund the customer.
- Shipping Failure:
Key Advantages of Orchestration Saga
- Centralized Control:
- All decisions are made by the orchestrator, ensuring a consistent workflow.
- Clear Workflow:
- The process flow is defined explicitly, making it easier to understand and debug.
- Error Handling and Compensation:
- Failures are handled systematically through compensation mechanisms.
Limitations
- Single Point of Failure:
- If the orchestrator service goes down, the entire workflow is affected.
- Complexity in Orchestrator:
- Managing complex workflows and compensation logic in the orchestrator can make it harder to maintain.
