@crawlee/core 4.0.0-beta.28 → 4.0.0-beta.280
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/byte-utils.d.ts +17 -0
- package/byte-utils.js +42 -0
- package/configuration.d.ts +75 -167
- package/configuration.js +164 -140
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/errors.d.ts +40 -19
- package/errors.js +52 -30
- package/events/{event_manager.d.ts → event-manager.d.ts} +29 -6
- package/events/{event_manager.js → event-manager.js} +10 -9
- package/events/index.d.ts +3 -3
- package/events/index.js +2 -3
- package/events/{local_event_manager.d.ts → local-event-manager.d.ts} +3 -10
- package/events/local-event-manager.js +101 -0
- package/events/system-info.d.ts +38 -0
- package/events/system-info.js +1 -0
- package/index.d.ts +9 -13
- package/index.js +10 -12
- package/internal.d.ts +8 -0
- package/internal.js +9 -0
- package/iterables.d.ts +79 -0
- package/iterables.js +134 -0
- package/log.d.ts +77 -1
- package/log.js +134 -1
- package/memory-storage/consts.d.ts +4 -0
- package/memory-storage/consts.js +4 -0
- package/memory-storage/index.d.ts +1 -0
- package/memory-storage/index.js +1 -0
- package/memory-storage/memory-storage.d.ts +43 -0
- package/memory-storage/memory-storage.js +158 -0
- package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
- package/memory-storage/resource-clients/common/base-client.js +6 -0
- package/memory-storage/resource-clients/dataset.d.ts +35 -0
- package/memory-storage/resource-clients/dataset.js +108 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +54 -0
- package/memory-storage/resource-clients/key-value-store.js +179 -0
- package/memory-storage/resource-clients/request-queue.d.ts +55 -0
- package/memory-storage/resource-clients/request-queue.js +413 -0
- package/memory-storage/utils.d.ts +16 -0
- package/memory-storage/utils.js +41 -0
- package/owned-or-injected.d.ts +58 -0
- package/owned-or-injected.js +98 -0
- package/package.json +23 -23
- package/proxy-configuration.d.ts +118 -0
- package/proxy-configuration.js +141 -0
- package/recoverable-state.d.ts +177 -0
- package/recoverable-state.js +268 -0
- package/request.d.ts +48 -101
- package/request.js +139 -249
- package/serialization.d.ts +0 -1
- package/serialization.js +18 -18
- package/{service_locator.d.ts → service-locator.d.ts} +66 -37
- package/service-locator.js +255 -0
- package/storages/batched-adds.d.ts +39 -0
- package/storages/batched-adds.js +81 -0
- package/storages/dataset.d.ts +105 -58
- package/storages/dataset.js +292 -151
- package/storages/index.d.ts +11 -12
- package/storages/index.js +7 -12
- package/storages/key-value-store-codec.d.ts +32 -0
- package/storages/key-value-store-codec.js +108 -0
- package/storages/{key_value_store.d.ts → key-value-store.d.ts} +169 -72
- package/storages/key-value-store.js +767 -0
- package/storages/request-dedup-cache.d.ts +20 -0
- package/storages/request-dedup-cache.js +48 -0
- package/storages/{request_list.d.ts → request-list.d.ts} +32 -171
- package/storages/{request_list.js → request-list.js} +276 -253
- package/storages/request-loader.d.ts +127 -0
- package/storages/request-loader.js +34 -0
- package/storages/request-manager-tandem.d.ts +82 -0
- package/storages/request-manager-tandem.js +200 -0
- package/storages/request-manager.d.ts +119 -0
- package/storages/request-manager.js +1 -0
- package/storages/{request_provider.d.ts → request-queue.d.ts} +127 -161
- package/storages/request-queue.js +871 -0
- package/storages/storage-instance-manager.d.ts +86 -0
- package/storages/storage-instance-manager.js +256 -0
- package/storages/storage-stats.d.ts +48 -0
- package/storages/storage-stats.js +29 -0
- package/storages/transaction.d.ts +270 -0
- package/storages/transaction.js +296 -0
- package/storages/utils.d.ts +59 -11
- package/storages/utils.js +76 -17
- package/system-info/cpu-info.d.ts +67 -0
- package/system-info/cpu-info.js +216 -0
- package/system-info/memory-info.d.ts +31 -0
- package/system-info/memory-info.js +115 -0
- package/system-info/ps-tree.d.ts +17 -0
- package/system-info/ps-tree.js +144 -0
- package/system-info/runtime.d.ts +14 -0
- package/system-info/runtime.js +80 -0
- package/typedefs.d.ts +0 -6
- package/typedefs.js +0 -1
- package/url.d.ts +9 -0
- package/url.js +11 -0
- package/validators.d.ts +23 -18
- package/validators.js +14 -18
- package/autoscaling/autoscaled_pool.d.ts +0 -298
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js +0 -527
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts +0 -4
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js +0 -4
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts +0 -179
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js +0 -279
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts +0 -178
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js +0 -168
- package/autoscaling/system_status.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/cookie_utils.d.ts +0 -43
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js +0 -111
- package/cookie_utils.js.map +0 -1
- package/crawlers/context_pipeline.d.ts +0 -61
- package/crawlers/context_pipeline.d.ts.map +0 -1
- package/crawlers/context_pipeline.js +0 -99
- package/crawlers/context_pipeline.js.map +0 -1
- package/crawlers/crawler_commons.d.ts +0 -191
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js +0 -108
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_utils.d.ts +0 -10
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js +0 -12
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts +0 -60
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js +0 -118
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts +0 -55
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js +0 -309
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts +0 -7
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js +0 -7
- package/crawlers/index.js.map +0 -1
- package/crawlers/internals/types.d.ts +0 -8
- package/crawlers/internals/types.d.ts.map +0 -1
- package/crawlers/internals/types.js +0 -2
- package/crawlers/internals/types.js.map +0 -1
- package/crawlers/statistics.d.ts +0 -204
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js +0 -350
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts +0 -254
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js +0 -268
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts +0 -3
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js +0 -3
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts +0 -84
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js +0 -219
- package/enqueue_links/shared.js.map +0 -1
- package/errors.d.ts.map +0 -1
- package/errors.js.map +0 -1
- package/events/event_manager.d.ts.map +0 -1
- package/events/event_manager.js.map +0 -1
- package/events/index.d.ts.map +0 -1
- package/events/index.js.map +0 -1
- package/events/local_event_manager.d.ts.map +0 -1
- package/events/local_event_manager.js +0 -93
- package/events/local_event_manager.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/log.d.ts.map +0 -1
- package/log.js.map +0 -1
- package/proxy_configuration.d.ts +0 -169
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js +0 -247
- package/proxy_configuration.js.map +0 -1
- package/recoverable_state.d.ts +0 -122
- package/recoverable_state.d.ts.map +0 -1
- package/recoverable_state.js +0 -138
- package/recoverable_state.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts +0 -134
- package/router.d.ts.map +0 -1
- package/router.js +0 -164
- package/router.js.map +0 -1
- package/serialization.d.ts.map +0 -1
- package/serialization.js.map +0 -1
- package/service_locator.d.ts.map +0 -1
- package/service_locator.js +0 -252
- package/service_locator.js.map +0 -1
- package/session_pool/consts.d.ts +0 -4
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js +0 -4
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts +0 -8
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js +0 -12
- package/session_pool/errors.js.map +0 -1
- package/session_pool/events.d.ts +0 -3
- package/session_pool/events.d.ts.map +0 -1
- package/session_pool/events.js +0 -3
- package/session_pool/events.js.map +0 -1
- package/session_pool/index.d.ts +0 -6
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js +0 -6
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts +0 -186
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js +0 -278
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts +0 -256
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js +0 -386
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts +0 -13
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js +0 -14
- package/storages/access_checking.js.map +0 -1
- package/storages/dataset.d.ts.map +0 -1
- package/storages/dataset.js.map +0 -1
- package/storages/index.d.ts.map +0 -1
- package/storages/index.js.map +0 -1
- package/storages/key_value_store.d.ts.map +0 -1
- package/storages/key_value_store.js +0 -513
- package/storages/key_value_store.js.map +0 -1
- package/storages/request_list.d.ts.map +0 -1
- package/storages/request_list.js.map +0 -1
- package/storages/request_list_adapter.d.ts +0 -58
- package/storages/request_list_adapter.d.ts.map +0 -1
- package/storages/request_list_adapter.js +0 -81
- package/storages/request_list_adapter.js.map +0 -1
- package/storages/request_manager_tandem.d.ts +0 -68
- package/storages/request_manager_tandem.d.ts.map +0 -1
- package/storages/request_manager_tandem.js +0 -124
- package/storages/request_manager_tandem.js.map +0 -1
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -592
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts +0 -128
- package/storages/request_queue.d.ts.map +0 -1
- package/storages/request_queue.js +0 -320
- package/storages/request_queue.js.map +0 -1
- package/storages/request_queue_v2.d.ts +0 -87
- package/storages/request_queue_v2.d.ts.map +0 -1
- package/storages/request_queue_v2.js +0 -437
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts +0 -245
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js +0 -431
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -60
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js +0 -95
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/typedefs.d.ts.map +0 -1
- package/typedefs.js.map +0 -1
- package/validators.d.ts.map +0 -1
- package/validators.js.map +0 -1
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import type { Log } from '@apify/log';
|
|
2
|
-
import type { BetterIntervalID } from '@apify/utilities';
|
|
3
|
-
import type { SystemInfo } from './system_status.js';
|
|
4
|
-
export interface SnapshotterOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Defines the interval of measuring the event loop response time.
|
|
7
|
-
* @default 0.5
|
|
8
|
-
*/
|
|
9
|
-
eventLoopSnapshotIntervalSecs?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Defines the interval of checking the current state
|
|
12
|
-
* of the remote API client.
|
|
13
|
-
* @default 1
|
|
14
|
-
*/
|
|
15
|
-
clientSnapshotIntervalSecs?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Maximum allowed delay of the event loop in milliseconds.
|
|
18
|
-
* Exceeding this limit overloads the event loop.
|
|
19
|
-
* @default 50
|
|
20
|
-
*/
|
|
21
|
-
maxBlockedMillis?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Defines the maximum ratio of total memory that can be used.
|
|
24
|
-
* Exceeding this limit overloads the memory.
|
|
25
|
-
* @default 0.9
|
|
26
|
-
*/
|
|
27
|
-
maxUsedMemoryRatio?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Defines the maximum number of new rate limit errors within
|
|
30
|
-
* the given interval.
|
|
31
|
-
* @default 1
|
|
32
|
-
*/
|
|
33
|
-
maxClientErrors?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Sets the interval in seconds for which a history of resource snapshots
|
|
36
|
-
* will be kept. Increasing this to very high numbers will affect performance.
|
|
37
|
-
* @default 60
|
|
38
|
-
*/
|
|
39
|
-
snapshotHistorySecs?: number;
|
|
40
|
-
/** @internal */
|
|
41
|
-
log?: Log;
|
|
42
|
-
}
|
|
43
|
-
interface MemorySnapshot {
|
|
44
|
-
createdAt: Date;
|
|
45
|
-
isOverloaded: boolean;
|
|
46
|
-
usedBytes?: number;
|
|
47
|
-
}
|
|
48
|
-
interface CpuSnapshot {
|
|
49
|
-
createdAt: Date;
|
|
50
|
-
isOverloaded: boolean;
|
|
51
|
-
usedRatio: number;
|
|
52
|
-
ticks?: {
|
|
53
|
-
idle: number;
|
|
54
|
-
total: number;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
interface EventLoopSnapshot {
|
|
58
|
-
createdAt: Date;
|
|
59
|
-
isOverloaded: boolean;
|
|
60
|
-
exceededMillis: number;
|
|
61
|
-
}
|
|
62
|
-
interface ClientSnapshot {
|
|
63
|
-
createdAt: Date;
|
|
64
|
-
isOverloaded: boolean;
|
|
65
|
-
rateLimitErrorCount: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates snapshots of system resources at given intervals and marks the resource
|
|
69
|
-
* as either overloaded or not during the last interval. Keeps a history of the snapshots.
|
|
70
|
-
* It tracks the following resources: Memory, EventLoop, API and CPU.
|
|
71
|
-
* The class is used by the {@link AutoscaledPool} class.
|
|
72
|
-
*
|
|
73
|
-
* When running on the Apify platform, the CPU and memory statistics are provided by the platform,
|
|
74
|
-
* as collected from the running Docker container. When running locally, `Snapshotter`
|
|
75
|
-
* makes its own statistics by querying the OS.
|
|
76
|
-
*
|
|
77
|
-
* CPU becomes overloaded locally when its current use exceeds the `maxUsedCpuRatio` option or
|
|
78
|
-
* when Apify platform marks it as overloaded.
|
|
79
|
-
*
|
|
80
|
-
* Memory becomes overloaded if its current use exceeds the `maxUsedMemoryRatio` option.
|
|
81
|
-
* It's computed using the total memory available to the container when running on
|
|
82
|
-
* the Apify platform and a quarter of total system memory when running locally.
|
|
83
|
-
* Max total memory when running locally may be overridden by using the `CRAWLEE_MEMORY_MBYTES`
|
|
84
|
-
* environment variable.
|
|
85
|
-
*
|
|
86
|
-
* Event loop becomes overloaded if it slows down by more than the `maxBlockedMillis` option.
|
|
87
|
-
*
|
|
88
|
-
* Client becomes overloaded when rate limit errors (429 - Too Many Requests),
|
|
89
|
-
* typically received from the request queue, exceed the set limit within the set interval.
|
|
90
|
-
* @category Scaling
|
|
91
|
-
*/
|
|
92
|
-
export declare class Snapshotter {
|
|
93
|
-
log: Log;
|
|
94
|
-
eventLoopSnapshotIntervalMillis: number;
|
|
95
|
-
clientSnapshotIntervalMillis: number;
|
|
96
|
-
snapshotHistoryMillis: number;
|
|
97
|
-
maxBlockedMillis: number;
|
|
98
|
-
maxUsedMemoryRatio: number;
|
|
99
|
-
maxClientErrors: number;
|
|
100
|
-
maxMemoryBytes: number;
|
|
101
|
-
cpuSnapshots: CpuSnapshot[];
|
|
102
|
-
eventLoopSnapshots: EventLoopSnapshot[];
|
|
103
|
-
memorySnapshots: MemorySnapshot[];
|
|
104
|
-
clientSnapshots: ClientSnapshot[];
|
|
105
|
-
eventLoopInterval: BetterIntervalID;
|
|
106
|
-
clientInterval: BetterIntervalID;
|
|
107
|
-
lastLoggedCriticalMemoryOverloadAt: Date | null;
|
|
108
|
-
/**
|
|
109
|
-
* @param [options] All `Snapshotter` configuration options.
|
|
110
|
-
*/
|
|
111
|
-
constructor(options?: SnapshotterOptions);
|
|
112
|
-
/**
|
|
113
|
-
* Starts capturing snapshots at configured intervals.
|
|
114
|
-
*/
|
|
115
|
-
start(): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Stops all resource capturing.
|
|
118
|
-
*/
|
|
119
|
-
stop(): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* Returns a sample of latest memory snapshots, with the size of the sample defined
|
|
122
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
123
|
-
*/
|
|
124
|
-
getMemorySample(sampleDurationMillis?: number): MemorySnapshot[];
|
|
125
|
-
/**
|
|
126
|
-
* Returns a sample of latest event loop snapshots, with the size of the sample defined
|
|
127
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
128
|
-
*/
|
|
129
|
-
getEventLoopSample(sampleDurationMillis?: number): EventLoopSnapshot[];
|
|
130
|
-
/**
|
|
131
|
-
* Returns a sample of latest CPU snapshots, with the size of the sample defined
|
|
132
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
133
|
-
*/
|
|
134
|
-
getCpuSample(sampleDurationMillis?: number): CpuSnapshot[];
|
|
135
|
-
/**
|
|
136
|
-
* Returns a sample of latest Client snapshots, with the size of the sample defined
|
|
137
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
138
|
-
*/
|
|
139
|
-
getClientSample(sampleDurationMillis?: number): ClientSnapshot[];
|
|
140
|
-
/**
|
|
141
|
-
* Finds the latest snapshots by sampleDurationMillis in the provided array.
|
|
142
|
-
*/
|
|
143
|
-
protected _getSample<T extends {
|
|
144
|
-
createdAt: Date;
|
|
145
|
-
}>(snapshots: T[], sampleDurationMillis?: number): T[];
|
|
146
|
-
/**
|
|
147
|
-
* Creates a snapshot of current memory usage
|
|
148
|
-
* using the Apify platform `systemInfo` event.
|
|
149
|
-
*/
|
|
150
|
-
protected _snapshotMemory(systemInfo: SystemInfo): void;
|
|
151
|
-
/**
|
|
152
|
-
* Checks for critical memory overload and logs it to the console.
|
|
153
|
-
*/
|
|
154
|
-
protected _memoryOverloadWarning(systemInfo: SystemInfo): void;
|
|
155
|
-
/**
|
|
156
|
-
* Creates a snapshot of current event loop delay.
|
|
157
|
-
*/
|
|
158
|
-
protected _snapshotEventLoop(intervalCallback: () => unknown): void;
|
|
159
|
-
/**
|
|
160
|
-
* Creates a snapshot of current CPU usage using the Apify platform `systemInfo` event.
|
|
161
|
-
*/
|
|
162
|
-
protected _snapshotCpu(systemInfo: SystemInfo): void;
|
|
163
|
-
/**
|
|
164
|
-
* Creates a snapshot of current API state by checking for
|
|
165
|
-
* rate limit errors. Only errors produced by a 2nd retry
|
|
166
|
-
* of the API call are considered for snapshotting since
|
|
167
|
-
* earlier errors may just be caused by a random spike in
|
|
168
|
-
* number of requests and do not necessarily signify API
|
|
169
|
-
* overloading.
|
|
170
|
-
*/
|
|
171
|
-
protected _snapshotClient(intervalCallback: () => unknown): void;
|
|
172
|
-
/**
|
|
173
|
-
* Removes snapshots that are older than the snapshotHistorySecs option
|
|
174
|
-
* from the array (destructively - in place).
|
|
175
|
-
*/
|
|
176
|
-
protected _pruneSnapshots(snapshots: MemorySnapshot[] | CpuSnapshot[] | EventLoopSnapshot[] | ClientSnapshot[], now: Date): void;
|
|
177
|
-
}
|
|
178
|
-
export {};
|
|
179
|
-
//# sourceMappingURL=snapshotter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotter.d.ts","sourceRoot":"","sources":["../../src/autoscaling/snapshotter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMrD,MAAM,WAAW,kBAAkB;IAC/B;;;OAGG;IACH,6BAA6B,CAAC,EAAE,MAAM,CAA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,iBAAiB,EAAE,GAAG,cAAc,EAAE,EACpF,GAAG,EAAE,IAAI;CAUhB"}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { getMemoryInfo, isContainerized } from '@crawlee/utils';
|
|
2
|
-
import ow from 'ow';
|
|
3
|
-
import { betterClearInterval, betterSetInterval } from '@apify/utilities';
|
|
4
|
-
import { log as defaultLog } from '../log.js';
|
|
5
|
-
import { serviceLocator } from '../service_locator.js';
|
|
6
|
-
const RESERVE_MEMORY_RATIO = 0.5;
|
|
7
|
-
const CLIENT_RATE_LIMIT_ERROR_RETRY_COUNT = 2;
|
|
8
|
-
const CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS = 10000;
|
|
9
|
-
/**
|
|
10
|
-
* Creates snapshots of system resources at given intervals and marks the resource
|
|
11
|
-
* as either overloaded or not during the last interval. Keeps a history of the snapshots.
|
|
12
|
-
* It tracks the following resources: Memory, EventLoop, API and CPU.
|
|
13
|
-
* The class is used by the {@link AutoscaledPool} class.
|
|
14
|
-
*
|
|
15
|
-
* When running on the Apify platform, the CPU and memory statistics are provided by the platform,
|
|
16
|
-
* as collected from the running Docker container. When running locally, `Snapshotter`
|
|
17
|
-
* makes its own statistics by querying the OS.
|
|
18
|
-
*
|
|
19
|
-
* CPU becomes overloaded locally when its current use exceeds the `maxUsedCpuRatio` option or
|
|
20
|
-
* when Apify platform marks it as overloaded.
|
|
21
|
-
*
|
|
22
|
-
* Memory becomes overloaded if its current use exceeds the `maxUsedMemoryRatio` option.
|
|
23
|
-
* It's computed using the total memory available to the container when running on
|
|
24
|
-
* the Apify platform and a quarter of total system memory when running locally.
|
|
25
|
-
* Max total memory when running locally may be overridden by using the `CRAWLEE_MEMORY_MBYTES`
|
|
26
|
-
* environment variable.
|
|
27
|
-
*
|
|
28
|
-
* Event loop becomes overloaded if it slows down by more than the `maxBlockedMillis` option.
|
|
29
|
-
*
|
|
30
|
-
* Client becomes overloaded when rate limit errors (429 - Too Many Requests),
|
|
31
|
-
* typically received from the request queue, exceed the set limit within the set interval.
|
|
32
|
-
* @category Scaling
|
|
33
|
-
*/
|
|
34
|
-
export class Snapshotter {
|
|
35
|
-
log;
|
|
36
|
-
eventLoopSnapshotIntervalMillis;
|
|
37
|
-
clientSnapshotIntervalMillis;
|
|
38
|
-
snapshotHistoryMillis;
|
|
39
|
-
maxBlockedMillis;
|
|
40
|
-
maxUsedMemoryRatio;
|
|
41
|
-
maxClientErrors;
|
|
42
|
-
maxMemoryBytes;
|
|
43
|
-
cpuSnapshots = [];
|
|
44
|
-
eventLoopSnapshots = [];
|
|
45
|
-
memorySnapshots = [];
|
|
46
|
-
clientSnapshots = [];
|
|
47
|
-
eventLoopInterval = null;
|
|
48
|
-
clientInterval = null;
|
|
49
|
-
lastLoggedCriticalMemoryOverloadAt = null;
|
|
50
|
-
/**
|
|
51
|
-
* @param [options] All `Snapshotter` configuration options.
|
|
52
|
-
*/
|
|
53
|
-
constructor(options = {}) {
|
|
54
|
-
ow(options, ow.object.exactShape({
|
|
55
|
-
eventLoopSnapshotIntervalSecs: ow.optional.number,
|
|
56
|
-
clientSnapshotIntervalSecs: ow.optional.number,
|
|
57
|
-
snapshotHistorySecs: ow.optional.number,
|
|
58
|
-
maxBlockedMillis: ow.optional.number,
|
|
59
|
-
maxUsedMemoryRatio: ow.optional.number,
|
|
60
|
-
maxClientErrors: ow.optional.number,
|
|
61
|
-
log: ow.optional.object,
|
|
62
|
-
}));
|
|
63
|
-
const { eventLoopSnapshotIntervalSecs = 0.5, clientSnapshotIntervalSecs = 1, snapshotHistorySecs = 30, maxBlockedMillis = 50, maxUsedMemoryRatio = 0.9, maxClientErrors = 3, log = defaultLog, } = options;
|
|
64
|
-
this.log = log.child({ prefix: 'Snapshotter' });
|
|
65
|
-
this.eventLoopSnapshotIntervalMillis = eventLoopSnapshotIntervalSecs * 1000;
|
|
66
|
-
this.clientSnapshotIntervalMillis = clientSnapshotIntervalSecs * 1000;
|
|
67
|
-
this.snapshotHistoryMillis = snapshotHistorySecs * 1000;
|
|
68
|
-
this.maxBlockedMillis = maxBlockedMillis;
|
|
69
|
-
this.maxUsedMemoryRatio = maxUsedMemoryRatio;
|
|
70
|
-
this.maxClientErrors = maxClientErrors;
|
|
71
|
-
// We need to pre-bind those functions to be able to successfully remove listeners.
|
|
72
|
-
this._snapshotCpu = this._snapshotCpu.bind(this);
|
|
73
|
-
this._snapshotMemory = this._snapshotMemory.bind(this);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Starts capturing snapshots at configured intervals.
|
|
77
|
-
*/
|
|
78
|
-
async start() {
|
|
79
|
-
const memoryMbytes = serviceLocator.getConfiguration().get('memoryMbytes', 0);
|
|
80
|
-
if (memoryMbytes > 0) {
|
|
81
|
-
this.maxMemoryBytes = memoryMbytes * 1024 * 1024;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
const containerized = serviceLocator.getConfiguration().get('containerized', await isContainerized());
|
|
85
|
-
const memInfo = await getMemoryInfo(containerized);
|
|
86
|
-
const totalBytes = memInfo.totalBytes;
|
|
87
|
-
this.maxMemoryBytes = Math.ceil(totalBytes * serviceLocator.getConfiguration().get('availableMemoryRatio'));
|
|
88
|
-
this.log.debug(`Setting max memory of this run to ${Math.round(this.maxMemoryBytes / 1024 / 1024)} MB. ` +
|
|
89
|
-
'Use the CRAWLEE_MEMORY_MBYTES or CRAWLEE_AVAILABLE_MEMORY_RATIO environment variable to override it.');
|
|
90
|
-
}
|
|
91
|
-
// Start snapshotting.
|
|
92
|
-
this.eventLoopInterval = betterSetInterval(this._snapshotEventLoop.bind(this), this.eventLoopSnapshotIntervalMillis);
|
|
93
|
-
this.clientInterval = betterSetInterval(this._snapshotClient.bind(this), this.clientSnapshotIntervalMillis);
|
|
94
|
-
const events = serviceLocator.getEventManager();
|
|
95
|
-
events.on("systemInfo" /* EventType.SYSTEM_INFO */, this._snapshotCpu);
|
|
96
|
-
events.on("systemInfo" /* EventType.SYSTEM_INFO */, this._snapshotMemory);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Stops all resource capturing.
|
|
100
|
-
*/
|
|
101
|
-
async stop() {
|
|
102
|
-
betterClearInterval(this.eventLoopInterval);
|
|
103
|
-
betterClearInterval(this.clientInterval);
|
|
104
|
-
const events = serviceLocator.getEventManager();
|
|
105
|
-
events.off("systemInfo" /* EventType.SYSTEM_INFO */, this._snapshotCpu);
|
|
106
|
-
events.off("systemInfo" /* EventType.SYSTEM_INFO */, this._snapshotMemory);
|
|
107
|
-
// Allow microtask queue to unwind before stop returns.
|
|
108
|
-
await new Promise((resolve) => {
|
|
109
|
-
setImmediate(resolve);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Returns a sample of latest memory snapshots, with the size of the sample defined
|
|
114
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
115
|
-
*/
|
|
116
|
-
getMemorySample(sampleDurationMillis) {
|
|
117
|
-
return this._getSample(this.memorySnapshots, sampleDurationMillis);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Returns a sample of latest event loop snapshots, with the size of the sample defined
|
|
121
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
122
|
-
*/
|
|
123
|
-
getEventLoopSample(sampleDurationMillis) {
|
|
124
|
-
return this._getSample(this.eventLoopSnapshots, sampleDurationMillis);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Returns a sample of latest CPU snapshots, with the size of the sample defined
|
|
128
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
129
|
-
*/
|
|
130
|
-
getCpuSample(sampleDurationMillis) {
|
|
131
|
-
return this._getSample(this.cpuSnapshots, sampleDurationMillis);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Returns a sample of latest Client snapshots, with the size of the sample defined
|
|
135
|
-
* by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
|
|
136
|
-
*/
|
|
137
|
-
getClientSample(sampleDurationMillis) {
|
|
138
|
-
return this._getSample(this.clientSnapshots, sampleDurationMillis);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Finds the latest snapshots by sampleDurationMillis in the provided array.
|
|
142
|
-
*/
|
|
143
|
-
_getSample(snapshots, sampleDurationMillis) {
|
|
144
|
-
if (!sampleDurationMillis)
|
|
145
|
-
return snapshots;
|
|
146
|
-
const sample = [];
|
|
147
|
-
let idx = snapshots.length;
|
|
148
|
-
if (!idx)
|
|
149
|
-
return sample;
|
|
150
|
-
const latestTime = snapshots[idx - 1].createdAt;
|
|
151
|
-
while (idx--) {
|
|
152
|
-
const snapshot = snapshots[idx];
|
|
153
|
-
if (+latestTime - +snapshot.createdAt <= sampleDurationMillis) {
|
|
154
|
-
sample.unshift(snapshot);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return sample;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Creates a snapshot of current memory usage
|
|
164
|
-
* using the Apify platform `systemInfo` event.
|
|
165
|
-
*/
|
|
166
|
-
_snapshotMemory(systemInfo) {
|
|
167
|
-
const createdAt = systemInfo.createdAt ? new Date(systemInfo.createdAt) : new Date();
|
|
168
|
-
this._pruneSnapshots(this.memorySnapshots, createdAt);
|
|
169
|
-
const { memCurrentBytes } = systemInfo;
|
|
170
|
-
const snapshot = {
|
|
171
|
-
createdAt,
|
|
172
|
-
isOverloaded: memCurrentBytes / this.maxMemoryBytes > this.maxUsedMemoryRatio,
|
|
173
|
-
usedBytes: memCurrentBytes,
|
|
174
|
-
};
|
|
175
|
-
this.memorySnapshots.push(snapshot);
|
|
176
|
-
this._memoryOverloadWarning(systemInfo);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Checks for critical memory overload and logs it to the console.
|
|
180
|
-
*/
|
|
181
|
-
_memoryOverloadWarning(systemInfo) {
|
|
182
|
-
const { memCurrentBytes } = systemInfo;
|
|
183
|
-
const createdAt = systemInfo.createdAt ? new Date(systemInfo.createdAt) : new Date();
|
|
184
|
-
if (this.lastLoggedCriticalMemoryOverloadAt &&
|
|
185
|
-
+createdAt < +this.lastLoggedCriticalMemoryOverloadAt + CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS)
|
|
186
|
-
return;
|
|
187
|
-
const maxDesiredMemoryBytes = this.maxUsedMemoryRatio * this.maxMemoryBytes;
|
|
188
|
-
const reserveMemory = this.maxMemoryBytes * (1 - this.maxUsedMemoryRatio) * RESERVE_MEMORY_RATIO;
|
|
189
|
-
const criticalOverloadBytes = maxDesiredMemoryBytes + reserveMemory;
|
|
190
|
-
const isCriticalOverload = memCurrentBytes > criticalOverloadBytes;
|
|
191
|
-
if (isCriticalOverload) {
|
|
192
|
-
const usedPercentage = Math.round((memCurrentBytes / this.maxMemoryBytes) * 100);
|
|
193
|
-
const toMb = (bytes) => Math.round(bytes / 1024 ** 2);
|
|
194
|
-
this.log.warning('Memory is critically overloaded. ' +
|
|
195
|
-
`Using ${toMb(memCurrentBytes)} MB of ${toMb(this.maxMemoryBytes)} MB (${usedPercentage}%). Consider increasing available memory.`);
|
|
196
|
-
this.lastLoggedCriticalMemoryOverloadAt = createdAt;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Creates a snapshot of current event loop delay.
|
|
201
|
-
*/
|
|
202
|
-
_snapshotEventLoop(intervalCallback) {
|
|
203
|
-
const now = new Date();
|
|
204
|
-
this._pruneSnapshots(this.eventLoopSnapshots, now);
|
|
205
|
-
const snapshot = {
|
|
206
|
-
createdAt: now,
|
|
207
|
-
isOverloaded: false,
|
|
208
|
-
exceededMillis: 0,
|
|
209
|
-
};
|
|
210
|
-
const previousSnapshot = this.eventLoopSnapshots[this.eventLoopSnapshots.length - 1];
|
|
211
|
-
if (previousSnapshot) {
|
|
212
|
-
const { createdAt } = previousSnapshot;
|
|
213
|
-
const delta = now.getTime() - +createdAt - this.eventLoopSnapshotIntervalMillis;
|
|
214
|
-
if (delta > this.maxBlockedMillis)
|
|
215
|
-
snapshot.isOverloaded = true;
|
|
216
|
-
snapshot.exceededMillis = Math.max(delta - this.maxBlockedMillis, 0);
|
|
217
|
-
}
|
|
218
|
-
this.eventLoopSnapshots.push(snapshot);
|
|
219
|
-
intervalCallback();
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Creates a snapshot of current CPU usage using the Apify platform `systemInfo` event.
|
|
223
|
-
*/
|
|
224
|
-
_snapshotCpu(systemInfo) {
|
|
225
|
-
const { cpuCurrentUsage, isCpuOverloaded } = systemInfo;
|
|
226
|
-
const createdAt = systemInfo.createdAt ? new Date(systemInfo.createdAt) : new Date();
|
|
227
|
-
this._pruneSnapshots(this.cpuSnapshots, createdAt);
|
|
228
|
-
this.cpuSnapshots.push({
|
|
229
|
-
createdAt,
|
|
230
|
-
isOverloaded: isCpuOverloaded,
|
|
231
|
-
usedRatio: Math.ceil(cpuCurrentUsage / 100),
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Creates a snapshot of current API state by checking for
|
|
236
|
-
* rate limit errors. Only errors produced by a 2nd retry
|
|
237
|
-
* of the API call are considered for snapshotting since
|
|
238
|
-
* earlier errors may just be caused by a random spike in
|
|
239
|
-
* number of requests and do not necessarily signify API
|
|
240
|
-
* overloading.
|
|
241
|
-
*/
|
|
242
|
-
_snapshotClient(intervalCallback) {
|
|
243
|
-
const now = new Date();
|
|
244
|
-
this._pruneSnapshots(this.clientSnapshots, now);
|
|
245
|
-
const allErrorCounts = serviceLocator.getStorageClient().stats?.rateLimitErrors ?? []; // storage client might not support this
|
|
246
|
-
const currentErrCount = allErrorCounts[CLIENT_RATE_LIMIT_ERROR_RETRY_COUNT] || 0;
|
|
247
|
-
// Handle empty snapshots array
|
|
248
|
-
const snapshot = {
|
|
249
|
-
createdAt: now,
|
|
250
|
-
isOverloaded: false,
|
|
251
|
-
rateLimitErrorCount: currentErrCount,
|
|
252
|
-
};
|
|
253
|
-
const previousSnapshot = this.clientSnapshots[this.clientSnapshots.length - 1];
|
|
254
|
-
if (previousSnapshot) {
|
|
255
|
-
const { rateLimitErrorCount } = previousSnapshot;
|
|
256
|
-
const delta = currentErrCount - rateLimitErrorCount;
|
|
257
|
-
if (delta > this.maxClientErrors)
|
|
258
|
-
snapshot.isOverloaded = true;
|
|
259
|
-
}
|
|
260
|
-
this.clientSnapshots.push(snapshot);
|
|
261
|
-
intervalCallback();
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Removes snapshots that are older than the snapshotHistorySecs option
|
|
265
|
-
* from the array (destructively - in place).
|
|
266
|
-
*/
|
|
267
|
-
_pruneSnapshots(snapshots, now) {
|
|
268
|
-
let oldCount = 0;
|
|
269
|
-
for (let i = 0; i < snapshots.length; i++) {
|
|
270
|
-
const { createdAt } = snapshots[i];
|
|
271
|
-
if (now.getTime() - new Date(createdAt).getTime() > this.snapshotHistoryMillis)
|
|
272
|
-
oldCount++;
|
|
273
|
-
else
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
snapshots.splice(0, oldCount);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
//# sourceMappingURL=snapshotter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotter.js","sourceRoot":"","sources":["../../src/autoscaling/snapshotter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,oBAAoB,GAAG,GAAG,CA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AC;QACnE,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,gBAAgB,EAAE,CAAC;IACvB,CAAC;IAED;;;OAGG;IACO,eAAe,CACrB,SAAoF,EACpF,GAAS;QAET,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,IAAI,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,qBAAqB;gBAAE,QAAQ,EAAE,CAAC;;gBACtF,MAAM;QACf,CAAC;QACD,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;CACJ"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Snapshotter } from './snapshotter.js';
|
|
2
|
-
/**
|
|
3
|
-
* Represents the current status of the system.
|
|
4
|
-
*/
|
|
5
|
-
export interface SystemInfo {
|
|
6
|
-
/** If false, system is being overloaded. */
|
|
7
|
-
isSystemIdle: boolean;
|
|
8
|
-
memInfo: ClientInfo;
|
|
9
|
-
eventLoopInfo: ClientInfo;
|
|
10
|
-
cpuInfo: ClientInfo;
|
|
11
|
-
clientInfo: ClientInfo;
|
|
12
|
-
memCurrentBytes?: number;
|
|
13
|
-
/**
|
|
14
|
-
* Platform only property
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
cpuCurrentUsage?: number;
|
|
18
|
-
/**
|
|
19
|
-
* Platform only property
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
isCpuOverloaded?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Platform only property
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
createdAt?: Date;
|
|
28
|
-
}
|
|
29
|
-
export interface SystemStatusOptions {
|
|
30
|
-
/**
|
|
31
|
-
* Defines max age of snapshots used in the {@link SystemStatus.getCurrentStatus} measurement.
|
|
32
|
-
* @default 5
|
|
33
|
-
*/
|
|
34
|
-
currentHistorySecs?: number;
|
|
35
|
-
/**
|
|
36
|
-
* Sets the maximum ratio of overloaded snapshots in a memory sample.
|
|
37
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
38
|
-
* @default 0.2
|
|
39
|
-
*/
|
|
40
|
-
maxMemoryOverloadedRatio?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Sets the maximum ratio of overloaded snapshots in an event loop sample.
|
|
43
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
44
|
-
* @default 0.6
|
|
45
|
-
*/
|
|
46
|
-
maxEventLoopOverloadedRatio?: number;
|
|
47
|
-
/**
|
|
48
|
-
* Sets the maximum ratio of overloaded snapshots in a CPU sample.
|
|
49
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
50
|
-
* @default 0.4
|
|
51
|
-
*/
|
|
52
|
-
maxCpuOverloadedRatio?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Sets the maximum ratio of overloaded snapshots in a Client sample.
|
|
55
|
-
* If the sample exceeds this ratio, the system will be overloaded.
|
|
56
|
-
* @default 0.3
|
|
57
|
-
*/
|
|
58
|
-
maxClientOverloadedRatio?: number;
|
|
59
|
-
/**
|
|
60
|
-
* The `Snapshotter` instance to be queried for `SystemStatus`.
|
|
61
|
-
*/
|
|
62
|
-
snapshotter?: Snapshotter;
|
|
63
|
-
}
|
|
64
|
-
export interface ClientInfo {
|
|
65
|
-
isOverloaded: boolean;
|
|
66
|
-
limitRatio: number;
|
|
67
|
-
actualRatio: number;
|
|
68
|
-
}
|
|
69
|
-
export interface FinalStatistics {
|
|
70
|
-
requestsFinished: number;
|
|
71
|
-
requestsFailed: number;
|
|
72
|
-
retryHistogram: number[];
|
|
73
|
-
requestAvgFailedDurationMillis: number;
|
|
74
|
-
requestAvgFinishedDurationMillis: number;
|
|
75
|
-
requestsFinishedPerMinute: number;
|
|
76
|
-
requestsFailedPerMinute: number;
|
|
77
|
-
requestTotalDurationMillis: number;
|
|
78
|
-
requestsTotal: number;
|
|
79
|
-
crawlerRuntimeMillis: number;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Provides a simple interface to reading system status from a {@link Snapshotter} instance.
|
|
83
|
-
* It only exposes two functions {@link SystemStatus.getCurrentStatus}
|
|
84
|
-
* and {@link SystemStatus.getHistoricalStatus}.
|
|
85
|
-
* The system status is calculated using a weighted average of overloaded
|
|
86
|
-
* messages in the snapshots, with the weights being the time intervals
|
|
87
|
-
* between the snapshots. Each resource is calculated separately
|
|
88
|
-
* and the system is overloaded whenever at least one resource is overloaded.
|
|
89
|
-
* The class is used by the {@link AutoscaledPool} class.
|
|
90
|
-
*
|
|
91
|
-
* {@link SystemStatus.getCurrentStatus}
|
|
92
|
-
* returns a boolean that represents the current status of the system.
|
|
93
|
-
* The length of the current timeframe in seconds is configurable
|
|
94
|
-
* by the `currentHistorySecs` option and represents the max age
|
|
95
|
-
* of snapshots to be considered for the calculation.
|
|
96
|
-
*
|
|
97
|
-
* {@link SystemStatus.getHistoricalStatus}
|
|
98
|
-
* returns a boolean that represents the long-term status
|
|
99
|
-
* of the system. It considers the full snapshot history available
|
|
100
|
-
* in the {@link Snapshotter} instance.
|
|
101
|
-
* @category Scaling
|
|
102
|
-
*/
|
|
103
|
-
export declare class SystemStatus {
|
|
104
|
-
private readonly currentHistoryMillis;
|
|
105
|
-
private readonly maxMemoryOverloadedRatio;
|
|
106
|
-
private readonly maxEventLoopOverloadedRatio;
|
|
107
|
-
private readonly maxCpuOverloadedRatio;
|
|
108
|
-
private readonly maxClientOverloadedRatio;
|
|
109
|
-
private readonly snapshotter;
|
|
110
|
-
constructor(options?: SystemStatusOptions);
|
|
111
|
-
/**
|
|
112
|
-
* Returns an {@link SystemInfo} object with the following structure:
|
|
113
|
-
*
|
|
114
|
-
* ```javascript
|
|
115
|
-
* {
|
|
116
|
-
* isSystemIdle: Boolean,
|
|
117
|
-
* memInfo: Object,
|
|
118
|
-
* eventLoopInfo: Object,
|
|
119
|
-
* cpuInfo: Object
|
|
120
|
-
* }
|
|
121
|
-
* ```
|
|
122
|
-
*
|
|
123
|
-
* Where the `isSystemIdle` property is set to `false` if the system
|
|
124
|
-
* has been overloaded in the last `options.currentHistorySecs` seconds,
|
|
125
|
-
* and `true` otherwise.
|
|
126
|
-
*/
|
|
127
|
-
getCurrentStatus(): SystemInfo;
|
|
128
|
-
/**
|
|
129
|
-
* Returns an {@link SystemInfo} object with the following structure:
|
|
130
|
-
*
|
|
131
|
-
* ```javascript
|
|
132
|
-
* {
|
|
133
|
-
* isSystemIdle: Boolean,
|
|
134
|
-
* memInfo: Object,
|
|
135
|
-
* eventLoopInfo: Object,
|
|
136
|
-
* cpuInfo: Object
|
|
137
|
-
* }
|
|
138
|
-
* ```
|
|
139
|
-
*
|
|
140
|
-
* Where the `isSystemIdle` property is set to `false` if the system
|
|
141
|
-
* has been overloaded in the full history of the {@link Snapshotter}
|
|
142
|
-
* (which is configurable in the {@link Snapshotter}) and `true` otherwise.
|
|
143
|
-
*/
|
|
144
|
-
getHistoricalStatus(): SystemInfo;
|
|
145
|
-
/**
|
|
146
|
-
* Returns a system status object.
|
|
147
|
-
*/
|
|
148
|
-
protected _isSystemIdle(sampleDurationMillis?: number): SystemInfo;
|
|
149
|
-
/**
|
|
150
|
-
* Returns an object with an isOverloaded property set to true
|
|
151
|
-
* if the memory has been overloaded in the last sampleDurationMillis.
|
|
152
|
-
*/
|
|
153
|
-
protected _isMemoryOverloaded(sampleDurationMillis?: number): ClientInfo;
|
|
154
|
-
/**
|
|
155
|
-
* Returns an object with an isOverloaded property set to true
|
|
156
|
-
* if the event loop has been overloaded in the last sampleDurationMillis.
|
|
157
|
-
*/
|
|
158
|
-
protected _isEventLoopOverloaded(sampleDurationMillis?: number): ClientInfo;
|
|
159
|
-
/**
|
|
160
|
-
* Returns an object with an isOverloaded property set to true
|
|
161
|
-
* if the CPU has been overloaded in the last sampleDurationMillis.
|
|
162
|
-
*/
|
|
163
|
-
protected _isCpuOverloaded(sampleDurationMillis?: number): ClientInfo;
|
|
164
|
-
/**
|
|
165
|
-
* Returns an object with an isOverloaded property set to true
|
|
166
|
-
* if the client has been overloaded in the last sampleDurationMillis.
|
|
167
|
-
*/
|
|
168
|
-
protected _isClientOverloaded(sampleDurationMillis?: number): ClientInfo;
|
|
169
|
-
/**
|
|
170
|
-
* Returns an object with sample information and an isOverloaded property
|
|
171
|
-
* set to true if at least the ratio of snapshots in the sample are overloaded.
|
|
172
|
-
*/
|
|
173
|
-
protected _isSampleOverloaded<T extends {
|
|
174
|
-
createdAt: Date;
|
|
175
|
-
isOverloaded: boolean;
|
|
176
|
-
}>(sample: T[], ratio: number): ClientInfo;
|
|
177
|
-
}
|
|
178
|
-
//# sourceMappingURL=system_status.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system_status.d.ts","sourceRoot":"","sources":["../../src/autoscaling/system_status.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,4CAA4C;IAC5C,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,aAAa,EAAE,UAAU,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;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