You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a distribution policy, the following distribution modes can be selected to define the strategy used to distribute jobs to workers:
16
+
Distribution policies support the following distribution modes to define the strategy used to distribute jobs to workers:
17
17
18
18
## Round robin mode
19
19
20
20
Jobs are distributed in a circular fashion such that each available worker receives jobs in sequence.
21
21
22
22
## Longest idle mode
23
23
24
-
Jobs are distributed to the worker that is least utilized first. If there's a tie, the worker available for the longest time is picked. Utilization is calculated as a `Load Ratio` by the following algorithm:
24
+
Jobs are distributed to the worker that's least utilized first. If there's a tie, the worker available for the longest time is picked. Utilization is calculated as a `Load Ratio` by the following algorithm:
25
25
26
26
Load Ratio = Aggregate of capacity consumed by all jobs assigned to the worker / Total capacity of the worker
27
27
@@ -59,17 +59,17 @@ LastAvailable: 2 min ago
59
59
Workers would be matched in order: D, C, A, B
60
60
```
61
61
62
-
Worker D has the lowest load ratio (0), so Worker D is offered the job first. Workers A and C are tied with the same load ratio (0.6). However, Worker C is available for a longer time (7 minutes ago) than Worker A (5 minutes ago), so Worker C is matched before Worker A. Finally, Worker B is matched last since Worker B has the highest load ratio (0.75).
62
+
Worker D has the lowest load ratio (0), so the job is first offered to Worker D. Workers A and C are tied with the same load ratio (0.6). However, Worker C is available for a longer time (7 minutes ago) than Worker A (5 minutes ago), so Worker C is matched before Worker A. Finally, Worker B is matched last since Worker B has the highest load ratio (0.75).
63
63
64
64
## Best worker mode
65
65
66
66
The workers that are best able to handle the job are picked first. The logic to rank Workers can be customized, with an expression or Azure function to compare two workers by specifying a Scoring Rule. [See example](../../how-tos/router-sdk/customize-worker-scoring.md)
67
67
68
-
When a Scoring Rule isn't provided, this distribution mode will use the default scoring method instead, which evaluates workers based on how the job's labels and selectors match with the worker's labels.
68
+
When a Scoring Rule isn't provided, this distribution mode uses the default scoring method instead, which evaluates workers based on how the job's labels and selectors match with the worker's labels.
69
69
70
70
### Default label matching
71
71
72
-
For calculating a score based on the job's labels, the `Match Score` is incremented by 1 for every worker label that matches a corresponding label on the job and then divide by the total number of labels on the job. Therefore, the more labels that matched, the higher a worker's `Match Score`. The final `Match Score`will always be a value between 0 and 1.
72
+
The `Match Score` is incremented by 1 for every worker label that matches a corresponding label on the job and then divide by the total number of labels on the job. Therefore, the more labels that matched, the higher a worker's `Match Score`. The final `Match Score`is always a value between 0 and 1.
73
73
74
74
#### Example
75
75
@@ -124,15 +124,15 @@ Worker B's match score = 1 (for matching english language label) / 2 (total numb
124
124
Worker C's match score = 1 (for matching english language label) / 2 (total number of labels) = 0.5
125
125
```
126
126
127
-
Worker A would be matched first. Next, Worker B or Worker C would be matched, depending on who was available for a longer time, since the match score is tied.
127
+
Worker A would be matched first. Next, Worker B or Worker C would be matched, depending on who was available for a longer time, since the match score is tied.
128
128
129
129
### Default worker selector matching
130
130
131
131
In the case where the job also contains worker selectors, the `Match Score` is calculated based on the `LabelOperator` of that worker selector.
132
132
133
133
#### Equal/notEqual label operators
134
134
135
-
The score is incremented by 1 if the worker selector has the `LabelOperator``Equal` or `NotEqual` for each job label that matches that worker selector, similar to the `Label Matching` mechanism.
135
+
If the `LabelOperator`worker selector is `Equal` or `NotEqual`, the score is incremented by 1 for each job label that matches that worker selector, similar to the `Label Matching` mechanism.
136
136
137
137
##### Example
138
138
@@ -187,11 +187,11 @@ Worker E's match score = 1 (for matching department selector) + 1 (for matching
187
187
Worker F's match score = 1 (for segment not equal to vip) / 2 (total number of labels) = 0.5
188
188
```
189
189
190
-
Worker E would be matched first. Next, Worker D or Worker F would be matched, depending on who was available for a longer time, since the match score is tied.
190
+
Worker E would be matched first. Next, Worker D or Worker F would be matched, depending on who was available for a longer time, since the match score is tied.
191
191
192
192
#### Other label operators
193
193
194
-
For worker selectors using operators that compare by magnitude (`GreaterThan`/`GreaterThanEqual`/`LessThan`/`LessThanEqual`), the worker's `Match Score` is incremented by an amount calculated using the logistic function (See Fig 1). The calculation is based on how much the worker's label value exceeds the worker selector's value or a lesser amount if it doesn't exceed the worker selector's value. Therefore, the more worker selector values the worker exceeds, and the greater the degree to which it does so, the higher a worker's score is.
194
+
For worker selectors using operators that compare by magnitude (`GreaterThan`/`GreaterThanEqual`/`LessThan`/`LessThanEqual`), the worker's `Match Score` is incremented by an amount calculated using the logistic function (See Fig 1). The calculation is based on how much the worker's label value exceeds the worker selector's value or a lesser amount if it doesn't exceed the worker selector's value. Therefore, the more worker selector values the worker exceeds, and the greater the degree to which it does so, the higher a worker's score is.
195
195
196
196
:::image type="content" source="../media/router/distribution-concepts/logistic-function.png" alt-text="Diagram that shows logistic function.":::
All three workers match the worker selectors on the job and are eligible to work on it. However, we can see that Worker H exceeds the "sales" worker selector's value by a margin of 5. Meanwhile, Worker I only exceeds the cost worker selector's value by a margin of 1. Worker G doesn't exceed any of the worker selector's values at all. Therefore, Worker H would be matched first, followed by Worker I and finally Worker G would be matched last.
270
+
All three workers match the worker selectors on the job and are eligible to work on it. However, we can see that Worker H exceeds the "sales" worker selector's value by a margin of 5. Meanwhile, Worker I only exceeds the cost worker selector's value by a margin of 1. Worker G doesn't exceed any of the worker selector's values at all. Therefore, Worker H would be matched first, followed by Worker I and finally Worker G would be matched last.
0 commit comments