1 of 14

Interpreter for Cadence/Temporal

Workflow Engine

Quanzheng Long

2 of 14

Cadence/Temporal is HARD to learn!

  • It’s powerful, but really complicated
  • Knowing how to write a sample is far from feeling comfortable to write and maintain production code

3 of 14

Proposal: better interface on top of C/T

  • Keep almost SAME POWER
  • Hide/Abstract the hard concepts:
    • Separation of Workflow vs Activity
    • Replay & non-determinism & versioning
    • Weird exception handling
    • Workflow threads
    • Sticky Cache
    • TestEnv

4 of 14

Comparison summary

  • Separation of Workflow vs Activity
  • Unit test
  • Replay & non-determinism & Versioning
  • Other interface contract
  • Workflow threads
  • Operation

Potential benefits:

  • Every dev will become experts of using Cadence easily
  • Deliver same products >2 times faster than using raw Cadence
  • Much easier to maintain

5 of 14

Separation of Workflow vs Activity

Cadence workflow:

  • Schedule timer/activities/etc
  • Deciding flows/parallel

Cadence activity:

  • Communicate with externals

iWF framework:

  • No distinction of workflow vs activity.
  • No restriction in iWF workflow code

* Exception for long running activity

6 of 14

Replay & non-determinism & Versioning

Cadence workflow:

  • Must be replay-safe
  • Must use versioning if not safe
  • Must use replay test to safeguard the determinism
  • Code gets really messy after several iterations

iWF framework:

  • None!!!

7 of 14

Unit tests

Cadence workflow:

  • Super hard to write & maintain
  • TestEnv is really tricky
  • Super hard to debug when things go wrong
    • Error messages are not obvious to fix the issues. It requires you to understand the internal details

iWF framework:

  • Only need the well-known unit test library:
    • E.g. For Java only Junit is enough!

8 of 14

Other interface contract

Implicit contracts in Cadence:

  • Signal cannot return data or throw back exception
  • Signal method is in a different thread
  • Query cannot modify states
  • Regular exception will block workflow
  • Checked exception is prohibited
  • Exception from activity is wrapped

iWF framework:

  • All is explicitly defined in APIs
  • Uses standard exception handling models

9 of 14

Workflow threads

Cadence multi-threading:

  • Super complicated to understand
  • Consuming lots of resources in Java SDK, not easily scale up(each instance can only run thousands of threads)

iWF framework:

  • Super straightforward
  • Super efficient using lightweight threading, support millions of threads per instance

10 of 14

Operation

Cadence operation

  • Lots of complicated metrics to monitor/understand that is not related to business. Especially for stickiness

iWF framework:

  • Operation is like operating a microservice (in fact it is).
  • No stickiness concept exposed

11 of 14

Setup projects using Cadence/Temporal

Cadence workflow:

  • Need to configure for every project that Start/Query/Signal workflows

iWF framework:

  • For workflow workers, or any project to Start/Signal/Query workflow, only need a URL of iWF server. Nothing else

12 of 14

Other benefits of iWF

  • No need to do continueAsNew. Potentially, iWF can do this underneath
  • Super easy to build SDKs for different languages
  • Easy to migrate between Cadence/Temporal/Others

13 of 14

iWF cons & counter arguments

  • Programming model change.
    • In raw Cadence, the workflow is programmed as a single function. In iWF, the workflow is required to modeled into explicit states of different Java classes.
    • In certain use cases, iWF may lose some “readibility” after dividing into multiple state files.
    • “Normal looking” workflow code is a “trap” in Cadence/Temporal.
  • Counter argument
    • In most cases, users usually don’t need too many states if workflow is designed correctly.
    • Multiple states will get some visibility like this if we build some visualization tool in IDE for iWF states which is not possible to build for Cadence workflow code.
    • In practice, forcing design in multiple states make it easier for multiple developers working in parallel
    • This iWF programming model change is very similar to AWS SWF-> AWS Step Functions. Step Functions has become very successful.

14 of 14

iWF vs C/T vs SWF vs Step Functions

Prog. model

Prog. language

Unit test

Power

Replay-safe code

Using versioning API

iWF

Explicit State machines

Native languages

Yes. Native libs likt Junit

Full power as Cadence

Not required

Not needed

Cadence

Native languages

Yes, TestEnv, hard to use

+ Search attribute, long running activity, reset, etc

Required

Supported

SWF

Implicit State machines

Native languages

limited

Required

Not supported

Step Function

Explicit State machines

JSON

Limited, less than SWF

Not required

Not needed