The Postgres-Native State Machine: Unpacking earendil-works/absurd

How a single SQL file replaces complex distributed coordinators to bring durable execution to the everyday database.

7 min read · earendil-works/absurd

A massive bank vault door with intricate clockwork gears mounted directly onto its steel surface. It represents bolting complex execution logic directly onto the secure, durable PostgreSQL database.
Absurd materializes queues, runs, and state machines directly into Postgres.

I generally try to avoid bringing in extra complexity if I can avoid it, so I wanted to see how far I can go with just Postgres. To this end, I wrote Absurd 1, a tiny SQL-only library with a very thin SDK to enable durable workflows on top of just Postgres — no extension needed.

Armin Ronacher, Creator · Absurd Workflows
Key Takeaways

The Database as the Coordinator

The software industry spent a decade extracting state and orchestration out of the database into complex microservices. Systems like Temporal provide incredible durability but require deploying and managing separate clusters, external metrics, and distinct storage layers. Absurd represents a violent pendulum swing in the opposite direction.

It proves that by aggressively leveraging modern PostgreSQL features, developers can achieve durable execution without a single external coordinator service. The entire brain of this system is just a set of Postgres tables and PL/pgSQL functions. It uses a pull-based model where a claim task function relies on Postgres locking semantics to hand work to workers safely.

The ctx.step() Crash Recovery Simulator

Checkpoints Over Replays

Traditional durable execution often requires deterministic code because it replays the entire function from the start upon failure. Absurd takes a different path by focusing on explicit checkpoints.

When a developer wraps a side effect in a step context, the SDK checks the database. If a result exists, it returns it immediately. If not, it executes the code and persists the result. This checkpointing system anchors progress so the system does not fall back to the beginning if a failure occurs.

def run_workflow(ctx: TaskContext):
    # If this succeeds, the result is saved in Postgres.
    # If it crashes later, this step is skipped entirely on restart.
    data = ctx.step('fetch_data', fetch_from_api)
    
    # The workflow will resume exactly here.
    processed = ctx.step('process', lambda: process_data(data))
    return processed
An extreme close-up of a heavy steel mountaineering piton hammered firmly into a textured vertical rock face. A thick, braided climbing rope is clipped securely through a carabiner attached to the piton.
Checkpoints act as pitons on a rock face, preventing the system from falling back to the start.

The AI Workload Sweet Spot

Developers are adopting this experimental framework for generative AI pipelines. Complex AI workflows often involve chaining multiple expensive LLM API calls.

If a worker crashes on step three of a five-prompt chain, Absurd resumes at step three. This saves the significant cost and latency of hitting the API for the first two steps all over again.

Absurd is a durable execution system: it saves checkpoints as your task progresses, so a crashed task resumes from the last checkpoint, not from scratch. For quick jobs, this distinction doesn't matter much. For multi-step workflows with expensive API calls, it's the whole point.

François Leblanc, Developer/Experimenter · leblancfg.com

Pushing Back Against Complexity

The project was created by Armin Ronacher, known for building Flask and Rye. It was born out of fatigue with the operational bloat required to run reliable background jobs for mid-sized architectures.

Hedcut portrait of Armin Ronacher (mitsuhiko)

The Boundaries of Postgres

Absurd wins on operational simplicity but places significant pressure on a single relational database. Massive horizontal scale will still demand dedicated systems like Temporal.

However, it is not just a standard job queue. While tools like Solid Queue retry failed jobs from the beginning, Absurd is a true durable state engine that remembers exactly where it left off.

FeatureAbsurdTemporalStandard Job Queue
InfrastructurePostgres onlyDedicated cluster & DBRedis or Database
State LocationDatabase (PL/pgSQL)Server & SDKsQueue only
Recovery StyleStep CheckpointsFull Event ReplayRetry from Start
Best ForAI Pipelines, SimplicityMassive Scale, EnterprisesSimple Background Tasks
A split composition. Left: a chaotic factory floor with tangled pipes. Right: a single, massive, immaculate iron anvil on a clean floor.
The operational overhead of distributed systems (left) versus the single-dependency simplicity of Absurd (right).