# Why Durable

This page is the decision before the install. It sets Durable beside the
five shapes a team usually weighs, in one table, with the measured
numbers and the cases where another shape wins. The commands it names
are `durable-sdk doctor --host`, `durable-sdk explain <id>`,
`durable-sdk ledger export` and `durable-sdk ledger verify --file <export>`.

## The answer in one paragraph

Durable is a TypeScript framework used as a library. It runs inside
your app, on the Postgres database the app already has, with a minute
cron as the only moving part outside the request path. A
workflow is a keyed saga: one run per intent, every side effect a step
that reads before it writes and carries an undo or the reason it cannot,
a failed run held for a person instead of retried in the dark. Four
things set it apart, and each is checkable in your database or in your
tree rather than taken on trust: the ledger, the undo, the doctor and
the legibility. [Concepts](https://durablesdk.com/docs/concepts.md) has the model in one page;
[Recipes](https://durablesdk.com/docs/recipes.md) has four products built on it (an order saga, a
campaign send, an intake with an approval, a booking with reminders).

## What you are choosing between

Five shapes hold the same kind of work. Each is described by what its
own documentation says it does, never by how well it does it.

**A workflow cluster you run.** A server holds every workflow's event
history. Workers you run poll the server, execute the workflow code and
report each event back, and the code is written deterministic so a
worker can replay the history and resume where the last one stopped.
Temporal is the example. The shape gives signals and queries into a
running workflow, timers that last as long as you like, child workflows
and SDKs in several languages. It needs the server, the workers and the
discipline of deterministic code.

**A hosted event-function service.** An event reaches the vendor's
service, the service invokes a function of yours and memoizes each
step's result, so a retry resumes at the first step that has no result
yet. Inngest and Trigger.dev are examples. The shape gives fan-out from
events, a dashboard of runs and steps, and no worker of your own to
keep up. The run's state lives with the vendor.

**A platform's durable functions.** The hosting platform's own workflow
package marks a function as a workflow and its calls as steps. The
platform's queue drives the steps, memoizes their results and parks a
run through a sleep or a hook in the platform's persistence. The shape
gives durability with nothing to install and a trace viewer in the
platform's dashboard. The state and the run live in the platform.

**A queue with retries.** A job is a message on a broker: Redis under
BullMQ, Postgres under pg-boss. Workers take jobs, a failed job is
retried with a backoff and then set aside, a delayed job fires later,
and a job id or a singleton key collapses a repeat. The shape is the
cheapest way to do work later, and it is enough when a job is one call
that can safely run again.

**A hand-rolled job table.** A status column, a cron that selects the
pending rows, a try/catch around the work. Every team has written one.
It holds until the second retry rule, the crash between the write and
the status update, or the question of what a job changed.

## Side by side

|                              | Durable                                                                                  | A cluster                                                | Hosted functions                                           | Platform functions                             | A queue                                | A job table              |
| ---------------------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------- | -------------------------------------- | ------------------------ |
| Where it runs                | inside your app's functions; no worker                                                   | a server plus workers you run or rent                    | your functions, invoked by the vendor's service            | the platform's functions and queue             | a broker plus workers you run          | your app plus a cron     |
| Where the state lives        | your Postgres, the `durable` schema: one record, every view derived from it              | the server's event history                               | the vendor's store                                         | the platform's persistence                     | the broker                             | your table               |
| How a repeat is deduplicated | an intent key, a pure function of the input; one run per key while the key lives         | a workflow id you supply                                 | an event id or an idempotency key you supply, for a window | an idempotency key you supply                  | a job id or a singleton key you supply | a unique index you write |
| Undo                         | a compensation declared per step; each undo a ledger row with what it found and restored | the saga pattern, written by hand in the workflow code   | by hand                                                    | by hand                                        | none                                   | none                     |
| The audit                    | an append-only, hash-chained ledger of before and after images; `verify` walks it        | the event history: inputs and results, kept for a period | the run's steps and their outputs, in the dashboard        | the run's trace, in the dashboard              | logs                                   | logs                     |
| Errors                       | a refusal is a value with a remedy; a failed run waits in limbo for a person             | exceptions and a retry policy                            | exceptions and retries                                     | exceptions and retries                         | retries, then a failed set             | try/catch                |
| Checks before a deploy       | the doctor's rules, offline                                                              | none in the box; a replay test you write                 | none                                                       | none                                           | none                                   | none                     |
| Legibility to an agent       | every refusal explained offline, every page as Markdown, OpenAPI, `AGENTS.md`            | a dashboard and a CLI                                    | a dashboard                                                | a dashboard                                    | a dashboard, or none                   | none                     |
| Leaving                      | your tables stay; `durable-sdk ledger export` takes the ledger                           | an export of the history                                 | your functions stay; the history is the vendor's           | your code stays; the history is the platform's | the jobs drain; your workers stay      | nothing to leave         |

Every column but the last takes a key you supply, so the row on
deduplication is about who computes it. Durable derives the key from
the input itself (`key: ["checkoutId", "requestId"]`), refuses a key that
reads the clock, and creates the key and the run in one transaction.
[Guarantees](https://durablesdk.com/docs/concepts/guarantees.md) states the exactly-once and the
at-least-once lines; [The queue vocabulary](https://durablesdk.com/docs/compare/queues.md) maps
the sixteen semantics of a queue onto Durable one by one.

## Against each product

Eleven products, each a walk in prose from its own documentation with
the page every beat reads under Sources:
[Trigger.dev](https://durablesdk.com/docs/compare/trigger-dev.md), [Inngest](https://durablesdk.com/docs/compare/inngest.md),
[the Workflow SDK](https://durablesdk.com/docs/compare/workflow-sdk.md),
[Upstash Workflow](https://durablesdk.com/docs/compare/upstash-workflow.md),
[Cloudflare Workflows](https://durablesdk.com/docs/compare/cloudflare-workflows.md),
[Hatchet](https://durablesdk.com/docs/compare/hatchet.md), [DBOS](https://durablesdk.com/docs/compare/dbos.md),
[SQS](https://durablesdk.com/docs/compare/sqs.md), [Temporal Cloud](https://durablesdk.com/docs/compare/temporal-cloud.md),
[Restate](https://durablesdk.com/docs/compare/restate.md) and
[Step Functions](https://durablesdk.com/docs/compare/step-functions.md). Each walk opens with what
the product gives, as its documentation describes, then what that leaves
you to write, then the same work under Durable, and closes with the case
where the other wins. [Compared](https://durablesdk.com/docs/compare.md) is the whole table, one
column per product and fifteen topics, every cell with its source.
[Why Durable](https://durablesdk.com/why) steps the queue's walk beat by beat and each
product's on its own page.

## What only Durable holds

> Diagram: The four things and where each is checked: two by a query on your database, two by a command over your tree.

**The ledger.** Every write a step makes leaves a row with the image it
found and the image it left, chained by hash per scope, append-only by
interface, by retention and by a database trigger, and never pruned: a
finished run's steps, inputs and outputs are held 90 days and an
unledgered finished run 14 days by default (`retention.windows`), the
ledger's rows for the life of the database.
The operator API's `verify` read recomputes every chain and names the
first broken link, and `durable-sdk ledger verify --file <export>` walks
an export of it offline; [How it works](https://durablesdk.com/docs/why/how-it-works.md) follows
one run row by row.

**The undo.** A step that changes the world declares its compensation
with its effect, or says `irreversible: "<why>"`, and the door refuses
one that says neither (`step.undo.effect`). When a later step fails the
completed steps' undos run in reverse, each its own `<step>.undo` row
with what it found and what it restored, so the undo is a record and
not a hope; [Paradigms](https://durablesdk.com/docs/why/paradigms.md) says why a compensation
beats a rollback here.

**The doctor.** `durable-sdk doctor --host` runs every rule over the
tree with no database and no network, and prints a failed rule as one
line with its fix. A key that reads the clock, a step with no undo and
no reason, a secret in a step output: each is refused before a deploy
rather than found after one; [The doctor](https://durablesdk.com/docs/guide/the-doctor.md) has
the rules.

**The legibility.** Every refusal a door throws has an id, and
`durable-sdk explain <id>` prints its sentence, its trap and its remedy
offline; the same table answers an error code such as `StaleWrite` and
a run id. Every docs page is Markdown at `/docs/<slug>.md`, the API is
an OpenAPI document and every app carries an `AGENTS.md`, so an agent
reads the product the way it reads the code;
[MCP and agents](https://durablesdk.com/docs/reference/mcp-and-agents.md) lists the surfaces.

## Numbers, measured

Every figure below is the newest develop bench's reading, written into
`tests/bench/targets.json` from the run's artifact as each pin's
`latest` beside the floor the bench gates against; the floors only
tighten, and a pull request that loosens one says why. The figures were
measured on a two-vCPU CI runner with the database on the same machine
and the dispatcher in the test process.

| Quantity                                            | Measured                                                                                                                 |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Runs of a ten-step workflow a minute                | 2,604 at one starter, up to 4,024 at eight, 4,045 at thirty-two                                                          |
| Wall time of one such run, mean                     | 23 ms at one starter; 14.9 ms at eight, the starters overlapping; 14.8 ms at thirty-two, the starters queued on one pool |
| A ledger append, p95                                | 4.3 ms uncontended (p50 3.7 ms); 69.2 ms with eight writers on one scope                                                 |
| Emit to delivered, p95                              | 27 ms on the inline drain; 2.8 s when the wake crosses the platform's queue                                              |
| A timer, sleep to resumed, p95                      | 5.0 s                                                                                                                    |
| Facts delivered one at a time a minute              | 10,549 at one partition, 14,307 at eight                                                                                 |
| Facts delivered to a batch listener of 100 a minute | 251,468 at eight partitions                                                                                              |
| Rows and bytes a run                                | 12 rows, 4,241 bytes; a million runs a day is 12 million rows                                                            |
| After a restart under load                          | 0 facts lost, 0 writes doubled, 0 runs in limbo                                                                          |

Every row is develop's bench run 40945075490 of 2026-10-29: the runs,
the facts, the rows and the restart on a two-vCPU Intel Xeon Platinum
8573C runner, the appends, the wakes and the timer on a two-vCPU AMD
EPYC 7763, each with the job's Postgres on the same machine. The eight
starters run in one process on a ten-connection pool, and thirty-two
buy nothing over eight: the bound at eight is the process's pool and
the database's CPU, not the engine. A ten-step run of read steps is 12
statements and no transaction with `completion: "behind"` and 22 under
the default, so a project's throughput is the database's statement rate
divided by that. A production database does better on that bound, with
more CPU and more connections than the runner's container. A database
reached over a network adds a round trip to each of a run's statements,
so one run takes longer than it does on loopback. The architecture
scales by partitions in parallel and by batch listeners today, and by
scopes sharded across databases next; a wait that is lost or late waits
at most a minute for the sweeper.

## When to pick another

- **Workers in several languages.** A cluster's SDKs cover Go, Java,
  Python and more. Durable is TypeScript, and a second language is a
  later plan, not a promise.
- **A managed history-replay UI.** A cluster's or a hosted service's
  dashboard replays a workflow's history step by step. Durable's console
  shows runs, steps, images and limbo, and a replay is a test file
  (`durable-sdk replay <runId>`).
- **Millions of concurrent timers.** A sleeping run is four rows and
  about 1.7 kB with its indexes (1,601 MB for a million, measured on the
  SDK's own schema), the read that finds the due ones is one index probe
  of six buffers at a million, and a sleep has no cap of the engine's:
  the workflow's own `timeout`, when declared, is the one bound. But a
  timer fires at minute precision through the sweeper, a backlog of due
  timers drains at about fifty a minute, and a preview deployment has no
  cron, so a timer there resumes at the next request. A cluster is built
  for that volume of timers.
- **A workflow that must run outside Postgres.** Durable's guarantees
  are Postgres transactions, and there is no second store.
- **Fire-and-forget work.** A job that is one call, can run again and
  changes nothing worth imaging wants a queue, not a ledger row.

## What Durable is not

Not a managed runtime for arbitrary code: the hosted platform runs apps
built on the SDK's template, with the routes the package binds and the
configuration it reads, never a container or a function handed to it
outside the template. Not open source: the packages are source-available
under their licence, the licence forbids offering them as a hosted
service, and the platform's own code is never published. Not a cluster,
a broker or a second database: a cron and Postgres are the whole of what
it needs. [FAQ](https://durablesdk.com/docs/operate/faq.md) answers the shorter questions.

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/why/compared.md, then decide whether Durable fits before adopting it; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
