feat: add fastify in cluster pool example
[poolifier.git] / CHANGELOG.md
... / ...
CommitLineData
1# Changelog
2
3All notable changes to this project will be documented in this file.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8## [Unreleased]
9
10## [2.6.24] - 2023-08-12
11
12### Added
13
14- Add array of transferable objects to the `execute()` method arguments.
15- WebSocket server pool examples: ws
16
17## [2.6.23] - 2023-08-11
18
19### Fixed
20
21- Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
22
23### Added
24
25- HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
26- HTTP server pool examples: express, fastify.
27
28## [2.6.22] - 2023-08-10
29
30### Fixed
31
32- Add missing `types` field to package.json `exports`.
33
34### Changed
35
36- Structure markdown documentation (PR #811).
37
38## [2.6.21] - 2023-08-03
39
40### Changed
41
42- Improve code documentation.
43- Code refactoring and cleanup for better maintainability and readability.
44
45## [2.6.20] - 2023-07-21
46
47### Fixed
48
49- Fix queued tasks redistribution on error task execution starvation.
50- Ensure task queueing per worker condition is untangled from the pool busyness semantic.
51
52### Changed
53
54- Drastically reduce lookups by worker in the worker nodes.
55
56## [2.6.19] - 2023-07-20
57
58### Added
59
60- Dedicated internal communication channel for worker_threads pools.
61
62## [2.6.18] - 2023-07-19
63
64### Changed
65
66- Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
67
68## [2.6.17] - 2023-07-16
69
70### Added
71
72- Add `listTaskFunctions()` method to worker class.
73
74## [2.6.16] - 2023-07-12
75
76### Fixed
77
78- Fix pool startup detection.
79- Fix worker task functions handling.
80
81## [2.6.15] - 2023-07-11
82
83### Added
84
85- Take into account worker node readiness in worker choice strategies.
86
87## [2.6.14] - 2023-07-10
88
89### Fixed
90
91- Fix task function statistics tracking.
92
93## [2.6.13] - 2023-07-10
94
95### Added
96
97- Add per task function statistics tracking.
98- Add public methods to manipulate the worker task functions at runtime.
99
100## [2.6.12] - 2023-07-09
101
102### Fixed
103
104- Workaround import issue with `node:os` module in node 16.x.x.
105
106## [2.6.11] - 2023-07-09
107
108### Fixed
109
110- Fix pool readiness semantic.
111
112## [2.6.10] - 2023-07-08
113
114### Fixed
115
116- Ensure workers are not recreated on error at pool startup.
117
118### Added
119
120- Add `ready` and `strategy` fields to pool information.
121- Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
122- Add dynamic pool sizing checks.
123
124## [2.6.9] - 2023-07-07
125
126### Fixed
127
128- Recreate the right worker type on uncaught exception.
129
130### Added
131
132- Add minimum and maximum to internal measurement statistics.
133- Add `runTime` and `waitTime` to pool information.
134- Check worker inactive time only on dynamic worker.
135
136## [2.6.8] - 2023-07-03
137
138### Fixed
139
140- Brown paper bag release to fix version handling in pool information.
141
142## [2.6.7] - 2023-07-03
143
144### Fixed
145
146- Ensure worker queued tasks at error are reassigned to other pool workers.
147
148### Added
149
150- Add pool `utilization` ratio to pool information.
151- Add `version` to pool information.
152- Add worker information to worker nodes.
153
154## [2.6.6] - 2023-07-01
155
156### Added
157
158- Add safe helper `availableParallelism` to help sizing the pool.
159
160### Fixed
161
162- Ensure message handler is only registered in worker.
163
164## [2.6.5] - 2023-06-27
165
166### Known issues
167
168- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
169
170### Fixed
171
172- Artificial version bump to 2.6.5 to workaround publication issue.
173- Ensure cluster pool destroy() gracefully shutdowns worker's server.
174- Ensure pool event is emitted before task error promise rejection.
175- Fix queued tasks count computation.
176
177### Removed
178
179- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
180
181## [2.6.4] - 2023-06-27
182
183### Known issues
184
185- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
186
187### Fixed
188
189- Ensure cluster pool destroy() gracefully shutdowns worker's server.
190- Ensure pool event is emitted before task error promise rejection.
191- Fix queued tasks count computation.
192
193### Removed
194
195- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
196
197## [2.6.3] - 2023-06-19
198
199### Fixed
200
201- Ensure no tasks are queued when trying to soft kill a dynamic worker.
202- Update strategies internals after statistics computation.
203
204### Changed
205
206- Optimize O(1) queue implementation.
207
208## [2.6.2] - 2023-06-12
209
210### Fixed
211
212- Fix new worker use after creation in dynamic pool given the current worker choice strategy.
213
214## [2.6.1] - 2023-06-10
215
216### Added
217
218- Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
219
220### Fixed
221
222- Fix average statistics computation: ensure failed tasks are not accounted.
223
224## [2.6.0] - 2023-06-09
225
226### Added
227
228- Add `LEAST_ELU` worker choice strategy (experimental).
229- Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
230
231### Changed
232
233- Refactor pool worker node usage internals.
234- Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
235- Breaking change: pool information `info` property object fields have been renamed.
236
237### Fixed
238
239- Fix wait time accounting.
240- Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
241- Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
242
243## [2.5.4] - 2023-06-07
244
245### Added
246
247- Add Event Loop Utilization (ELU) statistics to worker tasks usage.
248
249### Changed
250
251- Compute statistics at the worker level only if needed.
252- Add `worker_threads` options to thread pool options.
253
254### Fixed
255
256- Make the `LEAST_BUSY` strategy only relies on task runtime.
257
258## [2.5.3] - 2023-06-04
259
260### Changed
261
262- Refine pool information content.
263- Limit pool internals public exposure.
264
265## [2.5.2] - 2023-06-02
266
267### Added
268
269- Add `taskError` pool event for task execution error.
270- Add pool information `info` property to pool.
271- Emit pool information on `busy` and `full` pool events.
272
273## [2.5.1] - 2023-06-01
274
275### Added
276
277- Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
278- Add `error` pool event for uncaught worker error.
279
280## [2.5.0] - 2023-05-31
281
282### Added
283
284- Switch pool event emitter to `EventEmitterAsyncResource`.
285- Add tasks wait time accounting in per worker tasks usage.
286- Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
287
288### Changed
289
290- Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
291
292## [2.4.14] - 2023-05-09
293
294### Fixed
295
296- Ensure no undefined task runtime can land in the tasks history.
297- Fix median computation implementation once again.
298
299### Added
300
301- Unit tests for median and queue implementations.
302
303## [2.4.13] - 2023-05-08
304
305### Fixed
306
307- Fix worker choice strategy options validation.
308- Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
309
310## [2.4.12] - 2023-05-06
311
312### Added
313
314- Support multiple task functions per worker.
315- Add custom worker weights support to worker choice strategies options.
316
317### Changed
318
319- Use O(1) queue implementation for tasks queueing.
320
321### Fixed
322
323- Fix median computation implementation.
324- Fix fair share worker choice strategy internals update.
325
326## [2.4.11] - 2023-04-23
327
328### Changed
329
330- Optimize free worker finding in worker choice strategies.
331
332## [2.4.10] - 2023-04-15
333
334### Fixed
335
336- Fix typescript type definition for task function: ensure the input data is optional.
337- Fix typescript type definition for pool execute(): ensure the input data is optional.
338
339## [2.4.9] - 2023-04-15
340
341### Added
342
343- Add tasks queue enablement runtime setter to pool.
344- Add tasks queue options runtime setter to pool.
345- Add worker choice strategy options runtime setter to pool.
346
347### Changed
348
349- Remove the tasks queuing experimental status.
350
351### Fixed
352
353- Fix task function type definition and validation.
354- Fix worker choice strategy options handling.
355
356## [2.4.8] - 2023-04-12
357
358### Fixed
359
360- Fix message between main worker and worker type definition for tasks.
361- Fix code documentation.
362
363## [2.4.7] - 2023-04-11
364
365### Added
366
367- Add worker tasks queue options to pool options.
368
369### Fixed
370
371- Fix missing documentation.
372
373## [2.4.6] - 2023-04-10
374
375### Fixed
376
377- Ensure one task at a time is executed per worker with tasks queueing enabled.
378- Properly count worker executing tasks with tasks queueing enabled.
379
380## [2.4.5] - 2023-04-09
381
382### Added
383
384- Use monotonic high resolution timer for worker tasks runtime.
385- Add worker tasks median runtime to statistics.
386- Add worker tasks queue (experimental).
387
388## [2.4.4] - 2023-04-07
389
390### Added
391
392- Add `PoolEvents` enumeration and `PoolEvent` type.
393
394### Fixed
395
396- Destroy worker only on alive check.
397
398## [2.4.3] - 2023-04-07
399
400### Fixed
401
402- Fix typedoc generation with inheritance.
403
404## [2.4.2] - 2023-04-06
405
406### Added
407
408- Add `full` event to dynamic pool.
409- Keep worker choice strategy in memory for conditional reuse.
410
411### Fixed
412
413- Fix possible negative worker key at worker removal in worker choice strategies.
414
415## [2.4.1] - 2023-04-05
416
417### Changed
418
419- Optimize worker choice strategy for dynamic pool.
420
421### Fixed
422
423- Ensure dynamic pool does not alter worker choice strategy expected behavior.
424
425## [2.4.0] - 2023-04-04
426
427### Added
428
429- Add `LESS_BUSY` worker choice strategy.
430
431### Changed
432
433- Optimize worker storage in pool.
434- Optimize worker alive status check.
435- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
436- Optimize `LESS_USED` worker choice strategy.
437- Update benchmarks versus external threads pools.
438- Optimize tasks usage statistics requirements for worker choice strategy.
439
440### Fixed
441
442- Ensure trimmable characters are checked at pool initialization.
443- Fix message id integer overflow.
444- Fix pool worker removal in worker choice strategy internals.
445- Fix package publication with pnpm.
446
447## [2.4.0-3] - 2023-04-04
448
449### Added
450
451- Add `LESS_BUSY` worker choice strategy.
452
453### Changed
454
455- Optimize worker storage in pool.
456- Optimize worker alive status check.
457- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
458- Optimize `LESS_USED` worker choice strategy.
459- Update benchmarks versus external threads pools.
460
461### Fixed
462
463- Ensure trimmable characters are checked at pool initialization.
464- Fix message id integer overflow.
465- Fix pool worker removal in worker choice strategy internals.
466- Fix package publication with pnpm.
467
468## [2.4.0-2] - 2023-04-03
469
470### Added
471
472- Add `LESS_BUSY` worker choice strategy.
473
474### Changed
475
476- Optimize worker storage in pool.
477- Optimize worker alive status check.
478- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
479- Optimize `LESS_USED` worker choice strategy.
480
481### Fixed
482
483- Ensure trimmable characters are checked at pool initialization.
484- Fix message id integer overflow.
485- Fix pool worker removal in worker choice strategy internals.
486- Fix package publication with pnpm.
487
488## [2.4.0-1] - 2023-04-03
489
490### Added
491
492- Add `LESS_BUSY` worker choice strategy.
493
494### Changed
495
496- Optimize worker storage in pool.
497- Optimize worker alive status check.
498- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
499- Optimize `LESS_USED` worker choice strategy.
500
501### Fixed
502
503- Ensure trimmable characters are checked at pool initialization.
504- Fix message id integer overflow.
505- Fix pool worker removal in worker choice strategy internals.
506
507## [2.4.0-0] - 2023-04-03
508
509### Added
510
511- Add `LESS_BUSY` worker choice strategy.
512
513### Changed
514
515- Optimize worker storage in pool.
516- Optimize worker alive status check.
517- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
518- Optimize `LESS_USED` worker choice strategy.
519
520### Fixed
521
522- Ensure trimmable characters are checked at pool initialization.
523- Fix message id integer overflow.
524- Fix pool worker removal in worker choice strategy internals.
525
526## [2.3.10] - 2023-03-18
527
528### Fixed
529
530- Fix package.json `exports` syntax for ESM and CommonJS.
531
532### Changed
533
534- Permit SemVer pre-release publication.
535
536## [2.3.10-2] - 2023-03-18
537
538### Fixed
539
540- Fix package.json `exports` syntax for ESM and CommonJS.
541
542## [2.3.10-1] - 2023-03-18
543
544### Changed
545
546- Permit SemVer pre-release publication.
547
548## [2.3.10-0] - 2023-03-18
549
550### Fixed
551
552- Fix package.json `exports` syntax for ESM and CommonJS.
553
554## [2.3.9] - 2023-03-18
555
556### Changed
557
558- Introduce ESM module support along with CommonJS one.
559
560### Fixed
561
562- Fix brown paper bag bug referencing the same object literal.
563
564## [2.3.8] - 2023-03-18
565
566### Changed
567
568- Switch internal benchmarking code to benny.
569- Switch to TypeScript 5.x.x.
570- Switch rollup bundler plugins to core ones.
571- Switch to TSDoc syntax.
572- Enforce conventional commits.
573
574### Fixed
575
576- Fix random integer generator.
577- Fix worker choice strategy pool type identification at initialization.
578
579## [2.3.7] - 2022-10-23
580
581### Changed
582
583- Switch to open collective FOSS project funding platform.
584- Switch to ts-standard linter configuration on TypeScript code.
585
586### Fixed
587
588- Fixed missing async on pool execute method.
589- Fixed typing in TypeScript example.
590- Fixed types in unit tests.
591
592## [2.3.6] - 2022-10-22
593
594### Changed
595
596- Cleanup pool attributes and methods.
597- Refine error types thrown.
598
599### Fixed
600
601- Fix continuous integration build on windows.
602- Fix code coverage reporting by using c8 instead of nyc.
603
604## [2.3.5] - 2022-10-21
605
606### Changed
607
608- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
609- Optimize tasks usage lookup implementation.
610
611### Fixed
612
613- Fix missed pool event emitter type export.
614- Fix typedoc documentation generation.
615
616## [2.3.4] - 2022-10-17
617
618### Added
619
620- Fully automate release process with release-it.
621
622### Changed
623
624- Optimize fair share task scheduling algorithm implementation.
625- Update benchmarks versus external pools results with latest version.
626
627## [2.3.3] - 2022-10-15
628
629### Added
630
631- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
632
633## [2.3.2] - 2022-10-14
634
635### Changed
636
637- Optimize fair share worker selection strategy implementation.
638
639### Fixed
640
641- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
642
643## [2.3.1] - 2022-10-13
644
645### Added
646
647- Pool worker choice strategies:
648 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
649 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
650
651## [2.2.2] - 2022-10-09
652
653### Fixed
654
655- Fixed `README.md` file.
656
657## [2.2.1] - 2022-10-08
658
659### Added
660
661- Dynamic worker choice strategy change at runtime.
662
663## [2.2.0] - 2022-01-05
664
665### Breaking Changes
666
667- Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
668
669## [2.1.0] - 2021-08-29
670
671### Added
672
673- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
674
675### Breaking Changes
676
677- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
678- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
679- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
680- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
681
682## [2.0.2] - 2021-05-12
683
684### Bug fixes
685
686- Fix `busy` event emission on fixed pool type
687
688## [2.0.1] - 2021-03-16
689
690### Bug fixes
691
692- Check if pool options are properly set.
693- `busy` event is emitted on all pool types.
694
695## [2.0.0] - 2021-03-01
696
697### Bug fixes
698
699- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
700
701### Breaking Changes
702
703- `FullPool` event is now renamed to `busy`.
704- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
705 _Find more details on our JSDoc._
706
707- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
708
709- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
710
711### Pool options types declaration merge
712
713`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
714
715#### New `export` strategy
716
717```js
718// Before
719const DynamicThreadPool = require('poolifier/lib/dynamic')
720// After
721const { DynamicThreadPool } = require('poolifier/lib/dynamic')
722```
723
724But you should always prefer just using
725
726```js
727const { DynamicThreadPool } = require('poolifier')
728```
729
730#### New type definitions for input data and response
731
732For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
733_This is not a limitation by poolifier but Node.js._
734
735#### Public property replacements
736
737`numWorkers` property is now `numberOfWorkers`
738
739#### Internal (protected) properties and methods renaming
740
741These properties are not intended for end users
742
743- `id` => `nextMessageId`
744
745These methods are not intended for end users
746
747- `_chooseWorker` => `chooseWorker`
748- `_newWorker` => `createWorker`
749- `_execute` => `internalExecute`
750- `_chooseWorker` => `chooseWorker`
751- `_checkAlive` => `checkAlive`
752- `_run` => `run`
753- `_runAsync` => `runAsync`
754
755## [1.1.0] - 2020-05-21
756
757### Added
758
759- ThreadWorker support async functions as option
760- Various external library patches
761
762## [1.0.0] - 2020-01-24
763
764### Added
765
766- FixedThreadPool implementation
767- DynamicThreadPool implementation
768- WorkerThread implementation to improve developer experience