# Purple Flow's 512MB Workflow Engine: How AI-First Automation Runs 10,000+ Workflows Without a Database

> Source: <https://dev.to/mech_app_ai/purple-flows-512mb-workflow-engine-how-ai-first-automation-runs-10000-workflows-without-a-17i5>
> Published: 2026-11-27 20:06:39+00:00

**Recommendation:** Keep per-workflow state small and wrap the in-memory engine in an external supervisor that persists definitions and retries from the start, since a crash loses all in-flight workflows.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

Purple Flow positions itself as an AI-first n8n alternative that runs 10,000+ concurrent workflows in 512MB of RAM without a database. That constraint forces architectural decisions most workflow engines avoid: no Postgres for state, no Redis for queues, no persistent job tables. Everything lives in memory, which means the plumbing has to handle eviction, crash recovery, and LLM tool calls without the usual safety nets.

The project is early (15 GitHub stars, Show HN with 5 points), but the resource budget exposes interesting trade-offs. When you can't lean on a database to serialize workflow state or retry failed steps, you need different primitives for durability, observability, and agent coordination.

Purple Flow treats LLM calls as first-class workflow primitives, not afterthoughts bolted onto HTTP nodes. The engine embeds tool-calling loops directly into the execution graph. Instead of defining a workflow as a DAG of HTTP requests and transformations, you define it as a sequence of agent interactions where the LLM decides which tools to invoke next.

This changes the orchestration model:

The architecture assumes workflows are short-lived and LLM-driven. Long-running jobs with complex retry logic or multi-day pauses don't fit this model. The engine optimizes for rapid agent loops where the LLM makes decisions in seconds, not hours.

Purple Flow keeps all active workflow state in RAM using a hash map keyed by workflow ID. Each entry holds:

When a workflow completes or times out, the engine evicts it from memory. There's no write-ahead log, no checkpoint to disk. If the process crashes, in-flight workflows are lost.

The 10,000+ workflow claim depends on keeping per-workflow state small. A typical entry might be:

```
{
  "workflow_id": "wf_abc123",
  "status": "running",
  "current_step": 3,
  "messages": [
    {"role": "user", "content": "Scrape pricing from example.com"},
    {"role": "assistant", "tool_calls": [{"name": "http_get", "args": {"url": "..."}}]},
    {"role": "tool", "content": "{\"price\": 49.99}"}
  ],
  "created_at": 1732024800,
  "timeout_at": 1732025100
}
```

At ~5KB per workflow (assuming compact JSON and short tool outputs), 10,000 workflows fit in 50MB. The remaining 462MB handles the runtime, LLM client libraries, and HTTP server overhead.

Purple Flow uses a time-based eviction strategy:

There's no LRU cache or memory pressure detection. If you exceed 512MB, the process will OOM. The engine assumes you size your deployment to match expected concurrency.

Without a database, Purple Flow can't replay workflows after a crash. The engine treats failure recovery as an application-layer concern:

This shifts durability responsibility to the workflow author. If you need guaranteed execution, you wrap Purple Flow in a supervisor that persists workflow definitions and retries on failure.

| Failure Scenario | Purple Flow Behavior | Mitigation Strategy | 
|---|---|---|
| Process crash | All in-flight workflows lost | External supervisor retries from start | 
| LLM API timeout | Workflow marked failed, kept in memory until TTL | Client retries entire workflow | 
| Tool call exception | Workflow fails, error logged to stdout | Idempotent tools + client retry | 
| Memory exhaustion | Process OOM kills | Scale horizontally or reduce concurrency | 

Purple Flow logs workflow events to stdout in JSON format. There's no built-in metrics endpoint or trace storage. Observability depends on external log aggregation:

For production use, you'd pipe logs to Loki or Datadog and build dashboards around workflow ID patterns. The engine itself doesn't track success rates, P95 latency, or error budgets.

Purple Flow runs as a single-process HTTP server. You scale by running multiple instances behind a load balancer. Each instance is stateless (no shared memory), so workflows can't span processes.

Typical deployment:

The engine doesn't coordinate across instances. If you need workflow affinity (same workflow always routes to the same instance), you implement sticky sessions at the load balancer.

Purple Flow's core loop is a recursive agent step executor. Simplified version:

``` python
async def execute_workflow(workflow_id: str, user_input: str):
    state = {
        "workflow_id": workflow_id,
        "messages": [{"role": "user", "content": user_input}],
        "max_steps": 10,
        "current_step": 0
    }

    while state["current_step"] < state["max_steps"]:
        # Call LLM with conversation history and tool schemas
        response = await llm_client.chat(
            messages=state["messages"],
            tools=AVAILABLE_TOOLS
        )

        if response.tool_calls:
            # Execute each tool call and append results
            for tool_call in response.tool_calls:
                result = await execute_tool(tool_call.name, tool_call.args)
                state["messages"].append({
                    "role": "tool",
                    "tool_call_id": tool_call.id,
                    "content": json.dumps(result)
                })
            state["current_step"] += 1
        else:
            # LLM returned final answer, workflow complete
            return response.content

    raise Exception("Max steps exceeded")
```

The engine stores `state` in the in-memory hash map. If the process dies mid-loop, the state is gone.

Purple Flow's architecture optimizes for simplicity and low resource usage. That creates predictable failure modes:

These aren't bugs. They're trade-offs for running in 512MB. If you need durability, you add a supervisor. If you need backpressure, you add a queue in front of Purple Flow.

**Use Purple Flow when:**

**Avoid Purple Flow when:**

Purple Flow is a proof-of-concept for stateless agent orchestration. It shows you can run thousands of concurrent LLM workflows in a tiny memory footprint if you're willing to give up durability. For production systems, you'd wrap it in a supervisor that persists workflow definitions and retries on failure. For prototypes or ephemeral tasks, it's a clean way to chain tool calls without standing up Postgres.
