




























The Postgres World is a production-ready backend for self-hosted deployments. It uses PostgreSQL for durable storage and graphile-worker for reliable job processing.
Use the Postgres World when you need to deploy workflows on your own infrastructure outside of Vercel - such as a Docker container, Kubernetes cluster, or any cloud that supports long-running servers.
Install the Postgres World package in your workflow project:
Configure the required environment variables to use the world and point it to your PostgreSQL database:
WORKFLOW_TARGET_WORLD="@workflow/world-postgres"
WORKFLOW_POSTGRES_URL="postgres://user:password@host:5432/database"Run the migration script to create the necessary tables in your database. Ensure WORKFLOW_POSTGRES_URL is set when running this command:
npx workflow-postgres-setupThe migration is idempotent and can safely be run as a post-deployment lifecycle script.
To subscribe to the graphile-worker queue, your workflow app needs to start the world on server start. Here are examples for a few frameworks:
The Postgres World requires a long-lived worker process that polls the database for jobs. This does not work on serverless environments. For Vercel deployments, use the Vercel World instead.
Use the workflow CLI to inspect workflows stored in PostgreSQL:
# Set your database URL
export WORKFLOW_POSTGRES_URL="postgres://user:password@host:5432/database"
# List workflow runs
npx workflow inspect runs --backend @workflow/world-postgres
# Launch the web UI
npx workflow web --backend @workflow/world-postgresIf WORKFLOW_POSTGRES_URL is not set, the CLI defaults to postgres://world:world@localhost:5432/world.
Learn more in the Observability documentation.
Passing100% passing
Spec compliance is tested against Next.js (Turbopack) built in production mode and started with `next start`. View CI run →
165
Passed
0
Failed
19
Skipped
184
Total
1104
Passed
0
Failed
92
Skipped
1196
Total
Last updated: 4/17/2026, 6:41:14 PM · Commit: 5889d84
All configuration options can be set via environment variables or programmatically via createWorld().
WORKFLOW_POSTGRES_URL (required)PostgreSQL connection string. Falls back to DATABASE_URL if not set.
Default: postgres://world:world@localhost:5432/world
WORKFLOW_POSTGRES_JOB_PREFIXPrefix for graphile-worker queue job names. Useful when sharing a database between multiple applications.
WORKFLOW_POSTGRES_WORKER_CONCURRENCYNumber of concurrent workers polling for jobs. Default: 10
WORKFLOW_POSTGRES_MAX_POOL_SIZEMaximum size of the internal pg.Pool used when createWorld() constructs the pool. Default: 10
For higher worker concurrency, Graphile Worker recommends setting maxPoolSize to 10 or queueConcurrency + 2, whichever is larger.
import { createWorld } from "@workflow/world-postgres";
const world = createWorld({
connectionString: "postgres://user:password@host:5432/database",
jobPrefix: "myapp_",
queueConcurrency: 20,
maxPoolSize: 20, // overrides WORKFLOW_POSTGRES_MAX_POOL_SIZE
});The Postgres World uses PostgreSQL as a durable backend:
This architecture ensures workflows survive application restarts with all state reliably persisted. For implementation details, see the source code.
Deploy your application to any cloud that supports long-running servers:
Ensure your deployment has:
start() function called on server initializationThe Postgres World is not compatible with Vercel deployments. On Vercel, workflows automatically use the Vercel World with zero configuration.
start() on server initialization; not compatible with serverless platformsFor local development, use the Local World which requires no external services.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。