- ✔ Fast communication between threads
- ✔ Covers both fixed-task and variable-task scenarios
- ✔ Supports flexible pool sizes
- ✔ Proper async tracking integration
- ✔ Tracking statistics for run and wait times
- ✔ Cancellation Support
- ✔ Supports enforcing memory resource limits
- ✔ Supports CommonJS, ESM, and TypeScript
- ✔ Custom task queues
- ✔ Optional CPU scheduling priorities on Linux
Written in TypeScript.
For Node.js 24.x and higher.
-
piscina - the node.js worker pool
- Documentation
- Piscina API
- Class:
Piscina- Constructor:
new Piscina([options]) - Method:
run(task[, options]) - Method:
destroy() - Method:
close([options]) - Event:
'error' - Event:
'drain' - Event:
'needsDrain' - Event:
'message' - Property:
completed(readonly) - Property:
duration(readonly) - Property:
options(readonly) - Property:
runTime(readonly) - Property:
threads(readonly) - Property:
idleThreads(readonly) - Property:
queueSize(readonly) - Property:
needsDrain(readonly) - Property:
utilization(readonly) - Property:
waitTime(readonly) - Static property:
isWorkerThread(readonly) - Static property:
version(readonly) - Static method:
move(value)
- Constructor:
- Custom Task Queues
- Current Limitations (Things we're working on / would love help with)
- Performance Notes
- The Team
- Acknowledgements
- Sponsors
- Resources
In main.js:
const path = require("path");
const Piscina = require("piscina");
const piscina = new Piscina({
filename: path.resolve(__dirname, "worker.js"),
});
(async function () {
const result = await piscina.run