jargon

Comparison

SagavsState machine

Saga

you break the cross-service operation into local transactions and write an undo step for each one, because there is no shared rollback.

A sequence of local transactions across services, with a compensating action for each step, so that a failure part-way is unwound rather than rolled back. It buys availability and loose coupling at the cost of never having true atomicity: intermediate states are visible, and compensation is not the same as undo. Every saga step must be idempotent, because retries are guaranteed.

Full entry →

State machine

you wrote down every state and every allowed move between them, and three combinations you had shipped turned out to be impossible.

A model of an object as a fixed set of states plus the transitions permitted between them, usually recorded as a table or a diagram. Making it explicit is the highest-value modelling move available for anything with a lifecycle — an order, a subscription, a deployment — because the illegal transitions become visible instead of implied. The state pattern is one way to implement it; a table and a switch is often the clearer one.

Full entry →

Related comparisons