Skip to content

Add Task Queue Priority and Fairness sample#466

Open
sivagirish81 wants to merge 2 commits into
temporalio:mainfrom
sivagirish81:task_queue_priority_fairness
Open

Add Task Queue Priority and Fairness sample#466
sivagirish81 wants to merge 2 commits into
temporalio:mainfrom
sivagirish81:task_queue_priority_fairness

Conversation

@sivagirish81
Copy link
Copy Markdown

What was changed

This PR adds a new Go SDK sample: task-queue-priority-fairness.

Why?

Temporal users need a concrete, runnable sample showing how Task Queue Priority and Fairness work together in a shared multi-tenant queue:

  • Priority across levels (urgent before normal/background)
  • Fairness within a priority level (small tenants not starved by a large tenant)
  • Weighted fairness (premium-media gets a larger share while backlogged)

Checklist

  1. Closes #465

@sivagirish81 sivagirish81 requested a review from a team as a code owner May 5, 2026 20:57
@sivagirish81 sivagirish81 changed the title Task queue priority fairness Add Task Queue Priority and Fairness sample May 5, 2026
- `FairnessKey` groups work by tenant within a priority level. Every Activity Task in this sample uses its tenant ID as a non-empty fairness key.
- `FairnessWeight` gives `premium-media` a larger proportional share while it has backlog. The premium tenant uses `FairnessWeight=3.0`; regular tenants use `FairnessWeight=1.0`.

Priority determines which priority sub-queue Tasks go into. Fairness determines ordering within a given priority level. Fairness ordering is probabilistic and observational, so the exact order can vary between runs.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I need to change up this wording as it is misleading

Suggested change
Priority determines which priority sub-queue Tasks go into. Fairness determines ordering within a given priority level. Fairness ordering is probabilistic and observational, so the exact order can vary between runs.
Priority determines which priority sub-queue Tasks go into. Within a priority level, Fairness selects among fairness-key virtual queues using weighted, probabilistic dispatch. Tasks with the same fairness key are still dispatched FIFO, but the interleaving between different fairness keys is not a deterministic row-by-row sequence and can vary between runs.

`premium-media` should appear repeatedly near the front of normal-priority
dispatch while it still has backlog.

Fairness is probabilistic, so exact row-by-row ordering can vary between runs.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one as well.

Suggested change
Fairness is probabilistic, so exact row-by-row ordering can vary between runs.
Fairness uses weighted, probabilistic dispatch across fairness keys, so this sample validates expected weighted/proportional patterns rather than an exact row-by-row sequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add Task Queue Priority and Fairness sample

1 participant