https://github.com/temporalio/priority-fairness-streamlit-demo
Priority and fairness hello world example for Temporal Python SDK
https://github.com/temporalio/priority-fairness-streamlit-demo
Last synced: 3 days ago
JSON representation
Priority and fairness hello world example for Temporal Python SDK
- Host: GitHub
- URL: https://github.com/temporalio/priority-fairness-streamlit-demo
- Owner: temporalio
- Created: 2026-04-16T22:19:44.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-06-12T22:23:12.000Z (22 days ago)
- Last Synced: 2026-06-13T00:16:52.098Z (22 days ago)
- Language: Python
- Size: 1.02 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Priority & Fairness Demo
Interactive demo of Temporal's task queue priority and fairness features using a Streamlit dashboard.

## Prerequisites
- Python 3.12+
- [uv](https://docs.astral.sh/uv/)
- [Temporal CLI](https://docs.temporal.io/cli)
## Setup
```bash
uv sync
```
## Running
### 1. Start the Temporal dev server
Priority and fairness require specific dynamic config flags:
```bash
temporal server start-dev \
--dynamic-config-value matching.useNewMatcher=true \
--dynamic-config-value matching.enableFairness=true \
--dynamic-config-value matching.numTaskqueueReadPartitions=1 \
--dynamic-config-value matching.numTaskqueueWritePartitions=1
```
### 2. Start the worker
```bash
unset TEMPORAL_PROFILE
uv run python worker.py
```
### 3. Start the dashboard
```bash
unset TEMPORAL_PROFILE
uv run streamlit run dashboard.py
```
`unset TEMPORAL_PROFILE` ensures you connect to the local dev server instead of Temporal Cloud.
## What it does
The dashboard has two tabs:
**Priority** — Start a batch of workflows with random priorities (P1 High, P3 Medium, P5 Low). With priority enabled, high priority workflows execute before low priority ones. Toggle priority off to see FIFO behavior.
**Fairness** — Start a batch of workflows split across three tenants (Big 60%, Mid 25%, Small 15%). With fairness enabled, all tenants get regular turns. Toggle fairness off to see the "noisy neighbor" problem where the big tenant starves the others.
The worker is constrained to `max_concurrent_activities=1` to force a backlog and make the ordering effects visible.