Apify SDK

Apify SDK

  • Guide
  • Examples
  • Reference
  • GitHub

›Autoscaling Tools

Autoscaling Tools

  • Snapshotter
  • SystemStatus

SystemStatus

Provides a simple interface to reading system status from a Snapshotter instance. It only exposes two functions getCurrentStatus() and getHistoricalStatus(). The system status is calculated using a weighted average of overloaded messages in the snapshots, with the weights being the time intervals between the snapshots. Each resource is calculated separately and the system is overloaded whenever at least one resource is overloaded. The class is used by the AutoscaledPool class.

getCurrentStatus() returns a boolean that represents the current status of the system. The length of the current timeframe in seconds is configurable by the currentHistorySecs option and represents the max age of snapshots to be considered for the calculation.

getHistoricalStatus() returns a boolean that represents the long-term status of the system. It considers the full snapshot history available in the Snapshotter instance.

  • SystemStatus
    • new SystemStatus([options])
    • .getCurrentStatus() ⇒ Object
    • .getHistoricalStatus() ⇒ Object

new SystemStatus([options])

ParamTypeDefault
[options]Object

All SystemStatus parameters are passed via an options object with the following keys:

[options.currentHistorySecs]Number5

Defines max age of snapshots used in the getCurrentStatus() measurement.

[options.maxMemoryOverloadedRatio]Number0.2

Sets the maximum ratio of overloaded snapshots in a memory sample. If the sample exceeds this ratio, the system will be overloaded.

[options.maxEventLoopOverloadedRatio]Number0.2

Sets the maximum ratio of overloaded snapshots in an event loop sample. If the sample exceeds this ratio, the system will be overloaded.

[options.maxCpuOverloadedRatio]Number0.4

Sets the maximum ratio of overloaded snapshots in a CPU sample. If the sample exceeds this ratio, the system will be overloaded.

[options.maxClientOverloadedRatio]Number0.2

Sets the maximum ratio of overloaded snapshots in a Client sample. If the sample exceeds this ratio, the system will be overloaded.

systemStatus.getCurrentStatus() ⇒ Object

Returns an object with the following structure:

{
    isSystemIdle: Boolean,
    memInfo: Object,
    eventLoopInfo: Object,
    cpuInfo: Object
}

Where the isSystemIdle property is set to false if the system has been overloaded in the last options.currentHistorySecs seconds, and true otherwise.

systemStatus.getHistoricalStatus() ⇒ Object

Returns an object with the following structure:

{
    isSystemIdle: Boolean,
    memInfo: Object,
    eventLoopInfo: Object,
    cpuInfo: Object
}

Where the isSystemIdle property is set to false if the system has been overloaded in the full history of the Snapshotter (which is configurable in the Snapshotter) and true otherwise.

← Snapshotter
  • new SystemStatus([options])
  • systemStatus.getCurrentStatus() ⇒ Object
  • systemStatus.getHistoricalStatus() ⇒ Object
Apify SDK
Docs
GuideExamplesReference
Community
Stack OverflowTwitterFacebook
More
Apify CloudDocusaurusGitHub
Copyright © 2019 Apify Technologies s.r.o.