Deterministic Replay Isn't Free: Evaluating Temporal vs. Event-Sourced Sagas
DEV Community

Deterministic Replay Isn't Free: Evaluating Temporal vs. Event-Sourced Sagas

Disclosure: I'm the founder of JoobQ, a self-hosted job queue and durable workflow engine. We talk to teams evaluating Temporal every week, and we regularly tell some of them to pick Temporal over us. This post is the exact tradeoff breakdown we share with them.

Most teams don't choose a workflow engine because they want a distributed systems project. They choose one because a multi-step job-charging a card, provisioning an account, sending a webhook, rolling back on failure-crashed halfway through a deploy and left production data in a half-baked state.

When engineering leaders look for a durable answer to that problem, Temporal is the default benchmark. And for good reason: Temporal's core abstraction- deterministic replay -is one of the most genuinely impressive pieces of infrastructure built in the last decade. It is also one of the most expensive abstractions you can adopt, both operationally and cognitively.

Before you commit your team to it, you should know exactly what deterministic replay buys you, what it charges you in return, and when an event-sourced saga engine like JoobQ Pro gets you the durability you need without the cluster tax.

1. What Deterministic Replay Actually Buys You

To critique Temporal fairly, you have to start with why engineers who run it in production love it. In Temporal, you write workflows as ordinary imperative code-loops, if branches, local variables, await calls-rather than YAML or state-machine graphs.

Under the hood, the Temporal Server records every workflow state transition as an append-only Event History. When a worker crashes, gets evicted from cache, or restarts during a deploy, another worker picks up the workflow task, fetches the Event History, and replays your workflow function from line one-feeding recorded results back in place of re-executing side effects-until it reconstructs the exact in-memory call stack and local variables where execution left off.

That model buys three things that are genuinely hard to replicate without it:

  • Arbitrarily long durable sleeps. A workflow can call sleep(30 days) or wait six months for an external signal. No thread or container stays pinned in memory; the History Service persists a durable timer in its internal Timer Task Queue, evicts the execution from worker memory, and wakes it up months later on whatever worker is alive then.
  • Exact mid-function resumption. Because the SDK replays the entire function to rebuild local state, you don't have to manually serialize intermediate variables into a database column between steps. Your stack frame is your state machine.
  • Auditable, versioned execution history. Every activity scheduled, started, retried, or completed-plus every signal and timer-is captured in an immutable, inspectable ledger. You can take a failed production Event History, download it, and replay it locally in a debugger to reproduce the exact failure path.

If your domain truly requires workflows that behave like immortal, single-threaded processes living for weeks or years, deterministic replay is the cleanest programming model available.

2. The Cost Side (With Receipts)

The catch is that making imperative code look immortal requires heavy machinery underneath-and strict rules on top. Those costs show up in four places.

Persisting every state transition-and paying replay debt

Temporal does not just save "step 3 succeeded." A single activity execution generates a chain of lifecycle events (scheduled, started, completed, plus workflow task boundaries) persisted to the Event History.

  • Hard history ceilings: Temporal caps a single Workflow Execution's Event History at 51,200 events or 50 MB, emitting warnings at 10,240 events or 10 MB (Workflow Execution Limits). Long-running or chatty workflows must explicitly checkpoint state and call Continue-As-New to start a fresh history chain (Continue-As-New).
  • Replay latency: Every event saved is future CPU and network work on cache miss or worker handoff. Splitting work into dozens of fine-grained activities or streaming high-frequency signals into a workflow compounds payload transfer and replay overhead.
  • Cloud usage billing: If you offload operations to Temporal Cloud, pricing is metered per Action-starting at $50 per million Actions (scaling down to $25/M at higher self-serve volumes)-plus $0.042/GB-hour for Active Storage and $0.00105/GB-hour for Retained Storage (Temporal Pricing). At high throughput with chatty workflows, Actions accumulate faster than raw job counts because every activity, timer, signal, and child workflow triggers billable state transitions.

[INSERT: Concrete Action-count calculation & monthly cost comparison linking to your benchmark repository / pricing worksheet]

The cluster's moving parts and datastore

If you decide to self-host to avoid Action-based billing, you are not deploying a single binary next to Redis. A Temporal Server consists of four independently scalable services coordinated via Ringpop membership (Temporal Server Architecture):

  • Frontend Service: Stateless gRPC gateway handling rate limiting, auth, routing, and worker polls.
  • History Service: Partitioned into History Shards (which cannot be changed after cluster initialization without migration), managing mutable state, Event History persistence, and four internal queues-Transfer, Timer, Replicator, and Visibility.
  • Matching Service: Hosts user-facing Task Queues and dispatches tasks to polling workers.
  • Worker Service: Runs internal system and background workflows.

Backing those services requires a tuned persistence store (Cassandra, PostgreSQL, or MySQL) plus a Visibility index (Elasticsearch or SQL-backed Advanced Visibility), mTLS between nodes, and careful shard-count planning (Temporal Service Configuration). Running it reliably in production is a real infrastructure commitment.

NonDeterministicError in production

Because workers reconstruct state by re-running your current code against historical events, your workflow code must be strictly deterministic. If a developer adds, removes, or reorders an activity call, timer, or child workflow-or accidentally introduces non-deterministic behavior inside workflow code-existing in-flight executions will diverge from their recorded history and fail workflow tasks with a non-determinism error (Versioning & Runtime Checking).

Worse, runtime sanity checks vary by SDK and do not catch everything (such as changed input arguments or timer durations), which means safe deployments require maintaining a Replay Testing suite against captured production histories.

Patching and versioning workflow code

In a normal web app, you ship a bug fix and move on. In Temporal, you cannot safely deploy a structural change to a workflow while older executions are still open. You have two paths, and both add ceremony:

  • Patching (patched() / getVersion): You guard new code paths behind version branches-essentially permanent-until-drained feature flags-following a three-step deploy lifecycle: add patched("my-patch"), wait until all pre-patch executions close, deploy deprecate_patch("my-patch"), wait again, then delete the branch (Patching, Python Versioning). Even ordering matters: placing an older patch check ahead of a newer one can silently route executions down stale branches or trigger non-determinism errors.
  • Worker Versioning: You tag workers with Deployment Versions so old workers keep draining old executions while new workers pick up new ones (Worker Versioning). That eliminates code-level if patched() clutter, at the cost of operating multiple concurrent worker fleets until long-lived runs finish.

None of this is a flaw in Temporal-it is the unavoidable physics of deterministic code replay. The question is whether your workloads actually need to pay that physics tax.

3. How JoobQ Pro's Event-Sourced Sagas Work Instead

Most production workflows aren't six-month state machines with arbitrary branching. They are bounded, multi-step business transactions -onboarding a tenant, processing an order, syncing a billing state, running a fan-out pipeline-where you need:

  • Typed steps with explicit dependencies and randomized-backoff retries
  • Automatic rollback (compensations) when a downstream step fails
  • Pause/resume for webhooks, human approvals, or timers
  • Survivable state across worker crashes, without operating a 4-service cluster

JoobQ takes a different architectural bet: start with an MIT-licensed, high-throughput Redis job queue, and layer JoobQ Pro on top when you need durable orchestration. Instead of forcing your application runtime to deterministically replay arbitrary imperative call stacks, the engine conducts a declarative workflow graph and folds its state from an append-only event history in Redis.

How execution works under the hood

Declarative steps, ordinary worker code. Your step handlers are normal functions-native Crystal jobs, or thin SDK workers in Python, TypeScript, Ruby, Go, Rust, Java, PHP, .NET, or Elixir talking to the self-hosted JoobQUI SDK gateway (your polyglot workers never touch Redis directly).

Engine-conducted state transitions. The joobq-pro engine owns step ordering, dependency resolution, retries, signals, timers, queries, child workflows, and workflow timeouts. Every state transition is appended to the run's Redis history, so if any worker dies mid-step, the run survives and resumes from the last committed step.

First-class Saga compensations. Each step can declare a compensating action bound to its output. When a later step exhausts retries or the workflow is canceled, the engine automatically runs compensations in reverse order (newest first). (You can watch a live failure + compensation run-and inspect the audit log-in the interactive browser simulation at www.joobq.io/console.)

Minimal operational footprint, flat pricing. One Redis instance (which most teams already run), your workers, and a single self-hosted JoobQUI container with live WebSocket triage, time-travel event history, RBAC, OIDC SSO, TOTP 2FA, and an immutable audit log-with zero payload data leaving your VPC. The core queue and SDKs are free forever; Pro is licensed flat per deployment ($149/mo) rather than metered per Action (www.joobq.io).

Real code: Crystal Engine & Polyglot SDK API

Native Crystal Workflow (src/workflows/demo/):

require "joobq"
require "joobq_pro"
module Demo
# Step 1: Reserve inventory
struct ReserveInventory
include JoobQ :: Job
@queue = "orders"
@retries = 3
property order_id : String
property sku : String
property quantity : Int32
def initialize ( @order_id , @sku , @quantity ) end
def perform
reservation_id = InventoryService . reserve ( @order_id , @sku , @quantity ) { reservation_id : reservation_id , sku : @sku , quantity : @quantity } end
end
# Compensation for Step 1: Release inventory if a downstream step fails
struct ReleaseInventory
include JoobQ :: Job
@queue = "orders"
@retries = 5
property reservation_id : String
def initialize ( @reservation_id ) end
def perform
InventoryService . release ( @reservation_id ) { released : true , reservation_id : @reservation_id } end
end
# Step 2: Charge payment method
struct ChargePayment
include JoobQ :: Job
@queue = "billing"
@retries = 3
property order_id : String
property reservation_id : String
property amount_cents : Int64
def initialize ( @order_id , @reservation_id , @amount_cents ) end
def perform
charge_id = BillingService . charge ( @order_id , @amount_cents ) { charge_id : charge_id , status : "captured" } end
end
# Compensation for Step 2: Refund payment if approval times out or fails
struct RefundPayment
include JoobQ :: Job
@queue = "billing"
@retries = 5
property charge_id : String
def initialize ( @charge_id ) end
def perform
BillingService . refund ( @charge_id ) { refunded : true , charge_id : @charge_id } end
end
# Step 3: Fulfill order after human/webhook approval
struct FulfillOrder
include JoobQ :: Job
@queue = "fulfillment"
@retries = 3
property order_id : String
property reservation_id : String
property charge_id : String
def initialize ( @order_id , @reservation_id , @charge_id ) end
def perform
ShipmentService . dispatch ( @order_id , @reservation_id , @charge_id ) { dispatched : true } end
end
# Declarative Saga Blueprint
# If `charge` fails, `release` runs automatically.
# If `approve` times out or `fulfill` fails, `refund` then `release` run in reverse order.
OrderSaga = JoobQ :: Pro . workflow ( "order-saga" ) do
step "reserve" , ReserveInventory , input : { order_id : input ( :order_id ) , sku : input ( :sku ) , quantity : input ( :quantity ) , } , compensate : compensation ( ReleaseInventory , input : { reservation_id : ref ( "steps.reserve.output.reservation_id" ) } )
step "charge" , ChargePayment , after : [ "reserve" ] , input : { order_id : input ( :order_id ) , reservation_id : ref ( "steps.reserve.output.reservation_id" ) , amount_cents : input ( :amount_cents ) , } , compensate : compensation ( RefundPayment , input : { charge_id : ref ( "steps.charge.output.charge_id" ) } )
wait_for "approve" , after : [ "charge" ] , timeout : 15 . minutes
step "fulfill" , FulfillOrder , after : [ "approve" ] , input : { order_id : input ( :order_id ) , reservation_id : ref ( "steps.reserve.output.reservation_id" ) , charge_id : ref ( "steps.charge.output.charge_id" ) , } end
end
# Enqueue a run:
# run = Demo::OrderSaga.start( # order_id: "ord_9f8a2c", # sku: "PRO-LICENSE", # quantity: 1, # amount_cents: 14_900_i64 # ) # # Deliver the external signal (e.g., from a webhook or JoobQUI console): # JoobQ::Pro.signal(run.id, "approve", {approved_by: "o**@company.com"})

Polyglot SDK Blueprint (Python excerpt): Workers in Python-or any of the other 8 SDK languages-register the same workflow as a typed blueprint over the JoobQUI gateway (Workflow Docs):

from joobq import Worker , wf , input , output , compensation worker = Worker ( gateway_url = "https://joobqui.internal.company.com" , api_key = "jq_live_..." , queue = "orders" , ) def reserve ( payload : dict ) -> dict
Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.