Menu
InfoQ Architecture·July 23, 2026

Database-Backed Workflow Orchestration for Durable Execution

This article challenges the conventional wisdom of using external orchestrators for complex, fault-tolerant workflows, particularly in AI applications. It proposes leveraging existing databases for durable execution by treating workflow state as data. The approach aims to reduce operational overhead, increase reliability, and improve visibility into workflow status by consolidating orchestration logic within the database.

Read original on InfoQ Architecture

The Challenge with Traditional Workflow Orchestration

Modern applications, especially those involving AI, frequently require complex workflows. Traditional architectures often rely on external orchestrators and message queues (like RabbitMQ or Kafka) to manage these processes. While seemingly robust, this distributed approach introduces several pain points:

  • Increased Complexity: More moving parts (queues, separate orchestrator services, worker pools) mean a more complex system to build and maintain.
  • Reduced Reliability: Each external component represents an additional point of failure, paradoxically decreasing the overall reliability despite the intent to ensure durability.
  • Higher Latency and Cost: Moving data between multiple services and the orchestrator incurs network latency and operational overhead. AI computations are expensive, and redundant executions due to failures are costly.
  • Poor Visibility: It's often difficult to inspect the state of a workflow, what's in a queue, or why something failed without significant custom logging and monitoring.
  • Vendor Lock-in: Many external workflow solutions are proprietary or tightly coupled to specific cloud providers.
ℹ️

Workflows Are Data

The core premise of DBOS Transact is that workflow execution state should be treated as data. Since databases are inherently designed for reliable data storage and manipulation, they are uniquely suited to manage workflow durability.

Database-Backed Durable Execution

The proposed solution, exemplified by the DBOS Transact library, shifts workflow orchestration into the application's existing database. The key concepts are:

  • Checkpointing Workflow State: The execution state of workflows and individual steps is regularly checkpointed into database tables. This ensures durability, similar to how video games autosave progress.
  • Exactly-Once Execution: By storing state in the database, the system can reliably resume interrupted workflows from the last checkpoint, preventing duplicate work.
  • Leveraging Database Primitives: Standard database features like transactions, `SKIP LOCKED` queues, and unique primary keys are used to manage workflow steps, concurrency, and fault tolerance without external services.
  • Simplified Architecture: Eliminates the need for separate orchestrators, message queues, and worker pools, reducing infrastructure and operational burden.

Core Mechanisms

Building a database-backed workflow library involves defining workflows and steps as ordinary functions. The library handles the persistence and orchestration logic under the hood. For instance, in a Postgres-based implementation, this might involve:

  • Workflow Table: A table to store the state of each workflow instance (e.g., `workflow_id`, `status`, `current_step`, `input_data`, `output_data`).
  • Step Queue Table: A table acting as a queue for executable steps. Workers poll this table using `SELECT ... FOR UPDATE SKIP LOCKED` to acquire tasks atomically, ensuring only one worker processes a given step.
  • Result Storage: Storing results of completed steps in the database, allowing subsequent steps to retrieve necessary data without inter-service communication.
sql
CREATE TABLE workflow_states (
    workflow_id UUID PRIMARY KEY,
    status TEXT NOT NULL,
    current_step TEXT,
    input_json JSONB,
    output_json JSONB,
    last_updated TIMESTAMPTZ DEFAULT NOW()
);

CREATE TABLE step_queue (
    step_id UUID PRIMARY KEY,
    workflow_id UUID REFERENCES workflow_states(workflow_id),
    step_function_name TEXT NOT NULL,
    payload JSONB,
    scheduled_time TIMESTAMPTZ DEFAULT NOW()
);

This pattern is database-agnostic, though the article highlights Postgres as a suitable choice due to its robust transactional capabilities and advanced features like `SKIP LOCKED`.

Workflow OrchestrationDurable ExecutionDatabase-as-OrchestratorPostgreSQLFault ToleranceAI WorkflowsDistributed TransactionsSystem Reliability

Comments

Loading comments...