Notesencoding🌱 seedling
Durable Execution
Also: Durable Workflow · Workflow as Code · Event History Replay · Durable Functions
Durable execution runs ordinary code for a long-lived process so that it survives crashes: every step's result is recorded, and after a failure the code is replayed against that record to rebuild its state and continue where it stopped.
Why it exists
Multi-step processes (charge, ship, wait three days, follow up) outlive any single process. Building them from state tables, queues, cron and retry code is error-prone; every crash between steps is a potential bug.
How it works
- Activities are steps with side effects. The engine retries them, so they run at least once and must be idempotent.
- The workflow function sequences activities; each command and result is appended to an event history.
- After a crash a new worker replays the code: calls with recorded results return them instantly, rebuilding state; the first unrecorded call runs for real.
- Durable timers: a three-day sleep is an event, not a blocked thread.
- Determinism: replay compares the code's calls to the history, so workflow code must not read the clock, random numbers or do I/O directly. Code changes need versioning (patch markers or versioned workers).
Trade-offs
| Gains | Costs |
|---|---|
| business process is plain, readable code | determinism constraints on workflow code |
| crash recovery, retries and timers for free | versioning running workflows is real work |
| full audit trail of every step | an engine to run; history size limits |
In practice
- Temporal terminates a workflow whose history exceeds 51,200 events or 50 MB (it warns from 10,240 events or 10 MB); long-lived workflows use continue-as-new.
- AWS Lambda durable functions (Dec 2025) checkpoint and replay for up to a year; also Step Functions, Azure Durable Functions, Cloudflare Workflows (GA April 2025), Restate, DBOS.
Pitfalls
- Calling
now()orrandom()in workflow code: replay diverges and fails with a non-determinism error. - Non-idempotent activities: a retry after a crash repeats the side effect.
Connections
- Part of
- Encoding
- Learn first
- Idempotency
- In real systems
- Temporal
Recall
These cards are also in your review deck, scheduled with spaced repetition.