Stackbook Logo
architecture-descriptionemerging · medium operational burden

Temporal Workflows (Durable Execution)

Also known as: temporal, durable-execution, workflow-engine, activity

Intent

Write reliable, long-running business logic as code that survives crashes, retries automatically, and provides full observability — without managing queues, state machines, or timers manually.

Problem

Long-running processes (orders, onboarding, payments) need reliability: survive crashes, handle retries, support human-in-the-loop, provide visibility. Custom state machines are buggy and hard to maintain.

Forces

  • Business logic runs for minutes to months
  • Must survive process crashes, deployments, infra failures
  • Need exactly-once semantics for activities
  • Observability: current state, history, stack traces
  • Human-in-the-loop: approvals, signals, waits

Solution

✓ When to Use

  • Long-running business processes (orders, onboarding, claims)
  • Human-in-the-loop workflows (approvals, reviews)
  • Reliable orchestration of microservices
  • Replace custom state machines, cron jobs, queue workers

✗ When Not to Use

  • Simple request-response (overhead not justified)
  • Sub-second latency requirements (workflow overhead)
  • Team not ready for deterministic programming model
  • No ops capacity for Temporal cluster (use Cloud)

Pros

  • +Write reliable workflows as simple code
  • +Automatic retries, exactly-once, durable timers
  • +Full observability: history, stack traces, replay
  • +Human-in-the-loop: signals, queries, async waits
  • +No custom state machines, cron, queue management

Cons

  • Learning curve: deterministic programming, replay
  • Temporal cluster ops (or Cloud cost)
  • Workflow determinism constraints (no random, time, I/O)
  • Debugging: replay model different from traditional

Cost Profile

Infrastructure

Medium — Temporal cluster (3+ nodes) or Cloud

Operational

Medium — cluster ops, namespace management

Cognitive

High — deterministic programming, replay model

Failure Modes

  • Non-deterministic workflow → replay divergence

  • Activity timeout misconfig → stuck workflows

  • Worker version mismatch → task failures

  • Namespace retention too short → history loss

  • Worker OOM → task queue backup

Real-World Examples

Alternatives

  • aws-step-functions
  • camunda
  • custom-state-machine
  • celery
  • queue-workers

Related Patterns

  • saga-patterns
  • outbox-pattern
  • idempotency-key
  • durable-execution
  • workflow-engine
  • human-in-the-loop

Competency Domains

distribution communicationreliability opsdata consistencydeploymenteconomics evolution