@crawlee/core 3.0.0-alpha.2 → 3.0.0-alpha.22

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.
Files changed (159) hide show
  1. package/autoscaling/autoscaled_pool.d.ts +296 -0
  2. package/autoscaling/autoscaled_pool.d.ts.map +1 -0
  3. package/autoscaling/autoscaled_pool.js +673 -0
  4. package/autoscaling/autoscaled_pool.js.map +1 -0
  5. package/autoscaling/index.d.ts +4 -0
  6. package/autoscaling/index.d.ts.map +1 -0
  7. package/autoscaling/index.js +7 -0
  8. package/autoscaling/index.js.map +1 -0
  9. package/autoscaling/snapshotter.d.ts +193 -0
  10. package/autoscaling/snapshotter.d.ts.map +1 -0
  11. package/autoscaling/snapshotter.js +377 -0
  12. package/autoscaling/snapshotter.js.map +1 -0
  13. package/autoscaling/system_status.d.ts +181 -0
  14. package/autoscaling/system_status.d.ts.map +1 -0
  15. package/autoscaling/system_status.js +194 -0
  16. package/autoscaling/system_status.js.map +1 -0
  17. package/cache_container.d.ts +18 -0
  18. package/cache_container.d.ts.map +1 -0
  19. package/cache_container.js +42 -0
  20. package/cache_container.js.map +1 -0
  21. package/configuration.d.ts +150 -0
  22. package/configuration.d.ts.map +1 -0
  23. package/configuration.js +284 -0
  24. package/configuration.js.map +1 -0
  25. package/constants.d.ts +3 -0
  26. package/constants.d.ts.map +1 -0
  27. package/constants.js +6 -0
  28. package/constants.js.map +1 -0
  29. package/crawlers/crawler_commons.d.ts +25 -0
  30. package/crawlers/crawler_commons.d.ts.map +1 -0
  31. package/crawlers/crawler_commons.js +3 -0
  32. package/crawlers/crawler_commons.js.map +1 -0
  33. package/crawlers/crawler_extension.d.ts +11 -0
  34. package/crawlers/crawler_extension.d.ts.map +1 -0
  35. package/crawlers/crawler_extension.js +30 -0
  36. package/crawlers/crawler_extension.js.map +1 -0
  37. package/crawlers/crawler_utils.d.ts +20 -0
  38. package/crawlers/crawler_utils.d.ts.map +1 -0
  39. package/crawlers/crawler_utils.js +61 -0
  40. package/crawlers/crawler_utils.js.map +1 -0
  41. package/crawlers/index.d.ts +5 -0
  42. package/crawlers/index.d.ts.map +1 -0
  43. package/crawlers/index.js +8 -0
  44. package/crawlers/index.js.map +1 -0
  45. package/crawlers/statistics.d.ts +147 -0
  46. package/crawlers/statistics.d.ts.map +1 -0
  47. package/crawlers/statistics.js +360 -0
  48. package/crawlers/statistics.js.map +1 -0
  49. package/enqueue_links/enqueue_links.d.ts +151 -0
  50. package/enqueue_links/enqueue_links.d.ts.map +1 -0
  51. package/enqueue_links/enqueue_links.js +152 -0
  52. package/enqueue_links/enqueue_links.js.map +1 -0
  53. package/enqueue_links/index.d.ts +3 -0
  54. package/enqueue_links/index.d.ts.map +1 -0
  55. package/enqueue_links/index.js +6 -0
  56. package/enqueue_links/index.js.map +1 -0
  57. package/enqueue_links/shared.d.ts +60 -0
  58. package/enqueue_links/shared.d.ts.map +1 -0
  59. package/enqueue_links/shared.js +148 -0
  60. package/enqueue_links/shared.js.map +1 -0
  61. package/errors.d.ts +8 -0
  62. package/errors.d.ts.map +1 -0
  63. package/errors.js +12 -0
  64. package/errors.js.map +1 -0
  65. package/events/event_manager.d.ts +41 -0
  66. package/events/event_manager.d.ts.map +1 -0
  67. package/events/event_manager.js +103 -0
  68. package/events/event_manager.js.map +1 -0
  69. package/events/index.d.ts +3 -0
  70. package/events/index.d.ts.map +1 -0
  71. package/events/index.js +6 -0
  72. package/events/index.js.map +1 -0
  73. package/events/local_event_manager.d.ts +32 -0
  74. package/events/local_event_manager.d.ts.map +1 -0
  75. package/events/local_event_manager.js +114 -0
  76. package/events/local_event_manager.js.map +1 -0
  77. package/index.d.ts +14 -0
  78. package/index.d.ts.map +1 -0
  79. package/index.js +17 -0
  80. package/index.js.map +1 -0
  81. package/index.mjs +61 -0
  82. package/log.d.ts +3 -0
  83. package/log.d.ts.map +1 -0
  84. package/log.js +12 -0
  85. package/log.js.map +1 -0
  86. package/package.json +4 -8
  87. package/proxy_configuration.d.ts +181 -0
  88. package/proxy_configuration.d.ts.map +1 -0
  89. package/proxy_configuration.js +209 -0
  90. package/proxy_configuration.js.map +1 -0
  91. package/request.d.ts +185 -0
  92. package/request.d.ts.map +1 -0
  93. package/request.js +330 -0
  94. package/request.js.map +1 -0
  95. package/serialization.d.ts +33 -0
  96. package/serialization.d.ts.map +1 -0
  97. package/serialization.js +146 -0
  98. package/serialization.js.map +1 -0
  99. package/session_pool/errors.d.ts +8 -0
  100. package/session_pool/errors.d.ts.map +1 -0
  101. package/session_pool/errors.js +20 -0
  102. package/session_pool/errors.js.map +1 -0
  103. package/session_pool/events.d.ts +3 -0
  104. package/session_pool/events.d.ts.map +1 -0
  105. package/session_pool/events.js +6 -0
  106. package/session_pool/events.js.map +1 -0
  107. package/session_pool/index.d.ts +6 -0
  108. package/session_pool/index.d.ts.map +1 -0
  109. package/session_pool/index.js +9 -0
  110. package/session_pool/index.js.map +1 -0
  111. package/session_pool/session.d.ts +212 -0
  112. package/session_pool/session.d.ts.map +1 -0
  113. package/session_pool/session.js +360 -0
  114. package/session_pool/session.js.map +1 -0
  115. package/session_pool/session_pool.d.ts +222 -0
  116. package/session_pool/session_pool.d.ts.map +1 -0
  117. package/session_pool/session_pool.js +389 -0
  118. package/session_pool/session_pool.js.map +1 -0
  119. package/session_pool/session_utils.d.ts +9 -0
  120. package/session_pool/session_utils.d.ts.map +1 -0
  121. package/session_pool/session_utils.js +19 -0
  122. package/session_pool/session_utils.js.map +1 -0
  123. package/storages/dataset.d.ts +317 -0
  124. package/storages/dataset.d.ts.map +1 -0
  125. package/storages/dataset.js +367 -0
  126. package/storages/dataset.js.map +1 -0
  127. package/storages/index.d.ts +7 -0
  128. package/storages/index.d.ts.map +1 -0
  129. package/storages/index.js +11 -0
  130. package/storages/index.js.map +1 -0
  131. package/storages/key_value_store.d.ts +242 -0
  132. package/storages/key_value_store.d.ts.map +1 -0
  133. package/storages/key_value_store.js +320 -0
  134. package/storages/key_value_store.js.map +1 -0
  135. package/storages/request_list.d.ts +469 -0
  136. package/storages/request_list.d.ts.map +1 -0
  137. package/storages/request_list.js +724 -0
  138. package/storages/request_list.js.map +1 -0
  139. package/storages/request_queue.d.ts +315 -0
  140. package/storages/request_queue.d.ts.map +1 -0
  141. package/storages/request_queue.js +730 -0
  142. package/storages/request_queue.js.map +1 -0
  143. package/storages/storage.d.ts +260 -0
  144. package/storages/storage.d.ts.map +1 -0
  145. package/storages/storage.js +3 -0
  146. package/storages/storage.js.map +1 -0
  147. package/storages/storage_manager.d.ts +40 -0
  148. package/storages/storage_manager.d.ts.map +1 -0
  149. package/storages/storage_manager.js +119 -0
  150. package/storages/storage_manager.js.map +1 -0
  151. package/tsconfig.build.tsbuildinfo +1 -0
  152. package/typedefs.d.ts +12 -0
  153. package/typedefs.d.ts.map +1 -0
  154. package/typedefs.js +15 -0
  155. package/typedefs.js.map +1 -0
  156. package/validators.d.ts +21 -0
  157. package/validators.d.ts.map +1 -0
  158. package/validators.js +26 -0
  159. package/validators.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoscaled_pool.js","sourceRoot":"","sources":["../../src/autoscaling/autoscaled_pool.ts"],"names":[],"mappings":";;;;AACA,4CAAqD;AACrD,gDAA4F;AAC5F,oDAAoB;AACpB,oDAAiD;AACjD,gCAA2C;AAC3C,+CAAgE;AAChE,mDAAgF;AAsHhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAa,cAAc;IAmCvB,YACI,OAA8B,EACb,SAAS,6BAAa,CAAC,eAAe,EAAE;;;;;mBAAxC;;QApCrB;;;;;WAA0B;QAE1B,2BAA2B;QAC3B;;;;;WAAiD;QACjD;;;;;WAA0C;QAC1C;;;;;WAA4C;QAC5C;;;;;WAAgD;QAChD;;;;;WAA+C;QAC/C;;;;;WAAiD;QACjD;;;;;WAA2C;QAC3C;;;;;WAAyD;QACzD;;;;;WAA4D;QAC5D;;;;;WAA6D;QAC7D;;;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,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC;IAC/F,CAAC;CACJ;AAtgBD,wCAsgBC"}
@@ -0,0 +1,4 @@
1
+ export * from './autoscaled_pool';
2
+ export * from './snapshotter';
3
+ export * from './system_status';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/autoscaling/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./autoscaled_pool"), exports);
5
+ tslib_1.__exportStar(require("./snapshotter"), exports);
6
+ tslib_1.__exportStar(require("./system_status"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/autoscaling/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,wDAA8B;AAC9B,0DAAgC"}
@@ -0,0 +1,193 @@
1
+ import { Log } from '@apify/log';
2
+ import { BetterIntervalID } from '@apify/utilities';
3
+ import { Configuration } from '../configuration';
4
+ import { SystemInfo } from './system_status';
5
+ import { StorageClient } from '../storages/storage';
6
+ import { EventManager } from '../events/event_manager';
7
+ export interface SnapshotterOptions {
8
+ /**
9
+ * Defines the interval of measuring the event loop response time.
10
+ * @default 0.5
11
+ */
12
+ eventLoopSnapshotIntervalSecs?: number;
13
+ /**
14
+ * Defines the interval of checking the current state
15
+ * of the remote API client.
16
+ * @default 1
17
+ */
18
+ clientSnapshotIntervalSecs?: number;
19
+ /**
20
+ * Maximum allowed delay of the event loop in milliseconds.
21
+ * Exceeding this limit overloads the event loop.
22
+ * @default 50
23
+ */
24
+ maxBlockedMillis?: number;
25
+ /**
26
+ * Defines the maximum ratio of total memory that can be used.
27
+ * Exceeding this limit overloads the memory.
28
+ * @default 0.7
29
+ */
30
+ maxUsedMemoryRatio?: number;
31
+ /**
32
+ * Defines the maximum number of new rate limit errors within
33
+ * the given interval.
34
+ * @default 1
35
+ */
36
+ maxClientErrors?: number;
37
+ /**
38
+ * Sets the interval in seconds for which a history of resource snapshots
39
+ * will be kept. Increasing this to very high numbers will affect performance.
40
+ * @default 60
41
+ */
42
+ snapshotHistorySecs?: number;
43
+ /** @internal */
44
+ log?: Log;
45
+ /** @internal */
46
+ client?: StorageClient;
47
+ /** @internal */
48
+ config?: Configuration;
49
+ }
50
+ declare type MemorySnapshot = {
51
+ createdAt: Date;
52
+ isOverloaded: boolean;
53
+ usedBytes?: number;
54
+ };
55
+ declare type CpuSnapshot = {
56
+ createdAt: Date;
57
+ isOverloaded: boolean;
58
+ usedRatio: number;
59
+ ticks?: {
60
+ idle: number;
61
+ total: number;
62
+ };
63
+ };
64
+ declare type EventLoopSnapshot = {
65
+ createdAt: Date;
66
+ isOverloaded: boolean;
67
+ exceededMillis: number;
68
+ };
69
+ declare type ClientSnapshot = {
70
+ createdAt: Date;
71
+ isOverloaded: boolean;
72
+ rateLimitErrorCount: number;
73
+ };
74
+ /**
75
+ * Creates snapshots of system resources at given intervals and marks the resource
76
+ * as either overloaded or not during the last interval. Keeps a history of the snapshots.
77
+ * It tracks the following resources: Memory, EventLoop, API and CPU.
78
+ * The class is used by the {@link AutoscaledPool} class.
79
+ *
80
+ * When running on the Apify platform, the CPU and memory statistics are provided by the platform,
81
+ * as collected from the running Docker container. When running locally, `Snapshotter`
82
+ * makes its own statistics by querying the OS.
83
+ *
84
+ * CPU becomes overloaded locally when its current use exceeds the `maxUsedCpuRatio` option or
85
+ * when Apify platform marks it as overloaded.
86
+ *
87
+ * Memory becomes overloaded if its current use exceeds the `maxUsedMemoryRatio` option.
88
+ * It's computed using the total memory available to the container when running on
89
+ * the Apify platform and a quarter of total system memory when running locally.
90
+ * Max total memory when running locally may be overridden by using the `APIFY_MEMORY_MBYTES`
91
+ * environment variable.
92
+ *
93
+ * Event loop becomes overloaded if it slows down by more than the `maxBlockedMillis` option.
94
+ *
95
+ * Client becomes overloaded when rate limit errors (429 - Too Many Requests),
96
+ * typically received from the request queue, exceed the set limit within the set interval.
97
+ * @category Scaling
98
+ */
99
+ export declare class Snapshotter {
100
+ log: Log;
101
+ client: StorageClient;
102
+ config: Configuration;
103
+ events: EventManager;
104
+ eventLoopSnapshotIntervalMillis: number;
105
+ clientSnapshotIntervalMillis: number;
106
+ snapshotHistoryMillis: number;
107
+ maxBlockedMillis: number;
108
+ maxUsedMemoryRatio: number;
109
+ maxClientErrors: number;
110
+ maxMemoryBytes: number;
111
+ cpuSnapshots: CpuSnapshot[];
112
+ eventLoopSnapshots: EventLoopSnapshot[];
113
+ memorySnapshots: MemorySnapshot[];
114
+ clientSnapshots: ClientSnapshot[];
115
+ eventLoopInterval: BetterIntervalID;
116
+ clientInterval: BetterIntervalID;
117
+ lastLoggedCriticalMemoryOverloadAt: Date | null;
118
+ /**
119
+ * @param [options] All `Snapshotter` configuration options.
120
+ */
121
+ constructor(options?: SnapshotterOptions);
122
+ /**
123
+ * Starts capturing snapshots at configured intervals.
124
+ */
125
+ start(): Promise<void>;
126
+ /**
127
+ * Stops all resource capturing.
128
+ */
129
+ stop(): Promise<void>;
130
+ /**
131
+ * Returns a sample of latest memory snapshots, with the size of the sample defined
132
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
133
+ */
134
+ getMemorySample(sampleDurationMillis?: number): MemorySnapshot[];
135
+ /**
136
+ * Returns a sample of latest event loop snapshots, with the size of the sample defined
137
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
138
+ */
139
+ getEventLoopSample(sampleDurationMillis?: number): EventLoopSnapshot[];
140
+ /**
141
+ * Returns a sample of latest CPU snapshots, with the size of the sample defined
142
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
143
+ */
144
+ getCpuSample(sampleDurationMillis?: number): CpuSnapshot[];
145
+ /**
146
+ * Returns a sample of latest Client snapshots, with the size of the sample defined
147
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
148
+ */
149
+ getClientSample(sampleDurationMillis?: number): ClientSnapshot[];
150
+ /**
151
+ * Finds the latest snapshots by sampleDurationMillis in the provided array.
152
+ */
153
+ protected _getSample<T extends {
154
+ createdAt: Date;
155
+ }>(snapshots: T[], sampleDurationMillis?: number): T[];
156
+ /**
157
+ * Creates a snapshot of current memory usage
158
+ * using the Apify platform `systemInfo` event.
159
+ */
160
+ protected _snapshotMemory(systemInfo: SystemInfo): void;
161
+ /**
162
+ * Checks for critical memory overload and logs it to the console.
163
+ */
164
+ protected _memoryOverloadWarning(systemInfo: SystemInfo): void;
165
+ /**
166
+ * Creates a snapshot of current event loop delay.
167
+ */
168
+ protected _snapshotEventLoop(intervalCallback: () => unknown): void;
169
+ /**
170
+ * Creates a snapshot of current CPU usage using the Apify platform `systemInfo` event.
171
+ */
172
+ protected _snapshotCpu(systemInfo: SystemInfo): void;
173
+ /**
174
+ * Creates a snapshot of current API state by checking for
175
+ * rate limit errors. Only errors produced by a 2nd retry
176
+ * of the API call are considered for snapshotting since
177
+ * earlier errors may just be caused by a random spike in
178
+ * number of requests and do not necessarily signify API
179
+ * overloading.
180
+ */
181
+ protected _snapshotClient(intervalCallback: () => unknown): void;
182
+ /**
183
+ * Removes snapshots that are older than the snapshotHistorySecs option
184
+ * from the array (destructively - in place).
185
+ */
186
+ protected _pruneSnapshots(snapshots: MemorySnapshot[] | CpuSnapshot[] | EventLoopSnapshot[] | ClientSnapshot[], now: Date): void;
187
+ /**
188
+ * Helper method for easier mocking.
189
+ */
190
+ private _getMemoryInfo;
191
+ }
192
+ export {};
193
+ //# sourceMappingURL=snapshotter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshotter.d.ts","sourceRoot":"","sources":["../../src/autoscaling/snapshotter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,G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EAAE,MAAM;IAI7C;;OAEG;IACH,SAAS,CAAC,UAAU,CAAC,CAAC,SAAS;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE;IAoBvG;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,UAAU;IAchD;;OAEG;IACH,SAAS,CAAC,sBAAsB,CAAC,UAAU,EAAE,UAAU;IAmBvD;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,OAAO;IAuB5D;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU;IAY7C;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,CAAC,gBAAgB,EAAE,MAAM,OAAO;IAwBzD;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,WAAW,EAAE,GAAG,iBAAiB,EAAE,GAAG,cAAc,EAAE,EAAE,GAAG,EAAE,IAAI;IAUzH;;OAEG;YACW,cAAc;CAG/B"}
@@ -0,0 +1,377 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Snapshotter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const utilities_1 = require("@apify/utilities");
6
+ const utils_1 = require("@crawlee/utils");
7
+ const ow_1 = tslib_1.__importDefault(require("ow"));
8
+ const configuration_1 = require("../configuration");
9
+ const log_1 = require("../log");
10
+ const RESERVE_MEMORY_RATIO = 0.5;
11
+ const CLIENT_RATE_LIMIT_ERROR_RETRY_COUNT = 2;
12
+ const CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS = 10000;
13
+ /**
14
+ * Creates snapshots of system resources at given intervals and marks the resource
15
+ * as either overloaded or not during the last interval. Keeps a history of the snapshots.
16
+ * It tracks the following resources: Memory, EventLoop, API and CPU.
17
+ * The class is used by the {@link AutoscaledPool} class.
18
+ *
19
+ * When running on the Apify platform, the CPU and memory statistics are provided by the platform,
20
+ * as collected from the running Docker container. When running locally, `Snapshotter`
21
+ * makes its own statistics by querying the OS.
22
+ *
23
+ * CPU becomes overloaded locally when its current use exceeds the `maxUsedCpuRatio` option or
24
+ * when Apify platform marks it as overloaded.
25
+ *
26
+ * Memory becomes overloaded if its current use exceeds the `maxUsedMemoryRatio` option.
27
+ * It's computed using the total memory available to the container when running on
28
+ * the Apify platform and a quarter of total system memory when running locally.
29
+ * Max total memory when running locally may be overridden by using the `APIFY_MEMORY_MBYTES`
30
+ * environment variable.
31
+ *
32
+ * Event loop becomes overloaded if it slows down by more than the `maxBlockedMillis` option.
33
+ *
34
+ * Client becomes overloaded when rate limit errors (429 - Too Many Requests),
35
+ * typically received from the request queue, exceed the set limit within the set interval.
36
+ * @category Scaling
37
+ */
38
+ class Snapshotter {
39
+ /**
40
+ * @param [options] All `Snapshotter` configuration options.
41
+ */
42
+ constructor(options = {}) {
43
+ Object.defineProperty(this, "log", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: void 0
48
+ });
49
+ Object.defineProperty(this, "client", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ Object.defineProperty(this, "config", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: void 0
60
+ });
61
+ Object.defineProperty(this, "events", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: void 0
66
+ });
67
+ Object.defineProperty(this, "eventLoopSnapshotIntervalMillis", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ Object.defineProperty(this, "clientSnapshotIntervalMillis", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+ Object.defineProperty(this, "snapshotHistoryMillis", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: void 0
84
+ });
85
+ Object.defineProperty(this, "maxBlockedMillis", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: void 0
90
+ });
91
+ Object.defineProperty(this, "maxUsedMemoryRatio", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: void 0
96
+ });
97
+ Object.defineProperty(this, "maxClientErrors", {
98
+ enumerable: true,
99
+ configurable: true,
100
+ writable: true,
101
+ value: void 0
102
+ });
103
+ Object.defineProperty(this, "maxMemoryBytes", {
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true,
107
+ value: void 0
108
+ });
109
+ Object.defineProperty(this, "cpuSnapshots", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: []
114
+ });
115
+ Object.defineProperty(this, "eventLoopSnapshots", {
116
+ enumerable: true,
117
+ configurable: true,
118
+ writable: true,
119
+ value: []
120
+ });
121
+ Object.defineProperty(this, "memorySnapshots", {
122
+ enumerable: true,
123
+ configurable: true,
124
+ writable: true,
125
+ value: []
126
+ });
127
+ Object.defineProperty(this, "clientSnapshots", {
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true,
131
+ value: []
132
+ });
133
+ Object.defineProperty(this, "eventLoopInterval", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: null
138
+ });
139
+ Object.defineProperty(this, "clientInterval", {
140
+ enumerable: true,
141
+ configurable: true,
142
+ writable: true,
143
+ value: null
144
+ });
145
+ Object.defineProperty(this, "lastLoggedCriticalMemoryOverloadAt", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: null
150
+ });
151
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
152
+ eventLoopSnapshotIntervalSecs: ow_1.default.optional.number,
153
+ clientSnapshotIntervalSecs: ow_1.default.optional.number,
154
+ snapshotHistorySecs: ow_1.default.optional.number,
155
+ maxBlockedMillis: ow_1.default.optional.number,
156
+ maxUsedMemoryRatio: ow_1.default.optional.number,
157
+ maxClientErrors: ow_1.default.optional.number,
158
+ log: ow_1.default.optional.object,
159
+ client: ow_1.default.optional.object,
160
+ config: ow_1.default.optional.object,
161
+ }));
162
+ const { eventLoopSnapshotIntervalSecs = 0.5, clientSnapshotIntervalSecs = 1, snapshotHistorySecs = 30, maxBlockedMillis = 50, maxUsedMemoryRatio = 0.7, maxClientErrors = 3, log = log_1.log, config = configuration_1.Configuration.getGlobalConfig(), client = config.getStorageClient(), } = options;
163
+ this.log = log.child({ prefix: 'Snapshotter' });
164
+ this.client = client;
165
+ this.config = config;
166
+ this.events = this.config.getEventManager();
167
+ this.eventLoopSnapshotIntervalMillis = eventLoopSnapshotIntervalSecs * 1000;
168
+ this.clientSnapshotIntervalMillis = clientSnapshotIntervalSecs * 1000;
169
+ this.snapshotHistoryMillis = snapshotHistorySecs * 1000;
170
+ this.maxBlockedMillis = maxBlockedMillis;
171
+ this.maxUsedMemoryRatio = maxUsedMemoryRatio;
172
+ this.maxClientErrors = maxClientErrors;
173
+ // We need to pre-bind those functions to be able to successfully remove listeners.
174
+ this._snapshotCpu = this._snapshotCpu.bind(this);
175
+ this._snapshotMemory = this._snapshotMemory.bind(this);
176
+ }
177
+ /**
178
+ * Starts capturing snapshots at configured intervals.
179
+ */
180
+ async start() {
181
+ const { totalBytes } = await this._getMemoryInfo();
182
+ this.maxMemoryBytes = Math.ceil(totalBytes * this.config.get('availableMemoryRatio'));
183
+ this.log.debug(`Setting max memory of this run to ${Math.round(this.maxMemoryBytes / 1024 / 1024)} MB. Use the AVAILABLE_MEMORY_RATIO environment variable to override it.`); // eslint-disable-line max-len
184
+ // Ensure events are initialized.
185
+ // await this.events.init();
186
+ // Start snapshotting.
187
+ this.eventLoopInterval = (0, utilities_1.betterSetInterval)(this._snapshotEventLoop.bind(this), this.eventLoopSnapshotIntervalMillis);
188
+ this.clientInterval = (0, utilities_1.betterSetInterval)(this._snapshotClient.bind(this), this.clientSnapshotIntervalMillis);
189
+ this.events.on("systemInfo" /* SYSTEM_INFO */, this._snapshotCpu);
190
+ this.events.on("systemInfo" /* SYSTEM_INFO */, this._snapshotMemory);
191
+ }
192
+ /**
193
+ * Stops all resource capturing.
194
+ */
195
+ async stop() {
196
+ (0, utilities_1.betterClearInterval)(this.eventLoopInterval);
197
+ (0, utilities_1.betterClearInterval)(this.clientInterval);
198
+ this.events.off("systemInfo" /* SYSTEM_INFO */, this._snapshotCpu);
199
+ this.events.off("systemInfo" /* SYSTEM_INFO */, this._snapshotMemory);
200
+ // Allow microtask queue to unwind before stop returns.
201
+ await new Promise((resolve) => setImmediate(resolve));
202
+ // await this.events.close();
203
+ }
204
+ /**
205
+ * Returns a sample of latest memory snapshots, with the size of the sample defined
206
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
207
+ */
208
+ getMemorySample(sampleDurationMillis) {
209
+ return this._getSample(this.memorySnapshots, sampleDurationMillis);
210
+ }
211
+ /**
212
+ * Returns a sample of latest event loop snapshots, with the size of the sample defined
213
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
214
+ */
215
+ getEventLoopSample(sampleDurationMillis) {
216
+ return this._getSample(this.eventLoopSnapshots, sampleDurationMillis);
217
+ }
218
+ /**
219
+ * Returns a sample of latest CPU snapshots, with the size of the sample defined
220
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
221
+ */
222
+ getCpuSample(sampleDurationMillis) {
223
+ return this._getSample(this.cpuSnapshots, sampleDurationMillis);
224
+ }
225
+ /**
226
+ * Returns a sample of latest Client snapshots, with the size of the sample defined
227
+ * by the sampleDurationMillis parameter. If omitted, it returns a full snapshot history.
228
+ */
229
+ getClientSample(sampleDurationMillis) {
230
+ return this._getSample(this.clientSnapshots, sampleDurationMillis);
231
+ }
232
+ /**
233
+ * Finds the latest snapshots by sampleDurationMillis in the provided array.
234
+ */
235
+ _getSample(snapshots, sampleDurationMillis) {
236
+ if (!sampleDurationMillis)
237
+ return snapshots;
238
+ const sample = [];
239
+ let idx = snapshots.length;
240
+ if (!idx)
241
+ return sample;
242
+ const latestTime = snapshots[idx - 1].createdAt;
243
+ while (idx--) {
244
+ const snapshot = snapshots[idx];
245
+ if (+latestTime - +snapshot.createdAt <= sampleDurationMillis) {
246
+ sample.unshift(snapshot);
247
+ }
248
+ else {
249
+ break;
250
+ }
251
+ }
252
+ return sample;
253
+ }
254
+ /**
255
+ * Creates a snapshot of current memory usage
256
+ * using the Apify platform `systemInfo` event.
257
+ */
258
+ _snapshotMemory(systemInfo) {
259
+ const createdAt = systemInfo.createdAt ? new Date(systemInfo.createdAt) : new Date();
260
+ this._pruneSnapshots(this.memorySnapshots, createdAt);
261
+ const { memCurrentBytes } = systemInfo;
262
+ const snapshot = {
263
+ createdAt,
264
+ isOverloaded: memCurrentBytes / this.maxMemoryBytes > this.maxUsedMemoryRatio,
265
+ usedBytes: memCurrentBytes,
266
+ };
267
+ this.memorySnapshots.push(snapshot);
268
+ this._memoryOverloadWarning(systemInfo);
269
+ }
270
+ /**
271
+ * Checks for critical memory overload and logs it to the console.
272
+ */
273
+ _memoryOverloadWarning(systemInfo) {
274
+ const { memCurrentBytes } = systemInfo;
275
+ const createdAt = systemInfo.createdAt ? new Date(systemInfo.createdAt) : new Date();
276
+ if (this.lastLoggedCriticalMemoryOverloadAt && +createdAt < +this.lastLoggedCriticalMemoryOverloadAt + CRITICAL_OVERLOAD_RATE_LIMIT_MILLIS)
277
+ return;
278
+ const maxDesiredMemoryBytes = this.maxUsedMemoryRatio * this.maxMemoryBytes;
279
+ const reserveMemory = this.maxMemoryBytes * (1 - this.maxUsedMemoryRatio) * RESERVE_MEMORY_RATIO;
280
+ const criticalOverloadBytes = maxDesiredMemoryBytes + reserveMemory;
281
+ const isCriticalOverload = memCurrentBytes > criticalOverloadBytes;
282
+ if (isCriticalOverload) {
283
+ const usedPercentage = Math.round((memCurrentBytes / this.maxMemoryBytes) * 100);
284
+ const toMb = (bytes) => Math.round(bytes / (1024 ** 2));
285
+ this.log.warning('Memory is critically overloaded. '
286
+ + `Using ${toMb(memCurrentBytes)} MB of ${toMb(this.maxMemoryBytes)} MB (${usedPercentage}%). Consider increasing the actor memory.`);
287
+ this.lastLoggedCriticalMemoryOverloadAt = createdAt;
288
+ }
289
+ }
290
+ /**
291
+ * Creates a snapshot of current event loop delay.
292
+ */
293
+ _snapshotEventLoop(intervalCallback) {
294
+ const now = new Date();
295
+ this._pruneSnapshots(this.eventLoopSnapshots, now);
296
+ const snapshot = {
297
+ createdAt: now,
298
+ isOverloaded: false,
299
+ exceededMillis: 0,
300
+ };
301
+ const previousSnapshot = this.eventLoopSnapshots[this.eventLoopSnapshots.length - 1];
302
+ if (previousSnapshot) {
303
+ const { createdAt } = previousSnapshot;
304
+ const delta = now.getTime() - +createdAt - this.eventLoopSnapshotIntervalMillis;
305
+ if (delta > this.maxBlockedMillis)
306
+ snapshot.isOverloaded = true;
307
+ snapshot.exceededMillis = Math.max(delta - this.maxBlockedMillis, 0);
308
+ }
309
+ this.eventLoopSnapshots.push(snapshot);
310
+ intervalCallback();
311
+ }
312
+ /**
313
+ * Creates a snapshot of current CPU usage using the Apify platform `systemInfo` event.
314
+ */
315
+ _snapshotCpu(systemInfo) {
316
+ const { cpuCurrentUsage, isCpuOverloaded } = systemInfo;
317
+ const createdAt = systemInfo.createdAt ? new Date(systemInfo.createdAt) : new Date();
318
+ this._pruneSnapshots(this.cpuSnapshots, createdAt);
319
+ this.cpuSnapshots.push({
320
+ createdAt,
321
+ isOverloaded: isCpuOverloaded,
322
+ usedRatio: Math.ceil(cpuCurrentUsage / 100),
323
+ });
324
+ }
325
+ /**
326
+ * Creates a snapshot of current API state by checking for
327
+ * rate limit errors. Only errors produced by a 2nd retry
328
+ * of the API call are considered for snapshotting since
329
+ * earlier errors may just be caused by a random spike in
330
+ * number of requests and do not necessarily signify API
331
+ * overloading.
332
+ */
333
+ _snapshotClient(intervalCallback) {
334
+ const now = new Date();
335
+ this._pruneSnapshots(this.clientSnapshots, now);
336
+ const allErrorCounts = this.client.stats?.rateLimitErrors ?? []; // storage client might not support this
337
+ const currentErrCount = allErrorCounts[CLIENT_RATE_LIMIT_ERROR_RETRY_COUNT] || 0;
338
+ // Handle empty snapshots array
339
+ const snapshot = {
340
+ createdAt: now,
341
+ isOverloaded: false,
342
+ rateLimitErrorCount: currentErrCount,
343
+ };
344
+ const previousSnapshot = this.clientSnapshots[this.clientSnapshots.length - 1];
345
+ if (previousSnapshot) {
346
+ const { rateLimitErrorCount } = previousSnapshot;
347
+ const delta = currentErrCount - rateLimitErrorCount;
348
+ if (delta > this.maxClientErrors)
349
+ snapshot.isOverloaded = true;
350
+ }
351
+ this.clientSnapshots.push(snapshot);
352
+ intervalCallback();
353
+ }
354
+ /**
355
+ * Removes snapshots that are older than the snapshotHistorySecs option
356
+ * from the array (destructively - in place).
357
+ */
358
+ _pruneSnapshots(snapshots, now) {
359
+ let oldCount = 0;
360
+ for (let i = 0; i < snapshots.length; i++) {
361
+ const { createdAt } = snapshots[i];
362
+ if (now.getTime() - new Date(createdAt).getTime() > this.snapshotHistoryMillis)
363
+ oldCount++;
364
+ else
365
+ break;
366
+ }
367
+ snapshots.splice(0, oldCount);
368
+ }
369
+ /**
370
+ * Helper method for easier mocking.
371
+ */
372
+ async _getMemoryInfo() {
373
+ return (0, utils_1.getMemoryInfo)();
374
+ }
375
+ }
376
+ exports.Snapshotter = Snapshotter;
377
+ //# sourceMappingURL=snapshotter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshotter.js","sourceRoot":"","sources":["../../src/autoscaling/snapshotter.ts"],"names":[],"mappings":";;;;AACA,gDAA4F;AAC5F,0CAA+C;AAC/C,oDAAoB;AACpB,oDAAiD;AACjD,gCAA2C;AAK3C,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAC9C,MAAM,mCAAmC,GAAG,KAAK,CAAC;AA2DlD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,WAAW;IAuBpB;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