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 ArchitectureModern 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:
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.
The proposed solution, exemplified by the DBOS Transact library, shifts workflow orchestration into the application's existing database. The key concepts are:
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:
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`.