• This repository has been archived on 09/Oct/2024
  • Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Benchmarks for Temporal workflows

Maru - Temporal Load Simulator

Tool to generate load for Temporal workflows. Named after Kobayashi Maru.

⚠️ WARNING

This repository is a load generator for Temporal and does not represent suggested Go SDK practices or worker settings. Please reference the Go SDK documentation, or the Go SDK samples for better guidance.

How It Works

This repository defines a Temporal workflow which serves as a driver for load tests. Given the definition of a target load profile, the bench workflow would drive the target load and collect the workflow execution statistics.

Run the Bench Locally

The driver application reads the following environment variables to connect to a Temporal Server:

NAMESPACE=default
FRONTEND_ADDRESS=127.0.0.1:7233
PROMETHEUS_URL=http://prometheus-server

You will need to run the bench application, which also acts as a Temporal worker. Use the makefile to do so:

cd worker
make run

Deploy the Bench

The Bench workflow can be deployed to your target Temporal cluster, next to the workflows-to-be-benchmarked. You can choose to benchmark your own workflows or use the included basic workflow for starters.

The provided Helm chart can help you deploy the Bench application to your existing Kubernetes cluster.

Start a basic test using an input file

Once the bench worker and target workflows are running, you can start a quick test with the following command

  • Note: make sure you run this command in the base directory of your cloned maru repository (not the worker directory where you started the worker earlier).
tctl --namespace benchtest wf start --tq temporal-bench --wt bench-workflow --wtt 5 --et 1800 --if ./scenarios/basic-test.json --wid 1

This command starts a basic Bench workflow which in turns runs the Basic workflow six times. If everything is configured correctly, you should be able to see those workflows in Web UI:

Result of the Execution

Inspect the Bench Result

The Bench workflow returns the statistics of the workflow execution. You can query the workflow to retrieve execution statistics with the following command

$ tctl --namespace benchtest wf query --qt histogram --wid 1
Query result:
[[{"started":6,"closed":6,"backlog":0}]]

The workflow completed almost instantaneously, so there is just one data point. Let's try a more sophisticated scenario.

Start a longer load test using an input file

Here is a sample test that runs a steady workload of 20 workflows per second for 10 minutes:

tctl --namespace benchtest wf start --tq temporal-bench --wt bench-workflow --wtt 5 --et 1800 --if ./scenarios/basic-const12k.json --wid 2

It runs 12,000 workflows in total. The scenario also sets the reporting interval to 10 seconds, which means that the resulting report will have data points for every 10-second interval.

Retrieve the statistics of processing

Execute the histogram query to retrieve the execution statistics

$ tctl --namespace benchtest wf query --qt histogram --wid 2
Query result:
[[{"started":200,"closed":200,"backlog":0},{"started":200,"closed":200,"backlog":0},
{"started":200,"closed":200,"backlog":0},{"started":200,"closed":200,"backlog":0},
{"started":200,"closed":200,"backlog":0},{"started":200...

The result is a JSON array of execution statistics, where each array item represents a single time interval.

You can also retrieve the same information printed as a CSV file with the histrogram_csv query

$ tctl --namespace benchtest wf query --qt histogram_csv --wid 2
Query result:
[Time (seconds);Workflows Started;Workflows Started Rate;Workflow Closed;Workflow Closed Rate;Backlog
10;200;20.000000;200;20.000000;0
20;200;20.000000;200;20.000000;0
30;200;20.000000;200;20.000000;0
40;200;20.000000;200;20.000000;0
50;200;20.000000;200;20.000000;0
...

You can convert the workflow result to a chart using charting software of your choice. For example, save the CSV to a file, upload it to from Google Spreadsheets, and build a chart from columns 1, 3, 5, and 6:

Execution Chart

Retrieve the metrics

If you have Prometheus installed and configured, you can pass its URL via PROMETHEUS_URL environment variable (default: http://prometheus-server), you can use an additional query to retrieve the metrics of storage and History service utilization:

tctl --namespace benchtest wf query --qt metrics_csv --wid 2
Query result:
[Time (seconds);Persistence Latency (ms);History Service Latency (ms);Persistence CPU (mcores);History Service CPU (mcores);History Service Memory Working Set (MB)
60;8;456;494;418;27
120;9;479;1733;970;72
180;9;481;2537;996;80
240;9;481;3623;978;85
300;9;482;3652;949;87
360;9;477;3462;973;92
420;9;470;2522;636;91]

Variable load

You can define a load profile consisting of multiple steps. For example, you can start and finish the test with low number of executions per second but have a spike of high load in the middle.

Execution Chart

The above chart shows statistics from a sample run of ./scenarios/basic-spike.json.

Configure your own scenario

You can tweak the parameters of the benchmark scenario by adjusting the JSON file. Let's take the basic-const12k.json scenario as a starting point:

{
    "steps": [{
        "count": 12000,
        "ratePerSecond": 20,
        "concurrency": 5
    }],
    "workflow": {
        "name": "basic-workflow",
        "taskQueue": "temporal-basic",
        "args": {
            "sequenceCount": 3,
            "parallelCount": 1
        }
    },
    "report": {
        "intervalInSeconds": 10
    }
}

Here are all the parameters you may configure:

  • steps - An array that defines one or more steps of the load test.
  • steps[i].count - The total number of target worflow executions for a bench run.
  • steps[i].ratePerSecond - The maximum number of workflow executions to start per second (rate limiting). By default, no rate limiting applies.
  • steps[i].concurrency - The number of parallel activities that bench will use to start target workflows. Can be useful when ratePerSecond is too high for a single activity to keep up. Defaults to ratePerSecond divided by 10.
  • workflow.name - The name of a workflow to be used as the testing target. The bench will start step[*].count of these workflows.
  • workflow.taskQueue - The name of the task queue to use when starting the target workflow.
  • workflow.args - Arguments to send to the target workflows. This must match the shape of the target workflow's inputs.
  • report.intervalInSeconds - The resolution of execution statistics in the resulting report. Defaults to 1 minute.

Random inputs and outputs for the target workflow

The size of input and output data of workflows and activities may influence the performance characteristics.

The benchmark comes with a simple way to generate random payloads for your target workflows. Here is the definition of the workflow in ./scenarios/basic-payload.json:

"workflow": {
    "name": "basic-workflow",
    "taskQueue": "temporal-basic",
    "args": {
        "sequenceCount": 3,
        "payload": "$RANDOM(100)",
        "resultPayload": "$RANDOM_NORM(80,10)"
    }
}

Note how the args parameter contains two fields with "formulas" in them:

  • $RANDOM(<length>) generates a random string of the given length.
  • $RANDOM_NORM(<mean>,<stdvar>) generates a random string of a random length from the given normal distribution.

The formulas are replaced with random values by the benchmark workflow, so each target workflow execution receives its own value.

More Repositories

1

temporal

Temporal service
Go
11,040
star
2

temporalite-archived

An experimental distribution of Temporal that runs as a single process
Go
608
star
3

sdk-typescript

Temporal TypeScript SDK
TypeScript
510
star
4

sdk-python

Temporal Python SDK
Python
446
star
5

sdk-go

Temporal Go SDK
Go
437
star
6

samples-go

Temporal Go SDK samples
Go
404
star
7

sdk-dotnet

Temporal .NET SDK
C#
373
star
8

samples-typescript

TypeScript
297
star
9

docker-compose

Temporal docker-compose files
Shell
296
star
10

sdk-php

Temporal PHP SDK
PHP
274
star
11

helm-charts

Temporal Helm charts
Mustache
273
star
12

sdk-core

Core Temporal SDK that can be used as a base for language specific Temporal SDKs
Rust
262
star
13

cli

Command-line interface for running Temporal Server and interacting with Workflows, Activities, Namespaces, and other parts of Temporal
Go
246
star
14

sdk-java

Temporal Java SDK
Java
196
star
15

ui

Temporal UI
TypeScript
178
star
16

samples-java

Temporal Java SDK samples
Java
152
star
17

awesome-temporal

A curated list of awesome Temporal libraries and resources.
142
star
18

samples-python

Samples for working with the Temporal Python SDK
Python
117
star
19

samples-php

Temporal PHP SDK samples
PHP
92
star
20

documentation

Temporal documentation
Python
84
star
21

dashboards

Temporal Dashboards
77
star
22

api

Temporal gRPC API and proto files
Makefile
77
star
23

web

Temporal Web UI v1
JavaScript
70
star
24

ui-server

Golang Server for https://github.com/temporalio/ui
Go
66
star
25

proposals

Temporal proposals
66
star
26

experiment-dotnet

Temporal SDK for .NET
C#
65
star
27

snipsync

JavaScript
65
star
28

background-checks

Sample application using Temporal
Go
64
star
29

sdk-ruby

Temporal Ruby SDK
Ruby
64
star
30

temporal-ecommerce

Go
57
star
31

samples-dotnet

Samples for working with the Temporal .NET SDK
C#
52
star
32

money-transfer-project-template-go

Go
47
star
33

tctl

Temporal CLI
Go
43
star
34

samples-server

Go
41
star
35

temporal-polyglot

PHP
35
star
36

tcld

The temporal cloud cli.
Go
32
star
37

docker-builds

Temporal service Docker images build
Shell
27
star
38

api-go

Temporal gRPC API and proto files compiled for Go
Go
27
star
39

temporal-render-simple

temporal-render-simple
Shell
25
star
40

edu-101-go-code

Code used in exercises and demonstrations for the "Temporal 101 with Go" course
CSS
24
star
41

roadrunner-temporal

Temporal PHP-SDK Host Process plugin for Roadrunner
Go
22
star
42

spring-boot-demo

Sample application demonstrating Temporal JavaSDK Spring Boot integration
Java
22
star
43

temporaldotio

Website for temporal.io. Built with Next.js + Preact + Tailwind, hosted on Vercel
JavaScript
20
star
44

vscode-debugger-extension

Visual Studio Code debugger plugin
TypeScript
18
star
45

ringpop-go

Go
17
star
46

temporal-pendulum

Demo showing off Temporal Polyglot features (Java, Go, TypeScript, PHP)
Java
16
star
47

benchmark-workers

Pre-written workflows and activities useful for benchmarking Temporal
Go
14
star
48

features

Behavior and history compatibility testing for Temporal SDKs
Go
13
star
49

subscription-workflow-project-template-go

Go
13
star
50

subscription-workflow-project-template-php

Subscription Workflow Project Template for PHP
PHP
12
star
51

omes

A load generator for Temporal
C#
12
star
52

sagas-temporal-trip-booking

Java
12
star
53

temporal-aws-sdk-go

Temporal activities and workflow stubs that wrap AWS Go SDK
Go
12
star
54

graphql

GraphQL API for Temporal Server
HTML
11
star
55

money-transfer-project-java

Java
11
star
56

subscription-workflow-project-template-typescript

This project template illustrates the design pattern for subscription style business logic.
TypeScript
11
star
57

sdk-scala

Scala SDK for Temporal
10
star
58

terraform-provider-temporalcloud

Terraform provider for Temporal Cloud
Go
10
star
59

replay2024-demo

Demo code and infra
JavaScript
9
star
60

github-repo-notion-sync

Sync an organization's GitHub repo list to a Notion DB
TypeScript
9
star
61

benchmark-matrix

Automated benchmarks for Temporal
TypeScript
8
star
62

api-cloud

Temporal cloud gRPC API and proto files
Makefile
8
star
63

hello-world-project-template-go

Go
7
star
64

temporal-compensating-transactions

A four implementations of the Compensating Transaction pattern in Temporal in go, python, java and typescript
Java
6
star
65

edu-102-go-code

Code used in exercises and demonstrations for the "Temporal 102 with Go" course
Go
6
star
66

xk6-temporal

k6 Extension for testing/benchmarking Temporal
Go
6
star
67

hello-world-project-template-java

Java
6
star
68

money-transfer-project-template-ts

TypeScript
6
star
69

temporal-jumpstart-java

Some repos Start. This one Jump Starts.
Java
5
star
70

subscription-workflow-project-template-java

Subscription workflow project template for Java
Java
5
star
71

edu-101-java-code

Code Exercises for Temporal 101 in java
CSS
4
star
72

edu-101-typescript-code

Code used in exercises and demonstrations for the Temporal 101 (TypeScript) course
CSS
4
star
73

temporal-aws-sdk-generator

AWS SDK Bindings Generator
Go
4
star
74

documentation-samples-python

Python
4
star
75

data-pipeline-project-python

Python
4
star
76

temporal-animations

A toolkit for creating animations explaining Temporal
Python
4
star
77

reference-app-orders-go

Order processing reference application
Go
4
star
78

documentation-samples-go

Go
3
star
79

homebrew-brew

The official Homebrew tap for temporalio
Ruby
3
star
80

docusaurus-plugin-snipsync

Snipsync plugin for docusaurus - insert snippets into markdown files
TypeScript
3
star
81

temporal-demo-infra

Svelte
3
star
82

money-transfer-project-template-python

Python
3
star
83

graphql-proxy

GraphQL API for Temporal Server
Java
3
star
84

background-check-typescript

TypeScript
3
star
85

team

The Temporal team
3
star
86

sdk-php-interceptors-opentelemetry

Opentelemetry interceptors package for PHP SDK
PHP
3
star
87

email-subscription-project-python

Python
3
star
88

temporal-learning

HTML
3
star
89

temporal-development-patterns-whitepapers

Temporal Development Patterns Whitepapers
Java
2
star
90

idea-settings

2
star
91

cloud-samples-go

Temporal Cloud Samples - Go
Go
2
star
92

demo-go

Go
2
star
93

cheatsheets

Cheatsheets for the Temporal CLI
2
star
94

setup-temporal

TypeScript
2
star
95

worker-versioning-replay-demo

TypeScript
2
star
96

ringpop-common

JavaScript
2
star
97

temporal-cafe-typescript

TypeScript
2
star
98

temporal-pause-resume-compensate

Java
2
star
99

temporal-vscode

temporal-vscode
1
star
100

replay-demo-2023

Replay Demo 2023: Workflow Update, Schedules and Worker Versioning
Go
1
star