Durable workflow
Also called: durable execution.
A job of several steps, run by an engine that writes each finished step's result into an event history. If the worker running it crashes, a new worker replays that history, skips the steps already done and carries on from the step that was cut off. That step may run a second time, so a step with a side effect, like sending an email, must be safe to repeat.
The engine keeps an event history of every finished step. Here a step's timeout, which tells the engine a worker is gone, is shortened to half a second.
No run yet. Run the workflow, then crash the worker in step 3 to see what the history saves.
Say it in a prompt
Run the investor signing flow as a Temporal workflow with 4 activities: sign the document, make the PDF, email the investor, update the dashboard. Give each activity a 30 s start-to-close timeout and a retry policy (1 s first wait, doubling, at most 5 attempts). Make the email activity idempotent with a key made of the workflow run ID and the activity ID, so a retry after a crash never emails the investor twice. Keep the workflow code deterministic: no clock, random numbers or network calls outside activities. Vague vs precise prompt
Vague prompt
send the signed PDF to the investor in a background job Typical resultPuts all 4 steps in one job on a queue. When the worker restarts during a deploy, the job runs again from the top: the document is signed twice and the investor gets 2 emails.
Precise prompt
Run it as a Temporal workflow: 4 activities with retries, each result kept in the event history, and the email sent with an idempotency key of run ID plus activity ID. Keep the workflow code deterministic: no clock, random numbers or network calls outside activities. Typical resultAfter a crash a new worker carries on at the step that was cut off, the steps already done do not run again, and the investor gets 1 email, even though the email step ran twice.
Seen on
- Temporal docs: The event history is a complete, durable log of everything that happened in a workflow execution. After a worker crashes, the history is used to replay the code and rebuild the workflow's state as it was just before the crash.
- Microsoft Learn (Durable Task): Orchestrations use event sourcing: every step is appended to an execution history. On replay, a step the history shows as complete is not run again; its saved result is used and the code moves on.
- Temporal docs: Activities may be retried and can even partly run more than once, so they should be idempotent. The workflow run ID plus the activity ID makes a good idempotency key: the same on every retry, unique for each run.
You might describe it as
- a job that picks up where it left off after a crash
- long multi-step process that survives a server restart
- remember which steps already ran
Not to be confused with
- Saga
A durable workflow is a job whose engine remembers which steps are done; a saga is a pattern, a chain of steps with an undo for each, and sagas are often built as one.
- Retry with backoff
A durable workflow remembers which steps are done, so after a crash it retries only the step that was cut off; retry with backoff tries one failed call again, waiting longer each time.