Skip to content

Commit 418564a

Browse files
Merge pull request #309463 from radubulboaca/main
clarify longest idle
2 parents 3187ec1 + 1883bba commit 418564a

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

articles/communication-services/concepts/router/distribution-concepts.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@ title: Distribution mode concepts for Azure Communication Services
33
titleSuffix: An Azure Communication Services concept document
44
description: Learn about the Azure Communication Services Job Router distribution mode concepts.
55
services: azure-communication-services
6-
manager: chpalm
7-
ms.author: chpalm
6+
manager: radubulboaca
7+
ms.author: radubulboaca
88
author: tophpalmer
99
ms.date: 05/06/2022
10-
ms.topic: conceptual
10+
ms.topic: article
1111
ms.service: azure-communication-services
1212
---
1313

1414
# Distribution modes
1515

16-
When creating a distribution policy, we specify one of the following distribution modes to define the strategy to use when distributing jobs to workers:
16+
Distribution policies support the following distribution modes to define the strategy used to distribute jobs to workers:
1717

1818
## Round robin mode
1919

20-
Jobs will be distributed in a circular fashion such that each available worker will receive jobs in sequence.
20+
Jobs are distributed in a circular fashion such that each available worker receives jobs in sequence.
2121

2222
## Longest idle mode
2323

24-
Jobs will be distributed to the worker that is least utilized first. If there's a tie, we'll pick the worker that has been available for the longer time. 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:
2525

2626
Load Ratio = Aggregate of capacity consumed by all jobs assigned to the worker / Total capacity of the worker
2727

28+
Events such as `RouterWorkerRegistered`, are resetting the worker's idle time, which may impact the distribution based on longest idle time.
29+
2830
### Example
2931

30-
Assume that each `chat` job has been configured to consume one capacity for a worker. A new chat job is queued into Job Router and the following workers are available to take the job:
32+
Assume that each `chat` job is configured to consume one capacity unit for a worker. A new chat job is queued into Job Router and the following workers are available to take the job:
3133

3234
```text
3335
Worker A:
@@ -57,17 +59,17 @@ LastAvailable: 2 min ago
5759
Workers would be matched in order: D, C, A, B
5860
```
5961

60-
Worker D has the lowest load ratio (0), so Worker D will be offered the job first. Workers A and C are tied with the same load ratio (0.6). However, Worker C has been available for a longer time (7 minutes ago) than Worker A (5 minutes ago), so Worker C will be matched before Worker A. Finally, Worker B will be 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).
6163

6264
## Best worker mode
6365

64-
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)
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)
6567

66-
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. The algorithms are outlined below.
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.
6769

6870
### Default label matching
6971

70-
For calculating a score based on the job's labels, we increment the `Match Score` 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.
7173

7274
#### Example
7375

@@ -122,15 +124,15 @@ Worker B's match score = 1 (for matching english language label) / 2 (total numb
122124
Worker C's match score = 1 (for matching english language label) / 2 (total number of labels) = 0.5
123125
```
124126

125-
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.
126128

127129
### Default worker selector matching
128130

129-
In the case where the job also contains worker selectors, we'll calculate the `Match Score` based on the `LabelOperator` of that worker selector.
131+
In the case where the job also contains worker selectors, the `Match Score` is calculated based on the `LabelOperator` of that worker selector.
130132

131133
#### Equal/notEqual label operators
132134

133-
If the worker selector has the `LabelOperator` `Equal` or `NotEqual`, we increment the score by 1 for each job label that matches that worker selector, in a similar manner as the `Label Matching` above.
135+
The score is incremented by 1 if the `LabelOperator` worker selector is `Equal` or `NotEqual`, for each job label that matches that worker selector, similar to the `Label Matching` mechanism.
134136

135137
##### Example
136138

@@ -185,11 +187,11 @@ Worker E's match score = 1 (for matching department selector) + 1 (for matching
185187
Worker F's match score = 1 (for segment not equal to vip) / 2 (total number of labels) = 0.5
186188
```
187189

188-
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.
189191

190192
#### Other label operators
191193

192-
For worker selectors using operators that compare by magnitude (`GreaterThan`/`GreaterThanEqual`/`LessThan`/`LessThanEqual`), we'll increment the worker's `Match Score` 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 will be.
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.
193195

194196
:::image type="content" source="../media/router/distribution-concepts/logistic-function.png" alt-text="Diagram that shows logistic function.":::
195197

@@ -265,4 +267,4 @@ Worker H's match score = (1 + 1 / (1 + e^-((15 - 10) / 10)) + 1 / (1 + e^-((10 -
265267
Worker I's match score = (1 + 1 / (1 + e^-((10 - 10) / 10)) + 1 / (1 + e^-((10 - 9) / 10))) / 3 = 0.675
266268
```
267269

268-
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

Comments
 (0)