Skip to main content

Dex vs. Temporal

View as Markdown

Dex and Temporal both run processes that survive crashes, restarts, and long waits. Temporal replays workflow code against an Event History kept in a database, while Dex saves each Step's result and runs as one binary on object storage.

Watch on YouTube: Why Dex is lighter than Temporal

Differences at a glance

Measured numbers come from the dex-vs-temporal-demo repository and the Dex Performance page.

TopicTemporalDex
Worker memory and CPUIn a 512 MB container, the Worker was OOM-killed, and 715 messages got no reply. With 2 GB and a cache of 50 Workflows, it peaked at 581.6 MiB and 36.3% CPU.In 512 MB, the Worker peaked at 85.5 MiB and answered all 3,000 messages. With 2 GB, it peaked at 79.8 MiB and 17.4% CPU.
Server throughputTemporal Cloud's default limit is 500 actions per second per Namespace.One Dex Server node on S3 ran 1,772 SYNC Steps per second on 2 vCPU and 8,403 on 16 vCPU. The 16 vCPU node answered 67.3k Attribute-read RPCs per second.
Running the serverFrontend, History, Matching, and Worker services on Cassandra, MySQL, or PostgreSQL, plus a Visibility store.One binary. Its only required dependency is object storage: Amazon S3, Google Cloud Storage, Azure Blob Storage, Aliyun OSS, Tencent COS, or an S3-compatible store such as MinIO. db9 can take its place.
Long-running processesAn Event History holds at most 51,200 events or 50 MB. A longer process needs Continue-As-New in your code.Dex keeps each run's newest events and prunes older ones. The run keeps going without a new run.
Data sizeA payload holds at most 2 MB. A self-hosted server warns at 512 KB.A value holds up to 16 MiB, and a Flow run up to 64 MiB of active state, by default.
Going back to an earlier pointReset terminates the current run and starts a new run with a new Run ID.Time Travel moves the same run back to an earlier point. The Run ID stays the same, and the run gets a new run attempt.
Features only in DexThe page gives the workaround in Temporal for each feature.Flow designs drawn from source, forms generated in Dex Web, Clone fork, Connectors, SkipTimer, waits for a Step or an Attribute, and reads without a Worker.
Changing codeA deploy that changes the commands of an open run fails its Workflow Task with a nondeterminism error. Patching or Worker Versioning keeps open runs working.Each Step runs the code of the Worker that takes it. The demo's change needed no versioning code.
Writing codeWorkflow code must be deterministic. The demo's reply-with-approval Workflow has 26 lines.Steps are ordinary code. The same Flow has 26 lines.

Architecture

The Temporal Worker caches Workflow state in memory. The Dex Worker reads large values through a blob cache on disk.

Replay and saved Step results

The two engines continue a run in different ways after a Worker stops.

Temporal. A Workflow is one function. The server records an Event History, "a complete and durable log of everything that has happened in the lifecycle of a Workflow Execution". When the run is not in a Worker's cache, a Worker runs the function again from the beginning. Recorded Activity results are returned instead of running the Activities again. The commands the code produces are checked against the history, and a mismatch is a nondeterminism error. Clock reads, random numbers, and I/O go through Temporal APIs or into Activities. An Activity can run more than once: "Temporal recommends that Activities be idempotent" (Activity Definition).

Dex. A Flow is a set of Steps. Each Step returns a decision that names the next Steps or completes the Flow. Dex saves each finished Step's result, its Attribute writes, and the decision together. A Worker continues from that saved state with the next Step. Work that was in progress may be retried under its retry policy, so each Step must be idempotent. Failover and Deploys lists what runs again in each case.

What they share

  • A server records each run's progress outside your process. After a crash, the run continues from that record.
  • Workers in your own process pull tasks from the server. Your code never runs inside the server.
  • Timers are durable. A run that waits on a Timer or a message holds no Worker.
  • Temporal Activities and Dex Step methods have a retry policy and timeouts. Their default backoff is the same: 1 second, doubling up to 100 seconds, with no attempt limit. Dex also stops retrying a Step after 4 hours by default; see Limits. A Temporal Workflow Task retries on its own schedule, and a Temporal Workflow Execution has no retry policy by default.
  • A run has a business ID. At most one run with that ID is open at a time.
  • A unit of work can run more than once. Code that calls another system passes an idempotency key.

Terms map

TemporalDexNotes
Workflow, Workflow ID, Run IDFlow, Flow ID, Run IDSame roles.
Workflow code between ActivitiesStep decisions: GoTo, GoToMany, GracefulComplete, DeadEndControl flow is data that Dex saves with each Step.
ActivityThe Execute method of a StepOne retry unit. Give each durable call its own Step.
Local ActivityClosest: an ASYNC StepBoth trade some durability for latency. See SYNC and ASYNC Steps.
Timer, sleepTimer in a Step's WaitForBoth durable.
SignalChannel messageTemporal accepts a Signal with no Worker online. In Dex, the FlowService request PublishToChannel stores a Channel message with no Worker online. See Send a command at most once.
QueryGetAttributes, or a read-only RPCDex Server answers GetAttributes itself, with no Worker online. A Query and a read-only RPC run a handler on a Worker. See Server-side Attribute reads.
UpdateRPC that writes Attributes or publishes to a ChannelBoth need a Worker.
Workflow variablesAttributesDex saves them. Temporal rebuilds them by replay.
Child WorkflowSubFlow
Task QueueTask queueA Flow names its task queue at start and keeps it. Inside a task queue, Dex routes by Flow type.
Sticky executionSticky routingBoth are best effort: each first offers the task to the previous Worker for a few seconds, then to any Worker. A Temporal Worker that misses its cache replays the Event History. A Dex Worker needs no history cache.
Search AttributesIndexed Attributes
Workflow ID Conflict Policy, for an open Workflow ID. Workflow ID Reuse Policy, for a closed one.ID reuse policy, for open and closed Flow IDs. Start request ID.The start request ID lets Dex recognize a retried start request. See StartFlowOptions.
CancellationAn RPC cancels Steps by Step type. StopFlow stops the Flow.In both, your Worker code stops its external work cooperatively. Dex discards anything a canceled attempt returns later. See Cancel running Steps.
ResetTime TravelSee Going back to an earlier point.
Continue-As-New, to keep the history smallNot neededSee The history limit.
Patching, Worker VersioningNot neededSee Changing code.
ScheduleA Flow that loops on a TimerSee Cron schedule.
NexusNo direct equivalentA service in another team starts a Flow or calls an RPC over the FlowService API.
Temporal Web UIDex Web

Dex evolved from iWF. An iWF State corresponds to a Dex Step, and WaitUntil corresponds to WaitFor.

Videos

The videos are in English.

Next