Purple Flow's 512MB Workflow Engine: How AI-First Automation Runs 10,000+ Workflows Without a Database
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.
What AI-First Means Architecturally
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:
- Semantic routing replaces explicit branching. The LLM interprets user intent and picks the next step based on context, not hardcoded if/else logic.
- Tool schemas become workflow nodes. Each function signature (search, scrape, transform) is a callable unit the agent can chain together.
- State is conversational. Workflow context is a message history, not a key-value store. The engine passes prior tool results as assistant messages to the next LLM call.
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.
In-Memory State Management
Purple Flow keeps all active workflow state in RAM using a hash map keyed by workflow ID. Each entry holds:
- Current execution step
- Tool call history (inputs and outputs)
- LLM conversation thread
- Pending callbacks or webhooks
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.
Eviction Policy
Purple Flow uses a time-based eviction strategy:
- Workflows older than a configurable TTL (default 5 minutes) are purged.
- Completed workflows are removed immediately after returning results.
- Failed workflows are kept until TTL expires to allow retry or inspection.
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.
Failure Recovery and Retry Logic
Without a database, Purple Flow can't replay workflows after a crash. The engine treats failure recovery as an application-layer concern:
- Idempotent tool calls. Each tool (HTTP request, database query, file write) should be safe to retry. The engine doesn't track which tools succeeded before a crash.
- Client-side retries. If a workflow fails mid-execution, the caller must resubmit the entire request. The engine doesn't store partial progress.
- Webhook-based checkpoints. For long workflows, you can insert webhook callbacks at key steps. The external system tracks progress and resubmits if needed.
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 |
Observability Without Persistence
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:
Structured logs per step. Each tool call emits a log line with workflow ID, step index, tool name, and latency.
No distributed tracing. If a workflow calls external APIs, you need to correlate logs manually or inject trace IDs into tool arguments.
Memory usage is opaque. The engine doesn't expose Prometheus metrics for active workflow count or memory consumption. You monitor at the OS level.
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.
Deployment Shape
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:
- Container: 512MB memory limit, 0.5 CPU
- Replicas: 5-10 instances for high availability
- Load balancer: Round-robin or least-connections
- LLM backend: OpenAI API, Anthropic, or self-hosted Ollama
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.
Code Snippet: Workflow Execution Loop
Purple Flow's core loop is a recursive agent step executor. Simplified version:
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.
Likely Failure Modes
Purple Flow's architecture optimizes for simplicity and low resource usage. That creates predictable failure modes:
- Memory exhaustion under load. If workflows arrive faster than they complete, the in-memory map grows until OOM. No backpressure mechanism.
- Lost workflows on crash. Any deployment, restart, or OOM kill drops all active workflows. No graceful shutdown or state export.
- No retry for transient LLM errors. If the LLM API returns 429 or 503, the workflow fails immediately. The engine doesn't implement exponential backoff.
- Tool call timeouts block execution. If a tool hangs (slow HTTP request, unresponsive database), the workflow waits indefinitely. No per-tool timeout enforcement.
- No workflow prioritization. All workflows are equal. A flood of low-priority requests can starve high-priority ones.
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.
Technical Verdict
Use Purple Flow when:
- You need lightweight agent orchestration for short-lived workflows (under 5 minutes).
- You can tolerate lost workflows on crash and retry from the client.
- You want LLM-native primitives (tool calling, semantic routing) without database overhead.
- You're prototyping agentic workflows and need fast iteration.
Avoid Purple Flow when:
- You need guaranteed execution or multi-day workflows.
- You require detailed observability (traces, metrics, replay).
- You need workflow state to survive process restarts.
- You need backpressure, rate limiting, or priority queues.
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.
Source Links Primary repository: github.com/leetheguy/purple_flow Show HN discussion: news.ycombinator.com/item?id=50560170
Comments
No comments yet. Start the discussion.