A saga commits one local transaction per service and undoes finished steps with compensating actions when a later step fails; two-phase commit keeps every step open and locked until one coordinator decides.
Learn the idea first
Order #42 is one electric kettle for ₹1,200. Orders, payments, stock and shipping are separate services, each with its own database, so no single transaction can cover all of them. The order service runs the steps as an orchestrator. Red steps are failures and the compensations that undo them. Timings are an illustrative model.
Order service
orchestrator
Payment service
charges cards
Inventory service
kettles: stock
Shipping service
books couriers
Swipe the diagram sideways to see every column →
Where the time goes
264 ms total
Order #42 is one electric kettle for ₹1,200. Orders, payments, stock and shipping are separate services, each with its own database, so no single transaction can cover all of them. The order service runs the steps as an orchestrator. Red steps are failures and the compensations that undo them. Timings are an illustrative model.
Illustrative timings. Real numbers vary with distance, network quality and server load.