Sagas vs Queues: Choosing Durable Workflows with DBOS or Temporal

Architecture

Learn when a task queue is enough and when a business process needs durable workflow state, retries, timeouts, and compensating actions with DBOS or Temporal.

TL;DR

  • A queue distributes jobs. A durable workflow records a multi-step process, its decisions, timers, retries, and current progress.
  • Keep a simple queue for independent work. Reach for workflow orchestration when a process has dependencies, long waits, external callbacks, approvals, or compensating actions.
  • A saga coordinates committed local transactions across services. Compensation is a new action, not a rollback, and it can fail too.
  • DBOS persists workflow state in PostgreSQL and fits teams that want a database-centered application model. Temporal uses a dedicated service and event history for durable orchestration across workers and services.
  • Neither tool makes third-party side effects exactly once. Design idempotency and reconciliation at every external boundary.

Why queues become hard to operate as a business process grows

A task queue accepts work and lets workers process it asynchronously. This is a strong fit for a bounded operation such as resizing one uploaded image, generating a report, or sending a notification. The producer should be able to record the request, enqueue it, and let a worker retry a safe unit of work if a transient failure occurs.

Now consider onboarding an enterprise customer. The application creates a tenant, provisions identity-provider configuration, imports users, creates billing records, waits for a domain verification callback, and notifies an account owner. Some steps take seconds, others may take days. A queue can execute each step, but a queue alone does not define the durable business process. Application code starts accumulating status columns, retry timestamps, compensating jobs, callback handlers, and scheduled reconciliation tasks.

The resulting system is not automatically wrong. It is simply implementing a workflow engine in application tables and worker conventions. The useful question is whether the implicit machinery is already expensive to understand, test, and operate. Durable execution tools make the process model explicit and preserve enough state to resume it after a worker or application process disappears.

Queues and workflows are complementary. A workflow engine still dispatches work to workers. It adds a durable coordinator for the sequence and state around that work. Use the smallest model that fully represents the business contract.

Queue, workflow, and saga mean different things

A queue represents pending units of work

A queue stores messages or jobs until a consumer handles them. It commonly provides delivery, acknowledgement, retry, and sometimes delayed execution. A job should have a stable identifier, bounded inputs, and a clear completion condition. Delivery may be repeated after worker failure, so handlers must be idempotent or deduplicated. Celery's documentation, for example, explains that late acknowledgement can cause a task to execute more than once after a worker crash and therefore requires idempotent task behavior. Celery task acknowledgement and retries

A queue does not necessarily own the meaning of “the customer is onboarded.” It knows a task was delivered or completed. The application may keep that business state elsewhere.

A durable workflow represents progress through a process

A workflow coordinates steps and decisions. It can wait for an activity, schedule a timer, receive a signal or callback, branch on a result, and continue later. Durable execution records enough history or checkpoints for a replacement worker to reconstruct the workflow state after a crash. Temporal describes workflow execution as replaying workflow code against event history, while outside-world operations belong in Activities. Temporal concepts and event history

That division matters. Workflow code must be deterministic when replayed. Network calls, random values, and current-time reads belong in activities or workflow APIs that record their outcomes. The engine can then replay the decision path without repeating an external call merely because a worker restarted.

A saga represents distributed local transactions and their recovery

A saga is a sequence of local transactions across services or data stores. If a later step cannot complete, the process may run compensating transactions for prior committed steps. AWS describes choreography, where participants react to events, and orchestration, where a coordinator directs the sequence. Choreography can suit a small number of participants; orchestration makes dependencies more visible as the process grows. AWS saga patterns

Compensation does not restore the past atomically. If a payment was captured and a shipment was created, a refund and shipment cancellation are new operations with their own failure modes. A compensation may be unavailable, delayed, or require a human decision. The workflow must represent “compensation pending” and “manual reconciliation required” as real states.

Use a decision test before adding orchestration

Start with the process requirements, not a vendor comparison. A queue is usually enough when the work item is independent, short or bounded, has no meaningful intermediate business state, and can safely be retried or dead-lettered. A scheduled job or a few queue handlers can remain easier to run than a workflow platform for this case.

Consider durable workflow orchestration when several of these apply:

  • Steps depend on earlier results and must resume at the right point after a deployment or process crash.
  • The process waits on a human, webhook, payment settlement, or other event that may arrive much later.
  • Timers, deadlines, cancellation, or escalation are part of the business promise.
  • Multiple committed effects require explicit forward recovery or compensation.
  • Support and operations need to inspect an execution, understand its last successful step, and safely retry or cancel it.
  • Teams repeatedly write custom state machines, reapers, retry schedulers, and reconciliation jobs for the same process.

This is not a count-based rule. One long-running payment dispute process can justify orchestration, while a dozen independent email jobs may not.

Model a workflow around business state

Use explicit states that a product, operator, or customer can understand. Avoid a single status = failed for every outcome. A provisioning workflow might be requested, creating_tenant, waiting_for_domain, importing_users, active, compensating, or manual_review. Store a reason code, the responsible step, and timestamps for transitions.

For each step, specify its input, output, timeout, retryable errors, idempotency key, and compensation if one exists. Classify errors before adding retries. A connection reset may be transient. A rejected identity provider configuration is likely permanent until an operator or customer changes it. Retrying permanent failures wastes capacity and makes the actual issue less visible.

Here is a framework-neutral outline for an order workflow. The code is pseudocode: persist workflow transitions and invoke network operations through an activity or job handler.

async def fulfill_order(order_id: str):
    reservation_key = f"order:{order_id}:inventory"
    payment_key = f"order:{order_id}:payment"

    reservation = await activity(
        "reserve_inventory",
        order_id,
        idempotency_key=reservation_key,
    )
    await record_state(order_id, "inventory_reserved", reservation.id)

    payment = await activity(
        "authorize_payment",
        order_id,
        idempotency_key=payment_key,
    )
    await record_state(order_id, "payment_authorized", payment.id)

    try:
        shipment = await activity("create_shipment", order_id)
        await record_state(order_id, "fulfilled", shipment.id)
    except PermanentShippingError:
        await record_state(order_id, "compensating")
        await activity("void_authorization", payment_key)
        await activity("release_inventory", reservation_key)
        await record_state(order_id, "cancelled")

This sketch intentionally leaves important implementation choices visible. A real system must persist each step outcome, distinguish failures before and after a provider accepted a request, and handle ambiguous responses before repeating an operation. Model compensation state independently so a failed refund or release can be retried and surfaced to operations.

Compare DBOS and Temporal by operating model

DBOS: workflow durability backed by PostgreSQL

DBOS is designed around durable workflow and step functions with PostgreSQL persistence. Its architecture documentation describes recording workflow inputs, step outcomes, and final results in the database. This can be a natural fit when a team already operates PostgreSQL confidently and wants workflow state close to its application data. DBOS architecture

Database-centered durability brings responsibilities with it. Workflow history and step output retention need explicit policies. Checkpoint writes share a database's capacity envelope unless you isolate them. For production, understand the supported deployment topology, recovery behavior, schema upgrades, retention, and operational controls for the exact DBOS version and language SDK you choose. Do not assume that adding annotations alone gives high availability; the database and process recovery strategy remain part of the design.

DBOS documents that application writes and workflow checkpoints can share a transaction through its data source integrations, enabling atomic database effects for those operations. That guarantee has a boundary: it cannot atomically commit a write in PostgreSQL and an action at an unrelated payment provider. DBOS durable execution overview

Temporal: a dedicated workflow service and event history

Temporal separates application workers from a Temporal Service that persists workflow event history and schedules workflow and activity tasks. A worker can replay workflow code against that history after a restart. Activities perform calls to the external world, and activity retry policies, timeouts, and heartbeats support recovery from activity failures. Temporal Activities

This model is useful when workflows cross service boundaries or teams need a dedicated control plane and execution history. It also means operating or adopting a service with its own capacity, namespaces, task queues, versioning practices, access control, and retention behavior. Temporal Cloud can change the operational tradeoff, but then evaluate its current commercial terms and requirements directly rather than treating self-hosted and managed deployments as equivalent.

Temporal's documentation cautions that an Activity can execute more than once even though the workflow tracks the logical activity execution. If a call succeeds remotely and the worker crashes before reporting completion, a retry may repeat part of that operation. Activities that cause side effects still need idempotency or reconciliation. Temporal Activity execution and idempotency

Build a practical comparison around constraints

QuestionDBOS tends to fit whenTemporal tends to fit when
Where should durable state live?A PostgreSQL-backed application model is desirable and fits team operations.A dedicated workflow service and event-history model fit the platform architecture.
How broad is the workflow boundary?Workflows are close to the application and its database transactions.Several worker fleets or services need a shared workflow control plane.
What operations must be staffed?Database capacity, backups, schema lifecycle, and DBOS recovery.Temporal service or cloud operations, worker fleets, namespaces, and history lifecycle.
What evidence should operators inspect?Persisted workflow and step state with the chosen DBOS tooling.Workflow execution history, activity attempts, and Temporal operational tooling.
What should decide?Application fit, supported language SDK, transaction needs, and PostgreSQL operational limits.Workflow complexity, service boundary, SDK support, service operations, and history needs.

Validate the table against the current product versions, SDKs, and deployment options. A tool comparison goes stale quickly. Prototype one representative failure path in each candidate: kill a worker after a remote provider accepts a request, restart a worker during a timer, deploy a compatible workflow code change, and inspect whether an operator can determine what to do next.

Keep external effects idempotent and recoverable

At-least-once delivery is common in queues and workflow activities because retrying after uncertainty is safer than silently losing work. Exactly-once execution across a network is not a reasonable assumption. The provider may commit an operation while the caller times out before receiving the response.

Use a stable idempotency key derived from the logical business operation, not the retry attempt. Store the key and request fingerprint in your own database. If the provider supports idempotency, send that key on every retry. If it does not, query by a stable external reference before issuing a potentially duplicate mutation. Keep a reconciliation path for cases where the response remains ambiguous.

Make compensation explicit and observable. A refund request can be pending, rejected, or require manual review. A reservation release can race with fulfillment. Record both the original action and its compensation, and preserve an audit trail. For financial systems, pair workflow control with database invariants such as the balanced ledger approach described in our PostgreSQL double-entry ledger guide.

For work that needs only a single durable operation and quota-aware dispatch, a queue may still be the correct execution primitive. See how to protect shared worker pools with tenant quotas. The workflow can submit activities to such a pool where that boundary is useful.

Plan workflow evolution and production operations

Long-running workflows outlive individual deployments. Treat workflow definitions and stored payloads as durable interfaces. Add fields with defaults, tolerate older payload versions, and keep old worker code available until in-flight executions can safely move forward. Temporal exposes workflow versioning mechanisms for replay compatibility. Other engines have their own compatibility rules; follow the versioned guidance for the library and SDK in use.

Define operational controls before launch: who may cancel or signal an execution, how to retry a failed step, when to escalate a stuck process, and how to prevent a manual retry from duplicating a payment or shipment. Track age by workflow state, activity attempt counts, time waiting for external input, compensation backlog, and terminal failures. An “open workflow count” alone cannot distinguish healthy long waits from stuck executions.

Set retention deliberately. Detailed histories are useful for diagnosis and audit, but they consume storage and may contain sensitive data. Avoid putting credentials or unnecessary personal information in workflow inputs, event payloads, or activity results. Define deletion and archival policies that satisfy product and regulatory needs.

Finally, rehearse failure paths with realistic boundaries. Stop workers mid-activity, make a provider timeout after accepting an operation, deliver duplicate callbacks, let a timer fire during a deploy, and make a compensation fail. Confirm the resulting state is understandable and recoverable. Durable execution provides a foundation; the application still owns the semantics of safe business recovery.

Frequently asked questions

When should I use a workflow engine instead of a task queue?

Use a task queue for independent, bounded jobs that can be retried safely. Use a durable workflow when the process spans dependent steps, waits for external events or timers, needs visible progress, or must resume after a restart without losing its place. A workflow can use a queue to execute its individual activities.

Are saga compensations the same as database rollbacks?

No. A database rollback undoes uncommitted changes within one transaction. A saga compensation is a new business operation that attempts to counter an already committed effect. It can fail and needs its own retry, alerting, and reconciliation policy.

Does durable execution guarantee an external API call happens exactly once?

No. A worker can call a provider successfully and crash before recording the result. Use provider-supported idempotency keys, persist stable operation identifiers, and reconcile ambiguous outcomes. Durable workflow state supports recovery but cannot make an external system transactional.

Choose the simplest system that preserves the business promise

Queues are a good abstraction for distributing independent work. Durable workflows become valuable when the process itself has state, time, dependencies, and recovery obligations. A saga is the consistency strategy for a sequence of local transactions, while a workflow engine can provide the durable coordination around that strategy.

Compare DBOS and Temporal using your data boundary, deployment model, supported language SDKs, failure scenarios, and operational skills. Then prototype the failure cases before committing to a platform. If your team is planning a multi-step provisioning, payments, or integration system, talk with our engineering team about designing its recovery behavior before the first incident defines it for you.

Dumb Potato Editorial

Putting this into practice?

Share the problem you’re solving and the tradeoffs you’re weighing with our engineering team.

See how we help with web applications

Discuss your project