Saga
The Saga pattern in distributed systems is akin to transactions in databases. It ensures that multiple operations across different services either succeed or fail together, maintaining consistency. Saga orchestrates this by associating each action with a compensatory action, which reverses the changes made by the action if any subsequent steps fail.
This functionality is crucial in avoiding inconsistent states in distributed environments. While similar to Software Transactional Memory (STM), Sagas specifically address distributed systems.
Consider the operation of a donut shop accepting delivery orders. The process involves several steps:
- Putting donuts into a box:
- If subsequent steps fail, the donuts shouldn’t just be left in the box; they need to be unpacked and displayed again.
- Putting a label on the box:
- If a failure occurs after this step, the label needs to be removed.
- Handing the...