AutoscaledPoolOptions
Index
Properties
optionalautoscaleIntervalSecs
optionaldesiredConcurrency
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
.
optionaldesiredConcurrencyRatio
Minimum level of desired concurrency to reach before more scaling up is allowed.
optionalisFinishedFunction
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.
Type declaration
Returns Promise<boolean>
optionalisTaskReadyFunction
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.
Type declaration
Returns Promise<boolean>
optionallog
optionalloggingIntervalSecs
Specifies a period in which the instance logs its state, in seconds.
Set to null
to disable periodic logging.
optionalmaxConcurrency
The maximum number of tasks running in parallel.
optionalmaxTasksPerMinute
The maximum number of tasks per minute the pool can run.
By default, this is set to Infinity
, but you can pass any positive, non-zero integer.
optionalmaybeRunIntervalSecs
Indicates how often the pool should call the runTaskFunction()
to start a new task, in seconds.
This has no effect on starting new tasks immediately after a task completes.
optionalminConcurrency
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.
optionalrunTaskFunction
A function that performs an asynchronous resource-intensive task.
The function must either be labeled async
or return a promise.
Type declaration
Returns Promise<unknown>
optionalscaleDownStepRatio
Defines the amount of desired concurrency to be subtracted with each scaling down. The minimum scaling step is one.
optionalscaleUpStepRatio
Defines the fractional amount of desired concurrency to be added with each scaling up. The minimum scaling step is one.
optionalsnapshotterOptions
Options to be passed down to the Snapshotter constructor. This is useful for fine-tuning the snapshot intervals and history.
optionalsystemStatusOptions
Options to be passed down to the SystemStatus constructor. This is useful for fine-tuning the system status reports. If a custom snapshotter is set in the options, it will be used by the pool.
optionaltaskTimeoutSecs
Timeout in which the runTaskFunction
needs to finish, given in seconds.
Defines in seconds how often the pool should attempt to adjust the desired concurrency based on the latest system status. Setting it lower than 1 might have a severe impact on performance. We suggest using a value from 5 to 20.