AutoscaledPoolOptions
Properties
runTaskFunction
Type: function
A function that performs an asynchronous resource-intensive task. The function must either be labeled async
or return a promise.
isTaskReadyFunction
Type: function
A function that indicates whether runTaskFunction
should be called. This function is called every time there is free capacity for a new task and it
should indicate whether it should start a new task or not by resolving to either true
or false
. Besides its obvious use, it is also useful for
task throttling to save resources.
isFinishedFunction
Type: function
A function that is called only when there are no tasks to be processed. If it resolves to true
then the pool's run finishes. Being called only when
there are no tasks being processed means that as long as isTaskReadyFunction()
keeps resolving to true
, isFinishedFunction()
will never be
called. To abort a run, use the AutoscaledPool.abort()
method.
minConcurrency
Type: number
= 1
The minimum number of tasks running in parallel.
WARNING: If you set this value too high with respect to the available system memory and CPU, your code might run extremely slow or crash. If you're not sure, just keep the default value and the concurrency will scale up automatically.
maxConcurrency
Type: number
= 1000
The maximum number of tasks running in parallel.
desiredConcurrency
Type: number
The desired number of tasks that should be running parallel on the start of the pool, if there is a large enough supply of them. By default, it is
minConcurrency
.
desiredConcurrencyRatio
Type: number
= 0.95
Minimum level of desired concurrency to reach before more scaling up is allowed.
scaleUpStepRatio
Type: number
= 0.05
Defines the fractional amount of desired concurrency to be added with each scaling up. The minimum scaling step is one.