# Temporal Durable Execution: How Workflows Recover After a Crash

A process can fail between charging a card and reserving the stock. Restarting the process is easy; deciding which business steps have already happened is harder. Repeating everything can duplicate an external action, while abandoning the job leaves the order unfinished.

[Temporal](https://github.com/temporalio/temporal) addresses this coordination problem with durable execution. Application code describes a workflow, workers execute it, and a service persists the events needed to recover its progress. **The workflow can survive the lifetime of the worker process that originally ran it.**

That guarantee has a precise boundary. Replay can reuse a recorded activity result, but an external API call still needs a safe retry strategy if its outcome is uncertain. **Durable orchestration and idempotent side effects work together**; neither should be mistaken for a magic transaction spanning every system involved.

<iframe width="100%" class="aspect-video h-auto" src="https://www.youtube.com/embed/FwcvrWEldKI" title="Temporal workflows and durable execution" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

## The business process outlives the request

An ordinary HTTP handler is tied to a short execution window. It receives a request, performs work, and returns a response. A business process may need to last much longer: waiting for stock, retrying an unavailable service, collecting approval, or sending a notification after another system responds.

Keeping that process alive with a single request is fragile. Moving it into background jobs helps, but then application code has to record state, discover abandoned work, and decide which transitions are safe to repeat.

A workflow makes the coordination explicit. A checkout can express charging the card, reserving inventory, and sending confirmation in one logical sequence, even though each operation happens in a different system.

![Checkout workflow arranging payment, stock reservation, and email as separate activities](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/c4584729-5070-4d95-152d-2c8cb657af00/orig =1920x1080)

The sequence is not a database transaction. If the stock reservation fails permanently after a charge succeeds, the application still needs a business decision, such as refunding the payment or requesting manual resolution. Durability ensures that this decision can continue after failures; it does not decide the policy for the business.

This is the first useful separation: a workflow describes what should happen next, while the surrounding systems decide what each action means and how its effects are recorded.

## Workflows coordinate and activities perform external work

A Workflow Definition contains orchestration logic. Activities contain operations that interact with the outside world: an HTTP call, a database change, or a message to an email provider.

That boundary supports replay. The orchestration can be executed again against recorded results without blindly repeating every external action. A workflow's local variables can be reconstructed from the same sequence of decisions and outcomes.

The split also changes how failures are handled. A temporarily unavailable email API can be retried as an activity without restarting the entire checkout from the beginning. A non-retryable validation error can be handled differently from a network timeout.

## Workers execute application code

Temporal's service coordinates work and stores execution state. Workers run the application code. A worker polls the appropriate task queue, handles a task, and reports the result back to the service.

![Temporal documentation distinguishing worker execution from service orchestration](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/cc256d6d-5be3-4c07-0dfe-8e5f5fadd400/orig =1920x1080)

This means application dependencies remain under the team's control. A worker can run alongside services that need access to internal databases or APIs. It also means that operating Temporal does not remove the need to deploy and monitor those workers.

If one worker stops, another compatible worker can continue processing tasks. Compatibility matters because the replacement must understand the workflow's history and the activity types it may receive.

Task queues provide a routing boundary. They are not simply an archive of functions to execute; they connect the service's durable decisions to workers capable of performing them. A queue without available workers can preserve pending work while making no progress, which is an operational condition worth alerting on.

## Event History records the decisions needed for recovery

The durable record is an Event History. It includes events corresponding to workflow progress, such as scheduling an activity and receiving its completion result.

![Checkout Event History recording a scheduled charge and its completed result](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/14881cf8-12db-4261-e15c-9f4865803d00/orig =1920x1080)

The [Workflow Execution documentation](https://docs.temporal.io/workflow-execution) describes recovery in terms of replaying commands against this history. The application does not depend on recovering the exact heap memory of the original worker.

This is a different persistence model from writing a custom status column after every function call. The service and SDK coordinate the event sequence, while the application's workflow code expresses the process.

The record also has a boundary. An event can describe the result reported to Temporal; it is not an omniscient record of every event inside an external provider. If a provider accepted a charge but the worker died before reporting completion, the service may have to treat the activity's outcome as unknown.

That uncertainty is one reason retries and idempotency remain central even in a durable system.

## Replay rebuilds execution without repeating recorded results

After a worker failure, the workflow function can run again from its beginning. As it reaches operations already represented in history, the SDK supplies their recorded outcomes. Execution advances through the known past until it reaches work that still needs to happen.

![Replay returning the recorded charge result before continuing to stock reservation](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/c86f83a8-cc0e-463f-4be3-6cc022cb6600/orig =1920x1080)

A replay is therefore not equivalent to rerunning the whole business process against live services. The function's orchestration code executes again, while completed external work is represented by its recorded activity result.

This requires determinism in the workflow logic. Given the same history, it must produce a compatible sequence of commands. Arbitrary network calls, uncontrolled randomness, or ordinary wall-clock reads inside that logic can make a later replay choose a different path.

SDK-provided mechanisms and activity boundaries manage those sources of variability. The important design principle is that an input affecting a durable decision must be represented in a way replay can reproduce.

This constraint can feel unfamiliar at first. It is also what makes the recovery model understandable: the new worker is reconstructing the same process, not guessing what the previous process might have done.

## Retries do not remove the need for idempotency

An activity may fail or time out, and the configured retry policy determines when it is attempted again. Backoff keeps a short outage from turning into a rapid loop of requests.

![Activity retry timeline increasing the delay between email attempts](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/b24c4b96-ee44-4039-3847-c7934b704400/orig =1920x1080)

The [Activity Execution documentation](https://docs.temporal.io/activity-execution) explains that lost tasks are detected through timeouts and may be retried under the activity policy. A worker can disappear after beginning the function, not only before it starts.

Consider a payment provider that accepts the charge and returns successfully, followed immediately by a worker crash before the completion is persisted. A replacement cannot safely infer from the missing result that no charge occurred. Retrying the API call with a stable idempotency key lets the provider recognize the same business operation.

The key should represent that operation across attempts, not be regenerated for every retry. A durable workflow ID can help organize identity, but the external provider's idempotency behavior still needs to be understood.

| Failure point | Recovery concern |
|---|---|
| Before an external call | The activity may simply need another attempt |
| After the provider acts but before completion is recorded | A retry must not duplicate the effect |
| After a completion is recorded | Replay can reuse the saved result |
| After a later business step fails permanently | The workflow needs compensation or another explicit decision |

This is why durable execution should be described precisely. It removes much of the coordination machinery, while leaving business correctness as an application responsibility.

## Waiting does not require a sleeping worker

A long-running process often spends most of its time waiting. An order can wait for inventory, a subscription can wait for renewal, and an approval process can wait for a person.

A durable timer represents that wait without dedicating a worker thread to sleeping for weeks. The service records the timer and later makes progress possible when it fires.

The distinction matters for resource planning. Thousands of workflows waiting for dates do not imply thousands of active application processes. They still consume durable state and service capacity, so waiting is not completely free, but it differs fundamentally from maintaining one live process for every outstanding business operation.

Cancellation and expiry also become explicit business events. A customer may cancel an order during a wait, or an approval may cease to be relevant. The workflow can define the resulting transition instead of relying on a background script to discover stale rows.

## DOOM illustrates why replay can work

A deterministic program can reconstruct state from a compact sequence of inputs. DOOM is a striking example because its simulation advances predictably from player commands.

![DOOM explanation showing the fixed random-number table used for deterministic behavior](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/7a492430-8128-4227-9a23-75d379f80100/orig =1920x1080)

Temporal's [DOOM implementation write-up](https://temporal.io/blog/running-doom-as-a-temporal-workflow) describes recording player input and replaying it to reconstruct the game. That example illustrates the mechanism; it is not evidence that arbitrary programs become deterministic when placed inside a workflow.

The same distinction applies to business code. If the next decision depends on a recorded payment result, replay can reuse it. If it depends on an unrecorded external observation that changes every time, recovery cannot reproduce the old decision reliably.

DOOM also exposes a familiar software compatibility issue: the same input stream can behave differently under a changed engine. Long-lived workflows need similar care when their code is updated.

## Histories need boundaries and compatible code

A workflow can live for a long time, but one run's history should not grow indefinitely. Large histories increase the work needed for replay and eventually encounter service limits.

![DOOM recovery description explaining how a new worker reconstructs recorded game progress](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/23811a13-406d-4bb6-9fa8-ff6f71690e00/orig =1920x1080)

Continue-As-New provides a way to close the current run and start another with compact input. The new run can carry the business state needed to continue without carrying every old event in one expanding history.

Choosing the handoff state is an application design decision. An order might need its identity, completed business milestones, and outstanding action. A game can use a save-state representation. The compact state should retain what the next run needs without pretending to be a complete audit history by itself.

Code deployment requires equal care. If a new implementation changes command ordering for an execution already in progress, replay may detect a mismatch. Versioning and compatibility mechanisms allow old histories to remain meaningful while new executions use updated logic.

Durability therefore adds a long-term contract to application code: future workers must be able to understand the decisions recorded by earlier workers.

## The service is infrastructure that must be operated

A development server can make experimentation simple. Production introduces separate concerns: service availability, persistence, worker capacity, task routing, and access to the systems activities call.

![Temporal service architecture separating frontend, history, matching, and worker components](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/0a5e5a8e-51e1-4887-8bd3-b6977956c500/orig =1920x1080)

Self-hosting makes those components part of the team's operational responsibility. A managed service changes that responsibility but does not deploy the application's workers or guarantee that its payment provider is available.

Observability should follow the business process as well as the infrastructure. An active worker process does not show that orders are completing. Useful signals include pending tasks, repeated activity failures, execution age, and workflows awaiting an intervention that will never arrive.

The system also needs retention and capacity planning. A high-volume workflow with many tiny activities has a different event profile from a small number of long-lived approval processes. The right design depends on the frequency of durable transitions, not merely the number of lines in the workflow function.

## What the Netflix result actually describes

Netflix's [engineering account](https://netflixtechblog.com/how-temporal-powers-reliable-cloud-operations-at-netflix-73c69ccb5953) reports a reduction in deployments failing because of transient Cloud Operation failures, from 4% to 0.0001%. That is a specific deployment-orchestration result, not a claim that all Netflix crashes were eliminated.

![Continue-As-New discussion describing how a fresh workflow run keeps history bounded](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/6f9d30e0-a124-4d34-768b-4375cff70d00/orig =1920x1080)

The useful lesson is the reduction of repeated recovery logic around unreliable operations. It does not provide a universal percentage that another application can expect to reproduce. Different external systems, retry policies, and failure modes produce different outcomes.

Temporal is most compelling when a process crosses several failure boundaries and must continue reliably over time. A single short database operation may not need a workflow platform. A multi-step operation that already accumulates status flags, retry jobs, and recovery scripts is a stronger candidate.

## Final thoughts

**Temporal preserves the progress of a business process beyond the lifetime of its worker.** Event History and replay let replacement workers reconstruct execution, while activities isolate external work and supply configurable retry behavior.

The strongest designs keep the boundaries explicit. External effects need idempotency, permanent failures need business decisions, and long-lived executions need compatible code and bounded history. Durable execution replaces much of the recovery plumbing, while making those remaining responsibilities easier to see and reason about.
