---
title: "Run Dex in Production"
description: "A checklist for running Dex in production, with a link to the page that covers each item, from the server topology and capacity to backup, upgrades, and monitoring."
canonical_url: "https://docs.superdurable.io/components/production/"
source: "docs/content/components/production.mdx"
locale: "en"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Run Dex in Production

**dexcli dev** runs everything on one machine for development. This page
covers a self-hosted production server, which you run next to your own Workers.
It lists what to decide and set up before launch, and each item links to the
page with the details.

<a id="smallest-deployment"></a>

## Smallest real deployment

- One Dex Server node, with a hot standby if you need fast failover.
- One object storage bucket and prefix for the cluster.
- Authentication turned on before the API is reachable.
- TLS in front of the API port, or a private network. See [TLS](https://docs.superdurable.io/reference/server/authentication.md#tls).
- [Retention](https://docs.superdurable.io/components/production.md#retention) long enough for client retries.
- Metrics served and alerts on the node and its lease.

The [minimal configuration](https://docs.superdurable.io/components/production.md#minimal-configuration) below sets up this deployment.

## Before you launch

| Item               | What to know                                                                                                                                                                                                                                              | Details                                                                                                                                                                                 |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Topology           | One active node serves the cluster. Hot standbys can take over.                                                                                                                                                                                           | [Dex Server](https://docs.superdurable.io/components/server.md), [Lease, hot standby, and step down](https://docs.superdurable.io/reference/server/high-availability.md)                |
| Capacity and cost  | CPU is the limit. Start small; see [Sizing](https://docs.superdurable.io/components/production.md#sizing).                                                                                                                                                | [Performance](https://docs.superdurable.io/intro/performance.md), [Grow past one node](https://docs.superdurable.io/intro/limits.md#grow-past-one-node)                                 |
| Storage            | Object storage holds all server state. db9 (a separate PostgreSQL-compatible database product; stock PostgreSQL is not supported) can replace it.                                                                                                         | [Object storage and backup](https://docs.superdurable.io/reference/server/object-storage.md), [Dex Server dependencies](https://docs.superdurable.io/components/server.md#dependencies) |
| Search backend     | Built-in search needs no database. Heavy search can use PostgreSQL or ParadeDB.                                                                                                                                                                           | [Search backends](https://docs.superdurable.io/reference/server/search.md)                                                                                                              |
| Configuration      | `serve` reads one YAML file. Start from the [minimal configuration](https://docs.superdurable.io/components/production.md#minimal-configuration).                                                                                                         | [Install and configure server-zd](https://docs.superdurable.io/reference/server/configuration.md)                                                                                       |
| Retention          | Size it for client retries, as [Retention](https://docs.superdurable.io/components/production.md#retention) explains. The default is in [Defaults to change](https://docs.superdurable.io/components/production.md#defaults-to-change-before-production). | [Retention reference](https://docs.superdurable.io/reference/server/configuration.md#retention)                                                                                         |
| Backup and restore | The bucket prefix is the only source of truth. Version or replicate it, and practice a restore.                                                                                                                                                           | [Backup and restore](https://docs.superdurable.io/reference/server/object-storage.md#backup-and-restore)                                                                                |
| Kubernetes         | Run the server as a StatefulSet with graceful shutdown.                                                                                                                                                                                                   | [Kubernetes deployment](https://docs.superdurable.io/reference/server/kubernetes.md)                                                                                                    |
| Authentication     | Off by default. Require a bearer credential before you expose the API.                                                                                                                                                                                    | [Authentication](https://docs.superdurable.io/reference/server/authentication.md)                                                                                                       |
| Monitoring         | Serve metrics on their own listener. Alert on a node that is not serving and on failed lease renewals.                                                                                                                                                    | [Metrics and alerts](https://docs.superdurable.io/reference/server/metrics.md)                                                                                                          |
| Workers            | Workers connect out. Size their task slots, and stop them gracefully in a deploy.                                                                                                                                                                         | [Workers and the task queue](https://docs.superdurable.io/reference/server/workers.md)                                                                                                  |
| Upgrades           | Upgrades roll forward. Read each release's notes first; some need every process stopped.                                                                                                                                                                  | [Upgrades and compatibility](https://docs.superdurable.io/reference/server/upgrades.md), [Agent release notes](https://docs.superdurable.io/reference/agents/upgrades.md#release-notes) |
| Your database      | Writes from Steps must be safe to repeat.                                                                                                                                                                                                                 | [Dex and Your Database](https://docs.superdurable.io/components/your-database.md)                                                                                                       |
| Code changes       | Keep old Step types and RPCs until their Flows close.                                                                                                                                                                                                     | [Change Flow Code](https://docs.superdurable.io/concepts/change-flow-code.md)                                                                                                           |

<a id="defaults-to-change-before-production"></a>

### Defaults to change

| Default                                                                                          | Change it                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Closed runs, with their Step history, are deleted after 7 days. A deleted run frees its Flow ID. | Set a longer [retention](https://docs.superdurable.io/components/production.md#retention), and copy what you must keep to [your own database](https://docs.superdurable.io/components/your-database.md).                                                        |
| Public API authentication is off, so any client that reaches the server can call it.             | Configure an authenticator before you expose the port, as the [minimal configuration](https://docs.superdurable.io/components/production.md#minimal-configuration) does. See [Authentication](https://docs.superdurable.io/reference/server/authentication.md). |
| Step retries stop after 4 hours, and then the Flow fails.                                        | Set a retry policy or a failure route in [StepOptions](https://docs.superdurable.io/concepts/step.md#stepoptions).                                                                                                                                              |

<a id="sizing"></a>

### Sizing

As a starting point derived from the benchmark, a 2-vCPU node peaked near
1,800 SYNC Steps per second and a 16-vCPU node near 8,400. Start small and
watch CPU. Past one node, run separate clusters.

<a id="retention"></a>

### Retention

Set `retention.closedFlowDuration` to cover your longest client retry window,
since a deleted run frees its Flow ID. Copy data you must keep longer to your
own tables with [Attribute Store sync](https://docs.superdurable.io/components/your-database.md).

<a id="minimal-configuration"></a>

## Minimal configuration

This configuration runs one Dex Server node on Amazon S3, with authentication on:

```yaml
cluster:
  nodeId: dex-zd
objectStore:
  region: us-east-1
  bucket: BUCKET
  prefix: PREFIX
localStorage:
  directory: /var/lib/dex-server-zd/store
lease:
  duration: 60s
retention:
  closedFlowDuration: 7days
metrics:
  listen: 0.0.0.0:9090
auth:
  authenticators:
    - kind: staticTokens
      file: /etc/dex-server-zd/tokens.yaml
```

Replace `BUCKET` and `PREFIX` with your bucket and key prefix. The token file lists SHA-256 hashes of the bearer tokens that Workers and Clients send; [Authentication](https://docs.superdurable.io/reference/server/authentication.md) shows its format and the JWT option. `cluster.nodeId`, `objectStore.bucket`, and `localStorage.directory` are required, and the node ID and partition count cannot change after the first start. The 60-second lease suits a single node; with hot standbys, keep the 10-second default. [Install and configure server-zd](https://docs.superdurable.io/reference/server/configuration.md#minimal-production-configuration) explains every key.

Give each Worker and Client its token through the SDK's `credential` option;
a file credential rereads the token file, so you can rotate tokens without a
restart. [Send credentials from Workers and Clients](https://docs.superdurable.io/reference/server/authentication.md#sdk-credentials)
lists the option in each SDK. The API port serves plaintext gRPC: put TLS in
front of it, or keep it on a private network. [TLS](https://docs.superdurable.io/reference/server/authentication.md#tls)
lists the matching SDK option.

## When something goes wrong

- A Flow that does not advance or that failed:
  [Troubleshoot a Flow run](https://docs.superdurable.io/reference/web/debugging.md).
- Recover a Flow after a fix by running it again from an earlier Step:
  [Time Travel](https://docs.superdurable.io/concepts/change-flow-code.md#time-travel).
- Agent sessions in production:
  [Agents reference](https://docs.superdurable.io/reference/agents.md).

## Next

- [Failover and Deploys](https://docs.superdurable.io/concepts/failover-and-deploys.md): What runs again when a Worker crashes, a Dex Server node fails over, or you deploy new code, and what you must do about it.
- [Dex Cloud](https://docs.superdurable.io/components/choose-how-to-run.md#dex-cloud): Super Durable runs the server for you.
