Scaling and high availability
How work is divided
| Process | Command | Does |
|---|---|---|
| All-in-one | tappet serve | API, UI, webhooks, triggers, timers and workers in one process. |
| API | tappet serve --role api | API, UI, webhook gateway, SSE, MCP. Enqueues executions; runs none. |
| Worker | tappet worker [--concurrency N] | Claims executions from the queue and runs them. No HTTP listener. |
In HA mode all processes share one Postgres database (TAPPET_DATABASE_URL=postgres://...):
- Queue: executions are rows in a queue table. Workers claim them with
SELECT ... FOR UPDATE SKIP LOCKED, so two workers never claim the same execution, without a separate message broker. - Leases: a worker holds a lease on each running execution and renews it with heartbeats. If the
worker dies, the lease expires (
TAPPET_LEASE_TTL, default 60 s) and another worker resumes the execution from its last checkpoint. - Leader election: schedule triggers, poll triggers, wait-timer wake-ups and retention pruning must run exactly once across the cluster. One process holds a Postgres advisory lock and runs them; if it stops, another takes over.
- Webhooks: registrations are stored in the database, so any API process can accept any webhook. Load-balance API processes freely; no sticky sessions are needed (including for SSE, which reads events from the database).
- OAuth2 refresh: a Postgres advisory lock per credential guarantees a single refresh across all processes.
- Blobs: every process must see the same blob store. Use S3 (or an S3-compatible store such as MinIO, R2, or Ceph), or a volume mounted by all processes on a single host.
Minimum HA setup
- 2 API processes behind a load balancer, on different nodes.
- 2 or more workers, on different nodes.
- Postgres with a standby and automatic failover (a managed service, or Patroni / CloudNativePG).
- S3-compatible blob storage.
TAPPET_OIDC_COOKIE_KEYset to the same value on all API processes when OIDC is used.
The Docker Compose HA example in deploy/docker-compose/ha runs this shape on one host (useful
for testing upgrades and failover); the Helm chart’s values-ha.yaml runs it across nodes.
Sizing workers
--concurrency (or TAPPET_WORKER_CONCURRENCY) is the number of executions one worker runs at
once. Executions spend most of their time waiting on APIs, so concurrency can be much higher than
CPU count:
| Workload | Starting concurrency per worker (2 vCPU) |
|---|---|
| API calls, light transforms | 64 to 128 |
| Heavy Code nodes, large item lists | 8 to 16 |
| AI agents with long LLM calls | 32 to 64 |
Watch tappet_workers_busy, tappet_queue_depth and process memory, then adjust. Scale out with
more workers when the queue depth keeps growing while workers are busy.
Autoscaling
- Workers: scale on queue depth (
tappet_queue_depth, exported by API processes) through a Prometheus adapter or KEDA, or on CPU as a simpler proxy. The Helm chart includes an HPA on CPU and memory, with an optional external-metric target for queue depth. - API: scale on CPU and request rate. Webhook ingest is cheap per request; two or three API processes handle high volumes.
Scale-down is safe: a worker that receives SIGTERM stops claiming, finishes or checkpoints its
executions within TAPPET_SHUTDOWN_TIMEOUT, and releases its leases.
Postgres sizing
Tappet’s write load is dominated by checkpoints (one row per completed node) and queue updates. Guidelines:
- Connection pool: each process opens a bounded pool; budget about 10 connections per worker and per API process, and use PgBouncer in transaction mode beyond a few hundred connections. Advisory transaction locks work with transaction pooling.
- Keep execution retention reasonable (see Retention); run data is the largest table.
wait_onlycheckpointing (TAPPET_CHECKPOINT=wait_only) cuts writes substantially for high-volume, short workflows, at the cost of re-running whole executions after a crash.
Zero-downtime upgrades
See Upgrading. In short: run migrations first (tappet migrate, backward
compatible within a minor version), then roll API processes, then workers.