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])
Param | Type | Default |
---|---|---|
[options] | Object | |
All | ||
[options.currentHistorySecs] | Number | 5 |
Defines max age of snapshots used in the
| ||
[options.maxMemoryOverloadedRatio] | Number | 0.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] | Number | 0.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] | Number | 0.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] | Number | 0.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.