The Saga pattern coordinates a business transaction that spans multiple microservices by breaking it into a sequence of local transactions, one per service, instead of relying on a single distributed transaction.
An e-commerce checkout might involve Order, Payment, and Inventory services. Order creates a pending order, Payment charges the customer, and Inventory reserves stock; if Inventory reservation fails, compensating transactions refund the payment and cancel the order, so the system never ends up in a state where money was taken but no order exists.
public interface SagaStep<T> {
void execute(T context);
void compensate(T context);
}
public class OrderSagaOrchestrator {
private final List<SagaStep<OrderContext>> steps;
public void run(OrderContext ctx) {
int completed = 0;
try {
for (SagaStep<OrderContext> step : steps) {
step.execute(ctx);
completed++;
}
} catch (Exception ex) {
for (int i = completed - 1; i >= 0; i--) {
steps.get(i).compensate(ctx);
}
}
}
}A concise interview answer is
The Saga pattern splits a distributed transaction into local transactions per service, each with a compensating action, coordinated either through choreography with events or a central orchestrator. It trades strict atomicity for eventual consistency, which is necessary once each service owns its own database.
Last updated: 11 November 2026
Previous question: What strategies can be used for data replication or synchronization between microservices?
Next question: Can you explain the difference between choreography and orchestration in Saga?