fix: fix average computation
[poolifier.git] / src / pools / selection-strategies / README.md
CommitLineData
9e2ab226
JB
1# Worker choice strategies
2
3## Strategies
4
5### Fair share
6
7Its goal is to distribute the load evenly across all workers. To achieve this, the strategy keeps track of the average task execution time for each worker and assigns the next task to the worker with the lowest task end prediction time: `task_end_prediction = max(current_time, task_end_prediction) + average_task_execution_time`.
f1c06930 8By default, the strategy uses the average task execution time for each worker but it can be configured to use the task event loop utilization (ELU) active time instead.
9e2ab226
JB
9
10### Weighted round robin
11
afe102b2
JB
12The strategy assigns the next task using a robin round algorithm. The worker weights are maximum tasks execution time, once the worker has reached its maximum tasks execution time, the next task is assigned to the next worker.
13
9e2ab226
JB
14### Interleaved weighted round robin
15
16## Statistics
17
afe102b2
JB
18Worker choice strategies enable only the statistics that are needed to choose the next worker to avoid unnecessary overhead.
19
9e2ab226
JB
20### Median
21
22Strategies using the average task execution time for each worker can use the median instead. Median is more robust to outliers and can be used to avoid assigning tasks to workers that are currently overloaded. Median usage introduces a small overhead: measurement history must be kept for each worker and the median must be recomputed each time a new task has finished.