Connect Cadence to Astra DB in 5 Easy Steps
Author: Melissa Herrera
Cadence and Astra DB are a winning pair for developers looking to visualize their workflows while having a robust, easily-scalable database running in the background. Read on to learn how to connect Cadence to Astra DB in just 5 simple steps.
Cadence is a multi-tenant orchestration framework that helps with managing workflows. It scales horizontally to handle millions of concurrent executions from various customers. Cadence uses Docker Compose to run their server, and uses Apache CassandraⓇ as its default backend dependency. As a bonus, with Docker Compose you can also use Cadence with MySQL, PostgreSQL, Statsd+Graphite, and Elasticsearch.
In this post, we’ll show you how to connect Cadence with DataStax Astra DB to easily manage workflows at scale. This runbook is going to use DataStax cql-proxy, which is a sidecar designed to forward your application’s CQL traffic to an appropriate database service. (You may want to bookmark this one.)
Let’s get started!
Step 1: Setting up Astra DB
Before connecting to Temporal, you need to first create an Astra database instance and gather all your credentials. If you haven’t already, you can sign up for a free Astra DB account that will give you 80 GB monthly to work with. Now you can go ahead and spin up your first database with these steps:
- When asked for the keyspace name, name it
- Once your database is created, navigate back to your database dashboard and click Add Keyspace.
- Name this second keyspace
The status of your database will temporarily go to Maintenance but a few seconds later you can refresh your screen and the status should switch to Active.
Tokens are required to authenticate against Astra DB with APIs or drivers. These tokens can be used with multiple databases and can be configured to have specific permissions.
In this example, you’ll create a token using Admin Role. Temporal uses this token to receive credentials and permission to access your database, similar to how Cassandra has a “user” and “password”, which we’ll discuss in more detail in Step 4. When you create your tokens, download the CSV file to keep these credentials safe.
3. Find your Database ID.
Lastly, you want to get your Database ID. You can find this in one of two ways:
- Navigate to your your database and get the last ID in the URL:
- Copy and paste the “Datacenter ID” without the trailing
-1from the “Regions” section of your Astra Dashboard.
Step 2. Setting up Cadence
- First, clone this GitHub repository.
- Then, navigate to the cloned repository and use your preferred text editor (e.g. VisualStudio or Sublime) to update the .env file with the Astra Token and Astra Database ID that you obtained above.
Step 3. Migrating Cadence schema to Astra DB
Here, you’ll create and set up the keyspaces you made earlier in Astra DB with
temporal-cassandra-tool. This tool is part of the Cadence repo and it relies on the schema definition.
- Navigate to your cloned
- Run the following commands to initialize the keyspaces that we created through Astra DB. Note that there are two sets of commands: one for cadence keyspace and one for
Once the process is complete, you should see a message similar to this:
Great! Your schemas have now been migrated with Astra DB. You can double-check the tables by querying your database in Astra DB’s CQL Console.
To do this, run a quick
DESCRIBE tables; in both your cadence and
cadence_visibility keyspaces, you should see there are tables loaded in that were created by the schema migration.
Step 4. Running Docker Compose
In this step, the
docker-compose-cqlproxy.yaml file is already provided for you in the
cassandra-astra-cql-proxy repo. This file creates different Docker containers to run Temporal server. The persistence layer is configured for you to connect with cql-proxy, and it should pull the Astra DB credentials you set up earlier.
Run the following command to start Cadence:
Step 5. Test and validate
- Create a domain
samples-domainby running the following command:
2. Clone the sample project repository to your machine. Navigate to this project and run
make to build all the projects.
3. You can start by running the sample Hello World project by following the instructions in that repository.
Once you have this all up and running, you should be able to see your workflows on both the Cadence UI and Astra UI. You can see the domain on the top left is
samples-domain, the domain we created, and the Status of each workflow shows as “Completed”.
And just like that, you’ve spun up a free, serverless database with Astra DB and connected it to Cadence!
Cadence and Astra DB make a powerful pairing, and this five-step guide marks your first step in exploring the possibilities. With them, you can visualize your workflows with ease knowing you have a strong, supported database running in the background. So, keep this post handy and make the most out of your free Astra DB account by going ahead and experimenting with some Cadence samples!