Chapter 7: Durable Orchestration and Workers
A request lives for milliseconds. A process, such as fulfilling an order, ingesting and indexing a corpus, or running a multi-day training job, lives for minutes to months, calls flaky services, and must survive the machine running it dying halfway through. The naive solution, a database state column plus cron plus retry glue, reinvents a buggy workflow engine every time. Durable execution names the pattern: persist the progress of a computation, its checkpoints, so the program is in effect immortal. It can crash and wake up mid-function with all its local state intact. Everything else in this chapter (workers, sagas, observability) is in service of making that illusion reliable and operable.
Concepts from other sections (27)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- task queue: the durable server’s routing key; only pollers of queue
agentreceiveAgentRuntasks. Read more: 10.8 The agent image and chart - Continue-As-New: closing a run and starting a fresh one under the same workflow id with carried state, to bound history. Read more: 7.6 Deterministic replay
- Durable timer: a timer whose existence and deadline are recorded in history as
TimerStarted{fire_at}, so it survives any restart. Read more: 7.7 Durable timers - At-least-once delivery: a guarantee that every task is delivered, possibly more than once. Read more: 7.3 The task queue
- Idempotency key:
"<workflow_id>/<activity_id>", stable across attempts and runs, so an activity’s effect can be applied once. Read more: 7.4 The task protocol and workers - Idempotency: the property that applying an operation more than once has the same effect as applying it once. Read more: Chapter 3: RPC and Protocols
- Event sourcing: storing only the history of changes and deriving all state from it. Read more: 7.2 The workflow service
- Visibility timeout: the lease length ; a leased task is invisible to other pollers until it expires. Read more: 7.3 The task queue
- Dead-letter queue (DLQ): where a task is parked after attempts, to be redriven by an operator. Read more: 7.3 The task queue
- Model card: the model’s interface documentation: details, intended and out-of-scope use, evaluation with uncertainty, limitations, and data. Read more: 35.1 Datasheet and model card in AI Engineering
- Error budget: the bad events an objective allows over its period, as a full outage. Read more: 1.1 Design review: the tracer and the serving platform
- Thread pool: a fixed set of long-lived worker threads that execute tasks taken from a shared queue. Read more: 18.7 Thread pool in Programming and Algorithms
- Fan-in / fan-out: the number of inputs feeding one output, and the number of outputs fed by one input. Read more: 13.4 Variance propagation and initialization in Mathematics
- Exactly-once: the guarantee that each record affects state exactly once. Read more: Chapter 3: Batch and Streaming Processing in Data Engineering
- OpenTelemetry (OTel): the vendor-neutral standard for traces, metrics, and logs, made of an SDK, a collector, and exporters. Read more: Chapter 11: Observability
- span context: the triple of trace id, span id, and trace flags (plus
tracestate) that propagation carries between processes. Read more: 11.2 Tracing for the serving path - RPC: a remote call presented as a local function call through a generated stub. Read more: Chapter 3: RPC and Protocols
- KEDA: an operator that scales workloads on external metrics by creating and driving an HPA. Read more: 10.7 Durable and worker images and charts
- Consumer group: a set of consumers that divide a topic’s partitions among themselves; different groups each see every message. Read more: 5.3 Coordination and technology choice
- graceful shutdown: stop accepting, let in-flight work finish within a bound, then exit 0. Read more: 1.9 Async Rust and tokio: futures, tasks, channels, cancellation, hyper in Programming and Algorithms
- At-least-once: work is never dropped but may be processed more than once. Read more: Chapter 13: Case Study: Exactly-Once Event API
- CDC (change data capture): capturing a database’s changes as a stream for low-impact ingestion from OLTP systems. Read more: Chapter 1: Foundations in Data Engineering
- At-most-once: work is never processed twice but may be dropped. Read more: Chapter 13: Case Study: Exactly-Once Event API
- Consumer lag: log-end offset minus committed offset; the backlog a group still has to process. Read more: 5.3 Coordination and technology choice
- Cluster Autoscaler: the component (or Karpenter) that adds nodes when Pods cannot be scheduled and removes underused ones, which is why scaling Pods can wait on a new machine to boot. Read more: Chapter 10: Kubernetes Workloads and Deployment
- Partial failure: a remote call that times out, loses its response, or executes only partly. Read more: Chapter 3: RPC and Protocols
- Service Level Objective (SLO): a target for a defined measure of service behavior over a specified window. Read more: Chapter 13: Engineering Acronyms in Software Engineering
In this chapter you build such an engine yourself, in Go, with Temporal as the north star: history events and replay, task queues, GetVersion, Continue-As-New. Then you run the platform’s own data pipeline, training runs, evaluations, and releases on it. The arc is bottom-up. The first sections build the foundation: an append-only event log, a workflow service on top of it, a task queue with fenced leases, and the protocol and SDK that let workers poll for work. The middle sections make execution durable: activities with retries and heartbeats, deterministic replay of workflow code, durable timers, and the signals, cancellation, and sagas that let the outside world steer a running workflow. The last sections put real work on the engine: a subprocess runner that lets Go workers run Python durably, an optional Raft layer that replicates the log across three servers, and the platform workflows TrainRun, EvalSuite, and ModelRelease.
Learning objectives
- Explain durable execution as checkpointing for workflows, and why recovery by replaying an event log requires deterministic workflow code.
- Build a durable workflow engine from an event log, a task queue, and a worker SDK, and reason about its failure modes.
- Make side-effecting steps safe under at-least-once delivery with idempotency keys, and undo partial work with sagas.
- Run Python training and evaluation as durable activities that resume from checkpoints after any kill.
- Release a model through a gated, approved, canaried, and reversible workflow.
- Operate a pool of partitioned-log consumers: sizing, rebalancing, poison messages, and lag-based scaling.
Before you begin
Section titled “Before you begin”This chapter assumes the idempotency and partial-failure reasoning of RPC and Protocols and the event sourcing of Distributed Data and Caching. The engine is written in Go, so read the Go primer in Programming and Algorithms if you have not, along with Protocol Buffers and gRPC. Operating long-running workflows leans on Observability in Systems Engineering, and the partitioned-consumer material at the end assumes Messaging and Distributed Queueing from Systems Engineering.
In this chapter
Section titled “In this chapter”- The append-only event log. The segmented, fsynced write-ahead log that every other piece of the engine records into; the single source of truth.
- The workflow service. Idempotent workflow start, describe, list, and paged history over gRPC, with run state folded from the log.
- The task queue. Visibility timeouts, fenced leases, retries that end in a dead-letter queue, and long polling.
- The task protocol and workers. The task gRPC protocol, the Go worker SDK, and a worker pool that polls, executes, and reports back.
- Activities. Retries with backoff and jitter, timeouts, heartbeats, and the idempotency keys that make side effects safe to repeat.
- Deterministic replay. Workflow code that rebuilds its state by replaying history, plus Continue-As-New, history paging, and payload limits.
- Durable timers. Timers that survive restarts and fire exactly once, and a clock you can move forward in tests.
- Signals, cancellation, and sagas. How operators approve or cancel a running workflow, and how a saga undoes completed steps in reverse order.
- Subprocess activities: the Go runner and the Python helper. The file-and-exit-code contract that lets a Go worker run Python durably, resuming from the last heartbeated checkpoint.
- Raft high availability for the durable log (optional). Three replicas that agree on one log, built from the majority-intersection fact; the engine is complete without it.
- Platform workflows: TrainRun and EvalSuite. Training as segments with evaluation at fixed steps, resumable bit for bit after any kill.
- ModelRelease: gates, canary, burn check, and rollback. The release as a workflow: model card and ledger gates, human approval, a canary measured against the error budget, and a saga that rolls back.
The chapter also has a hands-on side quest, Kafka consumer groups, which puts the partitioned-consumer ideas at the end of this opening into practice.
The problem: long-running, failure-prone processes
Section titled “The problem: long-running, failure-prone processes”Before building anything, it helps to see the whole landscape the chapter covers. A real workflow is multi-step, long-lived, and distributed, and any step can fail, time out, or be interrupted by a deploy. Hand-rolled orchestration scatters state across a database column, a cron job, a retry wrapper, and a dead-letter queue, so correctness lives nowhere and bugs live everywhere. The recurring needs are always the same: retry with backoff, timeouts, idempotency, resume-after-crash, visibility, and rollback. Durable execution provides all of them as a single abstraction.
Durable execution and checkpointing
Section titled “Durable execution and checkpointing”The core pattern is to checkpoint every step. After each step’s result is known, persist it durably before moving on; on recovery, read the last checkpoint and continue, never redoing completed work.
Temporal and Cadence implement this with an event-sourced history and replay. The engine records an append-only log of every event (step scheduled, step completed, timer fired). To recover, it replays that log through your workflow code to rebuild local variables and resume at the next unexecuted line. Your workflow looks like ordinary sequential code; the engine makes it crash-proof underneath.
That design carries one real constraint. Because recovery replays your code, workflow code must be deterministic: no now(), random(), or direct I/O inline. Those go through the engine, which records their results, so replay reproduces the same path.
DBOS takes a different route, transactional checkpointing: it persists workflow and step state in Postgres transactions, so recovery is “read the last committed step and continue”. It is lighter-weight and leans on the database you already run. Either way, the idea is the same one that lets a multi-day GPU training run resume from its last saved checkpoint (Training and Frameworks), applied to arbitrary application workflows.
The worker pattern
Section titled “The worker pattern”Durable execution decouples “what to do” from “who does it”. The engine holds a durable queue of pending tasks (workflow steps and activities), and a pool of workers long-polls the queue, executes a task, and reports the result back: classic producer-consumer, made durable. Because all durable state lives in the engine, workers are stateless and horizontally scalable. They can crash, deploy, and autoscale freely; adding workers adds throughput, and losing workers just leaves tasks waiting in the queue.
The pattern also separates concerns. The workflow orchestrates; it is deterministic, the “what and when”. Activities do the side-effecting work, the “how”: call an API, run a model, write to a database. Activities get automatic retries, timeouts, and heartbeats. Named task queues route tasks to worker pools by capability (GPU workers, CPU workers, a region), which is how you would send embedding jobs to GPU workers and notifications to cheap CPU workers. None of this is exotic: it is the same worker pool as a thread pool, a Celery or Sidekiq queue, or a Kubernetes Job fan-out. Durable execution just persists the queue and the progress.
Reliability patterns around workers
Section titled “Reliability patterns around workers”Retries are guaranteed in this world, so every step must be safe to repeat, and when you cannot roll forward you must be able to undo. The standard patterns each solve one problem:
| Pattern | Problem it solves |
|---|---|
| Idempotency key | Retries must not double-apply a side effect (charge, send, insert) |
| Saga / compensation | A multi-step transaction across services can’t use 2PC; undo completed steps on later failure |
| Transactional outbox | Atomically commit a DB change and an event to publish (no dual-write inconsistency) |
| Exactly-once (effectively) | Combine idempotency + dedup so a step’s effect happens once despite at-least-once delivery |
| Circuit breaker / bulkhead | Stop hammering a failing dependency; isolate failures to one pool |
| Backpressure | Bound the queue and shed/slow producers so workers aren’t overwhelmed |
| Poison-message / DLQ | Quarantine a task that fails forever instead of blocking the queue |
At-least-once delivery is the cheap, available default. You reach effectively-once by making consumers idempotent and reconciling with compensation. There is no free exactly-once in a distributed system; you engineer it.
Temporal, Cadence, and DBOS
Section titled “Temporal, Cadence, and DBOS”The production engines make different tradeoffs, summarized here:
| Temporal / Cadence | DBOS | |
|---|---|---|
| Recovery model | Event-sourced history + replay | Transactional state in Postgres |
| State store | Cassandra / Postgres / MySQL | Postgres (the one you already have) |
| Execution | Separate worker pool polling a service | Library in your process |
| Strength | Long-lived, complex, signal-driven workflows | Lightweight, SQL-native, fewer moving parts |
| Lineage | Cadence (Uber, OSS) → Temporal (fork) | Postgres-first durable execution |
Temporal is the heavyweight: months-long workflows, signals, child workflows, timers, versioning, and multi-language SDKs, at the cost of running a cluster that itself needs a sharded store (see Distributed Data and Caching). Cadence is the open-source ancestor Temporal forked from, with the same concepts and less activity. DBOS trades some power for simplicity: if you already run Postgres, you get durable execution without a separate system.
Two neighbouring tool families are easy to confuse with these. Schedulers such as Airflow and Dagster (Orchestration and Modeling in Data Engineering) run batch DAGs on a schedule, while Temporal and DBOS run durable arbitrary code with fine-grained, event-driven, long-lived state; the tools overlap but are distinct. And distributed-compute frameworks such as Ray (Core actors and tasks, Ray Train, Ray Serve) apply the worker-pool pattern to in-memory distributed ML compute: fast task and actor scheduling across a cluster, but not durable. Lose a node mid-task and the task reruns; lose the driver and the job dies. Temporal and DBOS persist progress, while Ray maximizes throughput. A common pattern uses Ray for the heavy parallel compute inside a step and a durable engine to orchestrate the steps reliably around it.
Distributed observability
Section titled “Distributed observability”You cannot operate what you cannot see, and a workflow spanning services and hours is invisible without all three pillars of Observability: traces (one request or workflow across services, as a span tree), metrics (aggregate rates and latencies, RED and USE), and logs (discrete events). A durable workflow needs all three because it spans services and time.
Distributed tracing with OpenTelemetry propagates a trace and span context across every RPC and queue hop, so a workflow’s whole path is one connected trace that answers “where is execution #123 right now, and what is it waiting on?”. Durable engines add workflow-native visibility on top: list running and failed workflows, inspect event history, see which step is retrying. Temporal’s event log is an audit trail and a debugger. Correlation ids, threaded through logs, metrics, and traces, let you pivot between them.
Profiling
Section titled “Profiling”Observability tells you which request or step is slow; profiling tells you why, where the CPU cycles, allocations, or wait time actually go inside it. Sampling CPU profilers (py-spy, pprof, perf, async-profiler) produce flame graphs in Brendan Gregg’s style: read the widest frames, because that is where time goes. The USE method gives you a systematic way to find the bottleneck instead of guessing: for every resource, check Utilization, Saturation, and Errors.
Tail latency is where users feel pain, so profile the p99 path, not the average. Workers make this concrete: a few slow activities drag the whole workflow’s wall-clock time. The discipline is to form a hypothesis, measure, confirm, fix, and re-measure. The bottleneck is almost never where intuition first points; it is usually I/O wait, lock contention, or an N+1 query, not “the algorithm”.
Partitioned consumers
Section titled “Partitioned consumers”The durable engine owns workflow state. The other common worker shape is a pool of consumers reading a partitioned log such as Kafka, where the partition, not an engine, decides who does what. Read Messaging and Distributed Queueing first for the dynamics (queue versus log, push versus pull, delivery semantics); the runnable consumers and a hands-on lab are in the side quest Kafka consumer groups.
The partition is the unit of everything
Section titled “The partition is the unit of everything”A worker is a process that pulls work off a log and does it. Once you accept at-least-once delivery, the entire job becomes operational: distribute partitions across a pool, keep the group stable through joins and leaves, make handlers tolerate redelivery, contain poison messages, and size the pool to the backlog. The unifying constraint is the partition: it is simultaneously the unit of ordering, the unit of assignment, and the ceiling on useful parallelism within a group.
graph LR
subgraph "Topic: orders (4 partitions)"
P0[p0]; P1[p1]; P2[p2]; P3[p3]
end
subgraph "Group: order-workers"
W0[worker-0]; W1[worker-1]; W2[worker-2]; W3[worker-3]; W4[worker-4 IDLE]
end
P0-->W0; P1-->W1; P2-->W2; P3-->W3
style W4 fill:#cfcfcf,color:#444,stroke-dasharray: 4
The fifth worker is idle, because there is no partition left for it to own. This is the single most important operational fact about Kafka scaling, and it is why the KEDA replica cap in Containers, Kubernetes, and Workloads is the partition count.
Partition count is the parallelism ceiling
Section titled “Partition count is the parallelism ceiling”Within one consumer group, each partition is owned by exactly one consumer. A consumer may own several partitions, but a partition is never split across two consumers in the same group. Useful parallelism is therefore at most the partition count, and workers beyond it get no assignment and sit idle, burning resources for nothing.
Pick the partition count for your peak worker count plus headroom. Over-partitioning costs metadata and end-to-end latency; under-partitioning permanently caps throughput. And forecast ahead rather than reacting, because adding partitions later breaks key-to-partition stability: the hash target changes, so events for order_id=42 can land on a different partition than before, reordering them relative to history.
Consumer groups and rebalancing
Section titled “Consumer groups and rebalancing”When a consumer joins, leaves, or dies, the group rebalances: partitions are reassigned across the surviving members. The mechanics cause real incidents.
The classic eager (stop-the-world) protocol revokes all partitions from all members and then reassigns from scratch, so consumption pauses across the entire group during the reassignment. It is cheap to reason about and expensive in availability. Cooperative, incremental rebalancing (KIP-429, CooperativeStickyAssignor) revokes only the partitions that must move and lets everyone else keep consuming, with no global stall. Use it for any group where a stop-the-world pause hurts, which is most of them; it is what consumer-go.go and its siblings configure.
Warning: If a consumer does not call
poll()withinmax.poll.interval.ms, the broker assumes it is dead and kicks it, triggering a rebalance and reprocessing of its partitions. A handler that occasionally takes 6 minutes on a 5-minute interval will flap the whole group. Keep handlers fast, lowermax.poll.recordsso each poll batch finishes in time, or raise the interval to cover the worst case.
Scale-down needs care too. On scale-down or rollout, Kubernetes sends SIGTERM. A worker that traps it and Close()s the consumer leaves the group cleanly, so its partitions are reassigned immediately. A worker that is simply killed leaves the group waiting out session.timeout.ms before it notices, a window of stalled partitions. This is the consumer side of graceful shutdown from Containers, Kubernetes, and Workloads: trap SIGTERM, stop new work, finish in-flight work, commit, exit. All three example consumers implement it.
Idempotency and atomic state changes
Section titled “Idempotency and atomic state changes”Because delivery is at-least-once, every handler must tolerate seeing the same message twice. The first tool is an idempotency key. Before doing the work, claim the message’s natural key: Streamflow’s order-worker does SETNX order_id in Redis, with a TTL. If the key already exists, this is a redelivery, so skip the work and let the offset advance. This is the Idempotent Receiver pattern; the Redis dependency appears in the C4 component diagram from Containers, Kubernetes, and Workloads.
The second is the transactional outbox. The “wrote to the database but crashed before producing the event” hole is real. Close it by writing business state and the outgoing event into the same database transaction (an outbox table); a separate relay, or CDC, reads the outbox and publishes. State and event now commit atomically, with no lost or phantom events (microservices.io: Transactional Outbox).
The third is the order of offset commits. Commit offsets only after durable work, and batch commits for throughput. Committing before the work is at-most-once (loss on crash); committing after is at-least-once (a duplicate on crash, absorbed by the idempotency key). The examples set enable.auto.commit=false and commit explicitly after handle() returns.
Retries, poison messages, and the dead-letter queue
Section titled “Retries, poison messages, and the dead-letter queue”Failures come in two kinds. A transient failure (a database blip, a downstream timeout) should be retried with backoff; it will likely succeed. A poison message (malformed, referencing deleted data, failing a hard invariant) will never succeed, and retrying it forever blocks the partition behind it. Because ordering is per partition, a stuck message is head-of-line blocking: everything behind it on that partition waits.
The dead-letter queue breaks the block. After N attempts, route the poison message to an orders.DLQ topic and move on, unblocking the partition. Alert on DLQ depth; a human or a repair job drains it. The DLQ edge appears in the Streamflow container diagram of Containers, Kubernetes, and Workloads. Rather than blocking live traffic with in-line backoff, some designs also route transient failures to tiered retry topics (orders.retry.5s, orders.retry.1m, orders.retry.10m), each consumed by a delayed worker. Live consumption never stalls, retries escalate through the tiers, and whatever survives all tiers lands in the DLQ. Finally, bound the time per message: one slow handler must not block the batch, so set a per-message deadline and dead-letter the overrun, or you reintroduce the slow-handler rebalance described above.
Sizing and operating the pool
Section titled “Sizing and operating the pool”Partitions are the maximum parallelism, so size the partition count for peak workers plus headroom; you cannot scale useful workers past it. Within that limit, lag is the master signal. Consumer lag is the log-end offset minus the committed offset, the number of messages behind. It is the right input for both alerting and autoscaling, because it directly measures whether the pool is keeping up, unlike CPU, which a worker blocked on I/O leaves low while lag explodes.
KEDA scales on lag. Containers, Kubernetes, and Workloads wires a KEDA ScaledObject to consumer-group lag: lag rises, KEDA raises worker replicas (capped at the partition count), the Cluster Autoscaler adds nodes if pods are Pending, new members join, a rebalance assigns them partitions, and lag drains. KEDA can also scale to zero when idle. When lag keeps rising but replicas already equal the partition count, more pods do nothing; they sit idle. The lever then is more partitions, with a one-time reshuffle of the key-to-partition mapping.
The techniques of this section, and when to reach for each, are collected here for reference:
| Technique | When to apply |
|---|---|
| One consumer per partition (group sizing) | Always: never run more workers than partitions |
| Cooperative/incremental rebalancing | Any group where stop-the-world stalls hurt |
Tune max.poll.records / max.poll.interval.ms | When handlers are slow enough to risk false rebalances |
| Clean leave on SIGTERM | Every worker (fast partition reassignment on scale-down) |
| Idempotency key (SETNX) | Deduping redelivered messages |
| Transactional outbox | Atomic “update state + emit event” |
| Commit after durable work + batch commits | Every at-least-once consumer |
| Dead-letter queue | Any consumer that can receive poison messages |
| Tiered retry topics | When in-line retries would block live traffic |
| Scale on consumer lag (KEDA) | Sizing the worker pool to backlog |
| Add partitions (not pods) at the cap | When lag rises with replicas already = partitions |
Patterns worth internalizing
Section titled “Patterns worth internalizing”A handful of ideas recur through every section that follows:
- Persist progress, then proceed. Checkpoint each step so the computation is crash-proof; recover by reading the last durable state, or by replaying the log.
- Queue plus stateless worker pool. Push all state into a durable store so workers become disposable and horizontally scalable.
- At-least-once plus idempotency equals effectively-once. There is no free exactly-once; engineer it with keys, dedup, and compensation.
- Saga, not 2PC, across services. Roll forward where you can, compensate where you can’t.
- Trace across hops, profile within them. Observability locates the slow thing; profiling explains it. Measure before optimizing, every time.
Where this chapter connects
Section titled “Where this chapter connects”The ideas here reach across the library. Idempotency, retries, and partial failure in RPC and Protocols are why durable execution exists. Event sourcing, replay, and the log as truth in Distributed Data and Caching are how recovery reconstructs state, and the same chapter covers the sharded store Temporal needs underneath (Cassandra or Postgres). Checkpointed training pipelines in Training and Frameworks use the same checkpoint pattern with a different payload. Traces, metrics, logs, RED and USE, and SLOs in Observability are how you operate long-running workflows. Partitioned logs, consumer groups, and lag in Messaging and Distributed Queueing are the dynamics the partitioned consumers operate, and KEDA lag scaling and SIGTERM drains in Containers, Kubernetes, and Workloads are how you scale and stop the worker pool. Decorators wrapping workflows and retries in Coding and Design Patterns show how an engine’s API is built.
Industry leans on the same patterns:
| Company | The pattern they lean on | Instance |
|---|---|---|
| Uber | Durable execution + worker pools | Built Cadence → Temporal for trips/payments |
| Stripe | Idempotent durable workflows | Idempotency keys, saga-style money movement |
| Netflix | Workflow orchestration at scale | Conductor; durable media pipelines |
| Datadog / Honeycomb | Distributed tracing as a product | OpenTelemetry, span-based debugging |
| Coinbase / Snap | Temporal for critical workflows | Payment and provisioning sagas |
| Training labs | Checkpoint/replay for long jobs | Resumable distributed training runs |
If you want to feel the ideas before reading the build, a short experiment with an off-the-shelf engine is worth an afternoon. Build a three-step pipeline (download, embed, index) as a Temporal or DBOS workflow and kill the worker mid-run; it resumes without redoing completed steps, and that is durable execution. Make a step non-idempotent (“charge the card”), force a retry, and watch the double charge; then fix it with an idempotency key. Add a compensation (a refund) and trigger a downstream failure to see the saga unwind. Finally, instrument the workflow with OpenTelemetry traces and profile the slowest activity to find where the wall-clock time actually goes.
Key terms
Section titled “Key terms”- Durable execution: persisting the progress of a long-running computation step by step, so it can crash and resume where it left off without redoing completed work; Temporal, Cadence, and DBOS provide it.
- Transactional checkpointing: durable execution by storing workflow and step state in database transactions, so recovery reads the last committed step and continues; the approach of DBOS, an alternative to event-sourced replay.
- Worker pool: stateless processes that long-poll a durable queue, execute tasks, and report results; because all state lives in the queue or engine, workers can crash, deploy, and autoscale freely.
- Transactional outbox: writing business state and the outgoing event in the same database transaction, with a separate relay publishing from the outbox table, so state and event commit atomically with no dual-write inconsistency.
- Head-of-line blocking: one stuck item at the front of an ordered queue or partition stalling everything behind it; a dead-letter queue breaks it for poison messages.
- Tiered retry topics: a chain of delayed retry topics (for example 5 s, 1 min, 10 min), each read by its own consumer, so transient failures retry without stalling live consumption and survivors land in the dead-letter queue.
- Consumer group rebalance: reassigning a topic’s partitions among a consumer group’s members when one joins, leaves, or is presumed dead; within a group each partition has exactly one owner, so the partition count caps useful parallelism.
- Cooperative rebalancing: an incremental rebalance protocol that revokes only the partitions that must move while other members keep consuming, unlike eager rebalancing, which stops the whole group.
- USE method: Brendan Gregg’s checklist for finding a bottleneck: for every resource, check utilization, saturation, and errors.
- Flame graph: a visualization of sampled stack traces in which each frame’s width is the share of time spent in it; the widest frames show where time goes.
Further reading
Section titled “Further reading”- Temporal documentation and DBOS documentation, the primary references for this chapter.
- Apache Cadence documentation, Temporal’s open-source ancestor.
- Temporal, “What is durable execution”.
- microservices.io, the saga pattern and the transactional outbox.
- OpenTelemetry documentation, for distributed tracing.
- Brendan Gregg, Systems Performance, for profiling.