Try
↑ ↓ move↵ openesc close

Saga compensation lab

Run a chain of steps with an undo for each. Make steps and undos fail, switch between orchestration and choreography, and watch readers see work that is later taken back.

tick 1504 steps, orchestrationchance of no failure: 72%

Outcomes

started
300
committed
221 (75%)
compensated
72
parked
0
in flight
7

A saga runs its steps one after another. When a step fails, it runs the undo of every earlier step in reverse order. An undo that keeps failing parks the saga for a person.

Cost

messages per saga
7.9
latency
3.9 ticks
work undone
9% of steps

Orchestration sends a command and gets a reply for every action. Choreography sends one event per action, and no one place holds the whole story.

What a reader sees in the middle

reads of half-done work
900
of those, later undone
23%
told it is pending
0%

A reader that looks at a record while a saga is running sees its early steps. If that saga later fails, the reader saw something that never really happened.

Sagas in flight over the last 120 ticks
Sagas in flight over the last 120 ticks. Text version available below the chart.035810161120recent tickssagas

What to try

Each one sets up a starting point. Then make the change it describes.

  1. Longer sagas fail more

    Set the steps to 8 and read the committed share.

    Look for. Every step is another chance to fail, so the share of sagas that commit falls like a power of the step count. More steps also means more work to undo.

  2. Orchestration against choreography

    Read messages per saga, then switch to choreography.

    Look for. Orchestration sends a command and a reply for each action, so it uses about twice the messages. What it buys is one place that knows where each saga is.

  3. Readers see work that is undone

    With isolation off, read the share of reads of half-done work that were later undone.

    Look for. Sagas have no isolation. A reader can see the early steps of a saga that then fails. That reader saw something that, in the end, never happened.

  4. A semantic lock

    Turn on the semantic lock and read the same numbers.

    Look for. No read sees work that is later undone, because every read of a saga in flight is told it is pending. The cost moves to the reader, which has to cope with pending.

  5. Undo that cannot succeed

    Set undo failure to 50 percent and read the parked count.

    Look for. A compensation is retried a few times and then the saga is parked for a person. Compensations must be written to succeed, and to be safe to repeat.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms