Architecture Overview
OpenWorkflow uses a worker-driven architecture:- Workers run in your infrastructure and poll the database for work
- Clients create workflow runs by writing to the database
- Database (PostgreSQL or SQLite) stores all workflow state
Requirements
For most production use cases, use PostgreSQL 14 or later:- The connecting user needs permissions to create schemas and tables (for migrations)
- Workflow state is stored in the configured schema (default:
openworkflow)
Production Setup
1. Set Up PostgreSQL
Provision a PostgreSQL database. Any PostgreSQL 14+ instance works.2. Configure the Backend
Edit youropenworkflow.config.ts to set the Postgres URL and namespace:
OPENWORKFLOW_POSTGRES_URL,
OPENWORKFLOW_NAMESPACE_ID, and OPENWORKFLOW_SCHEMA env vars to dynamically
set the Postgres URL, namespace, and schema, but you can set this up however
you’d like.
3. Migrations
Migrations run automatically when the backend connects. OpenWorkflow creates:<schema>.workflow_runs- Stores workflow run state<schema>.step_attempts- Stores step execution history
4. Start Workers
Dockerfile Templates
If you deploy workers in containers, these Dockerfile templates are a good starting point:Scaling Workers
Horizontal Scaling
You can run multiple worker instances for high availability and throughput. Workers coordinate through the database:- Each workflow run is claimed by exactly one worker at a time
- Workers use atomic database operations to prevent duplicate processing
- If a worker crashes, its workflows automatically become available to others
Concurrency Tuning
Theconcurrency setting controls how many workflow runs a single worker
processes simultaneously. Each workflow occupies one slot while executing.
- Start with
concurrency: 10and adjust based on workload - Increase for I/O-bound workflows (lots of API calls, database queries)
- Decrease for CPU-bound workflows (heavy computation)
- Monitor database connection usage - each worker maintains a connection pool
Monitoring
Dashboard
OpenWorkflow includes a built-in dashboard for monitoring:- Workflow run status (
pending,running,completed,failed,canceled) - Step execution history
- Error details and retry attempts
- Real-time updates
Prometheus Metrics
The dashboard process exposes a Prometheus-compatibleGET /metrics endpoint.
See the Prometheus guide for scrape configuration and alert
examples.