Skip to main content
Version: 3.8

AutoscaledPoolOptions

Index

Properties

optionalautoscaleIntervalSecs

autoscaleIntervalSecs?: number = ```ts 10 ```

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.

optionaldesiredConcurrency

desiredConcurrency?: 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.

optionaldesiredConcurrencyRatio

desiredConcurrencyRatio?: number = ```ts 0.90 ```

Minimum level of desired concurrency to reach before more scaling up is allowed.

optionalisFinishedFunction

isFinishedFunction?: () => Promise<boolean>

Type declaration

    • (): Promise<boolean>
    • 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.


      Returns Promise<boolean>

optionalisTaskReadyFunction

isTaskReadyFunction?: () => Promise<boolean>

Type declaration

    • (): Promise<boolean>
    • 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.


      Returns Promise<boolean>

optionallog

log?: Log

optionalloggingIntervalSecs

loggingIntervalSecs?: null | number = null | number

Specifies a period in which the instance logs its state, in seconds. Set to null to disable periodic logging.

optionalmaxConcurrency

maxConcurrency?: number = ```ts 200 ```

The maximum number of tasks running in parallel.

optionalmaxTasksPerMinute

maxTasksPerMinute?: number

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

maybeRunIntervalSecs?: number = ```ts 0.5 ```

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

minConcurrency?: number = ```ts 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.

optionalrunTaskFunction

runTaskFunction?: () => Promise<unknown>

Type declaration

    • (): Promise<unknown>
    • A function that performs an asynchronous resource-intensive task. The function must either be labeled async or return a promise.


      Returns Promise<unknown>

optionalscaleDownStepRatio

scaleDownStepRatio?: number = ```ts 0.05 ```

Defines the amount of desired concurrency to be subtracted with each scaling down. The minimum scaling step is one.

optionalscaleUpStepRatio

scaleUpStepRatio?: number = ```ts 0.05 ```

Defines the fractional amount of desired concurrency to be added with each scaling up. The minimum scaling step is one.

optionalsnapshotterOptions

snapshotterOptions?: SnapshotterOptions

Options to be passed down to the Snapshotter constructor. This is useful for fine-tuning the snapshot intervals and history.

optionalsystemStatusOptions

systemStatusOptions?: SystemStatusOptions

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

taskTimeoutSecs?: number = ```ts 0 ```

Timeout in which the runTaskFunction needs to finish, given in seconds.