This repository contains a set of scenarios to test the latency of Temporal workflows in various configurations.
Results screen for the Update-With-Start (Local Activities)
scenario:
- Run Workflow (Regular Activities): Runs the workflow in its entirety and returns the result to the client.
- Run Workflow (Regular Activities): Runs the workflow in its entirety but uses local activities and returns the result to the client.
- Update-With-Start (Regular Activities): Demonstrates the "Early Return" pattern. Returns a value to the client from an update before the workflow completes.
- Update-With-Start (Local Activities): Demonstrates the "Early Return" pattern. Same as Update-With-Start (Regular Activities), but uses a local activity inside the update handler.
- Eager Workflow Start: runs the workflow in its entirety eagerly with local activities and returns the result to the client.
- Ensure you have a Temporal Service running. You can use the Temporal Cloud or run a local instance (
brew install temporal && temporal server start-dev
). - Install the
just
CLI tool:brew install just
. - Clone this repository and navigate to the root directory:
git clone https://github.com/temporal-sa/temporal-latency-optimization-scenarios.git
andcd temporal-latency-optimization-scenarios
. - Install the dependencies for the web server and the Python worker:
cd web && npm install && cd ../worker && poetry install
. - Copy the
.env.template
file to.env
and update the values as needed.
-
You may need to enable Update, Update With Start, and Eager Workflow Start
-
For Cloud, reach out to your account team
-
For local testing, add these to your
temporal server start-dev
:--dynamic-config-value frontend.enableUpdateWorkflowExecutionAsyncAccepted=true --dynamic-config-value frontend.enableUpdateWorkflowExecution=true --dynamic-config-value frontend.enableExecuteMultiOperation=true --dynamic-config-value system.enableEagerWorkflowStart=true
Before running any just
commands, ensure your environment is clean by unsetting any existing Temporal environment variables:
unset TEMPORAL_TASK_QUEUE TEMPORAL_CONNECTION_NAMESPACE TEMPORAL_CONNECTION_TARGET TEMPORAL_CONNECTION_MTLS_KEY_FILE TEMPORAL_CONNECTION_MTLS_CERT_CHAIN_FILE TEMPORAL_CONNECTION_WEB_PORT CALLER_API_PORT PUBLIC_WEB_URL
- Start the web server:
just run_web
. - Start the Temporal worker:
just run_temporal
. - Navigate to the web server in your browser (default is
http://0.0.0.0:5178
).