Modal Title
Open Source / Software Development

Meet Cadence: Workflow Engine for Taming Complex Processes

The Cadence code platform and workflow engine can abstract away the most difficult complexities in developing high-scale distributed applications.
Jan 27th, 2022 4:00am by and
Featued image for: Meet Cadence: Workflow Engine for Taming Complex Processes
Feature image via Pixabay  
Ben Bromhead
Ben Bromhead is co-founder and chief technology officer at Instaclustr, which provides a platform around open source data technologies.

Developers building any modern application face the challenge of complex interactions with third-party APIs, internal services and long-running business processes. These processes require developers to track complex states, enable responses to asynchronous events and achieve communication with external dependencies that are potentially unreliable.

Developers regularly approach these complex needs with equally complex solutions — rigging together systems involving stateless services, databases, retry algorithms and scheduled job queues.

Emrah Seker
Emrah is a staff software engineer at Uber. His software development experience covers a wide span from kernel-level programming to distributed web services. He loves working on cloud computing and highly scalable systems. Emrah’s previous companies include Box, Microsoft and Siemens.

However, these unwieldy systems bury the application’s business logic beneath all that complexity and often face availability issues due to their reliance on dispersed and untested components.

Ultimately, developer productivity suffers under the weight of maintaining these sprawling and burdensome systems.

Cadence is an open source fault-oblivious stateful code platform and workflow engine specifically designed to solve this development challenge. Originally developed and open-sourced by Uber — and now adopted and developed by an increasing number of companies including Uber and Instaclustr — Cadence can abstract away the most difficult complexities associated with developing high-scale distributed applications.

How Does Cadence Work?

Cadence preserves the entire state of an application in durable virtual memory not associated with any specific process. The stored application state includes all call parameters and returned results for user-defined activities. It then uses that information to catch up and replay workflows that get interrupted.

Cadence has libraries that enable developers to create and coordinate workflows using popular languages such as Java, Go, Python and Ruby. Cadence services, such as workers, are largely stateless and leverage a data store for task/workflow persistence. Supported storage options include open source Cassandra and MySQL/PostgreSQL, and an adapter is available for any database featuring multi-row single shard transactions. Multiple service deployment models are available as well. For example, Uber uses multitenant Cadence clusters shared by hundreds of applications.

In this way, Cadence empowers developers with a new tool for writing and managing distributed applications while maintaining application durability, availability and scalability.

How Does Cadence Help Developers?

Cadence offers a lot of value to development teams that work with microservices-based architectures that require fault tolerance, as well as applications that include myriad multistep concurrent workflows or interact with multiple third-party APIs.

But Cadence’s versatility lends itself to nearly any scenario involving multiple requests and replies. Developers can use Cadence to create applications that serve as workflow and orchestration platforms, and get back tremendous boosts to developer productivity by replacing traditional strategies for leveraging databases and task queues.

Getting more specific, the advantages of Cadence are demonstrated in the following use cases:

  • Periodic execution (distributed cron). Cadence guarantees the execution of periodically-scheduled business logic, complete with complex error handling, retry policies and asynchronous history event replication. Importantly, Cadence supports the execution of jobs in parallel and at a massive scale, with the capability to execute millions of workflows concurrently.
  • Microservice orchestration. Business processes implemented as multiple microservices calls must have all those calls succeed, even if downstream services fail. Cadence guarantees completion of workflow code, supporting unlimited retries and making compensation logic simple to develop, such as the SAGA pattern.
  • Polling. Polling jobs that periodically check for a state change — often used for monitoring or file processing — are particularly well-matched with Cadence’s support for long-running activities and unlimited retries.
  • Event-driven applications. Cadence directly supports asynchronous events and abstracts away the complexity of state persistence for developers, making it simple to implement applications that listen to multiple event sources.
  • Storage scanning. Cadence enables scalable, resilient and complete scans of large partitioned datasets, even across billions of files.
  • Batch jobs. For batch jobs where external API calls may fail, Cadence guarantees durability.
  • Infrastructure provisioning. Long-running provisioning operations can suffer from intermittent failures; Cadence prevents this from happening. The platform further supports routing of activity execution to specific processes or hosts, as well as scalable fault-tolerant locking behavior to execute a single mutation on a resource at a time.
  • CI/CD pipelines and application deployment. By enabling developers’ focus on business logic, Cadence offers an ideal platform for building deployment solutions.
  • Operational management. Cadence enables automated management and recovery for creating self-operating databases and more.
  • Interactive applications. Cadence’s performance and scalability enable UI session state tracking and simultaneous background operation execution.
  • DSL workflows. The Cadence SDK allows developers to write fault-tolerant, scalable, durable applications that interpret DSL process definitions.
  • Big data and ML. Cadence offers a powerful control plane for big data and machine learning solutions, providing task execution routing to control how ML models and other files are allocated.

How Can You Get Started?

To get started using Cadence, grab the GitHub repo for the Cadence server or the Docker image.

Cadence: Java Hello World example

The following example demonstrates how to create and run a Hello World application in Cadence using Java. First, get the latest Cadence Java client here. Include it as a dependency in your Java project, which looks like this in Gradle.

Add these dependencies, required by cadence-client.

Next, compile this code.

Add this logback config file in your classpath.

Next, implement the Hello World workflow by adding HelloWorldImpl with the sayHello method:

Link this workflow to the Cadence framework by registering it with a worker connected to a Cadence Service (the worker connects to the locally running service by default).

Now, execute the Hello World workflow with the CLI by running the worker program.

The last line of the program’s output will now resemble this:

A look at the workflow execution history will further yield valuable information for developers to use in troubleshooting their applications.

Given the advantages Cadence offers to organizations and application developers ready to benefit from its rather unique strengths — and its availability as free and open source software! — those interested should be quick to explore the platform’s inviting potential.

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.
TNS owner Insight Partners is an investor in: Docker.