Skip to content

Commit db511e7

Browse files
committed
feat(task queues): more refinement to priority and fairness draft
1 parent ad537c1 commit db511e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/develop/task-queue-priority-fairness.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ If you're self-hosting Temporal, use the latest pre-release development server a
3434

3535
### When to use priority
3636

37-
If you need a way to specify the order your Tasks execute in, you can use priority to manage that. Priority gives you a way to differentiate between different Tasks you have, like batch and real-time, so that you can allocate resources more effectively. You can also use this as a way to run urgent Tasks immediately and override others.
37+
If you need a way to specify the order your Tasks execute in, you can use priority to manage that. Priority lets you differentiate between your Tasks, like batch and real-time for example, so that you can allocate resources more effectively. You can also use this as a way to run urgent Tasks immediately and override others.
3838

3939
### How to use priority
4040

4141
You can select a priority level by setting the _priority key_ to a value within the integer range `[1,5]`. A lower value implies higher priority, so `1` is the highest priority level. The default priority, if unspecified, is `3`.
4242

43-
When you set a priority level within your Task Queues, this means that they will __all__ be processed in priority order. For example, all your priority level `1` Tasks will execute before your priority level `2` Tasks and so on. So your lower priority Tasks will be completely blocked until the higher priority Tasks finish running. Tasks with the same priority level are scheduled to run in first-in-first-out (FIFO) order. If you need more flexibility to allocate resources to lower priority Tasks sooner, check out [the fairness section](#task-queue-fairness).
43+
When you set a priority level within your Task Queues, this means that they will __all__ be processed in priority order. For example, all of your priority level `1` Tasks will execute before your priority level `2` Tasks and so on. So your lower priority Tasks will be blocked until the higher priority Tasks finish running. Tasks with the same priority level are scheduled to run in first-in-first-out (FIFO) order. If you need more flexibility to allocate resources to lower priority Tasks sooner, check out [the fairness section](#task-queue-fairness).
4444

4545
Activities will inherit the priority level of their Workflow if a separate Activity priority level isn't set.
4646

47+
When you update priority levels, the Task Queues will only reflect these changes for Tasks that haven't dispatched yet, not Tasks that are already queued.
48+
4749
:::note
4850
[Sticky tasks](/sticky-execution) ignore priority settings.
4951
:::
@@ -199,17 +201,17 @@ await Workflow.ExecuteChildWorkflowAsync(
199201
Task Queue fairness applies within each priority level. This gives you more control over the order that Tasks are dispatched from the backlog at a specific priority level. You can assign compute resources fairly so that priority levels are respected, but Tasks at lower priority levels will still be processed without waiting for all higher priority Tasks to finish first. It’s intended to address common situations like:
200202

201203
- Multi-tenant applications with big and small tenants where small tenants shouldn't be blocked by big ones. That means any single user should be able to use all available resources rather than being rate limited at a fixed level.
202-
- Assigning Tasks to different capacity bands and then dispatch 80% from one band and 20% from another, for example, without limiting overall capacity when one band is empty.
204+
- Assigning Tasks to different capacity bands and then, for example, dispatching 80% from one band and 20% from another without limiting overall capacity when one band is empty.
203205

204-
Fairness is only avaliable in Temporal Cloud, so contact Temporal Support or your Temporal account team to enable this feature for your cloud Namespaces.
206+
Fairness is only avaliable as a paid feature in Temporal Cloud, so contact Temporal Support or your Temporal account team to enable this feature for your cloud Namespaces. Fairness can be enabled or disabled at the Namespace level and billing will be disabled at the next calendar hour after it is disabled.
205207

206208
:::warning
207209
For **Pre-release**, fairness cannot be enabled for active Task Queues. The Task Queues have to be new or idle and there can't be any running Workflows. Once fairness is enabled, all existing backlog Tasks in the Task Queue will be abandoned.
208210
:::
209211

210212
### How fairness works
211213

212-
Fairness sequences Tasks at each priority level based on each _fairness key_ and their _fairness weight_ within a Task Queue. The fairness keys are used to describe your Task structure. A fairness key can correspond to unique applications, tenants, or other groupings useful to your workloads. The Tasks associated with each fairness key are dispatched based on the _fairness weight_ that has been assigned to the key. Using the fairness keys and their corresponding fairness weights lets you define tiers with weighted capacities, like high, medium, and low, so that higher priority tasks don't overwhelm your resources and block lower priority tasks.
214+
Fairness sequences Tasks at each priority level based on _fairness keys_ and their _fairness weight_ within a Task Queue. The fairness keys are used to describe your Task structure. A fairness key can correspond to unique applications, tenants, or other groupings useful to your workloads. The Tasks associated with each fairness key are dispatched based on the _fairness weight_ that has been assigned to the key. Using the fairness keys and their corresponding fairness weights lets you define tiers with weighted capacities, like high, medium, and low, so that higher priority tasks don't overwhelm your resources and block lower priority tasks.
213215

214216
Fairness attempts to distribute all the Tasks from a higher priority level first before distributing any from a lower priority. The fairness weights allow for unequal distribution among tenants or for allocating fractions of capacity to different levels or types of Tasks.
215217

@@ -219,6 +221,8 @@ Fairness applies within each priority level. It sequences Tasks in the Task Queu
219221
- The current backlog of Tasks
220222
- A data structure that tracks how you've distributed Tasks for different fairness keys
221223

224+
When you update fairness keys or fairness weights, the Task Queues will only reflect these changes for Tasks that haven't dispatched yet, not Tasks that are already queued.
225+
222226
### When to use fairness
223227

224228
Fairness applies to backlogged Tasks when there isn't sufficient Worker capacity to dispatch Tasks immediately. This is applicable if you want to distribute a finite resource across all of your Tasks without blockers. If all Tasks can be dispatched immediately, then you don't need to use fairness.

0 commit comments

Comments
 (0)