Multi-step workflows
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Multi-step workflows: the 60-second story

    Multi-step workflows

    The pod crashed after the charge. Who remembers order 81?

    A chain of calls has no memory. The money is taken, the store never hears, and nothing records which steps ran.

    Signals that it’s a multi-step workflow

    1. One action, several owners or companies
    2. Steps fail after others changed something
    3. Steps that wait: UPI, banks, humans
    4. “Where is order 81?”

    Climb the ladder. The saga is rung 3, not the top.

    Most of the interview is about what keeps it running through crashes, retries, code changes and peak load.

    Choreograph the whole order?

    Bad: Events between services

    Nobody sees where order 81 is or owns its 10-minute timeout.

    Good: Orchestrate the core flow

    Choreograph only side effects like SMS and analytics.

    Undo before the pivot, push forward after it

    Reserving stock and taking payment can be compensated. The store accepting is the pivot; once packing starts, rider assignment and settlement are only retried.

    The payment call timed out. Did it charge? Retry anyway?

    The trick

    Yes, with the same key, o81:charge, built from the order and step. Payments returns the stored result if the first call worked.

    Durable execution: replay, don’t re-run

    Each step’s result is appended to the order’s history. If worker A dies, worker B replays the code; finished steps return recorded results, so nobody is charged twice.

    3.6M

    orders in flight at the dinner peak

    Little’s law: 2,000 orders a second × 30 minutes. At 10 transitions each, that’s 20,000 a second, beyond Step Functions’ default quotas and about $75,000 a month.

    Say it like this

    One database? One transaction. Otherwise a saga in a workflow engine: compensable steps before the pivot, retries after it, durable timers for waits, and an idempotency key per step.