A header-only C++ library for writing task-parallel programs using task graphs, with CPU multithreading and CUDA GPU support.
piscinajs/piscina
A Node.js worker thread pool for running CPU-heavy tasks off the main event loop, with queues, cancellation and run-time stats.
- Stars
- 5,226
- Forks
- 177
- Open issues
- 7
- Last commit
- 6 days ago
What is it?
Piscina is a worker thread pool for Node.js. It lets an application dispatch synchronous or async functions to a set of Worker threads, so CPU-bound work runs in parallel without blocking the main event loop. Each worker loads an exported handler from a separate file, and the pool returns the result as a Promise.
The pool handles the operational details: it manages minimum and maximum thread counts, idle timeouts, and a configurable task queue with an optional size limit and backpressure events. Tasks can be cancelled with an AbortSignal, and the pool records run and wait time statistics. Workers can be given memory limits, environment variables, and Linux CPU nice priorities.
Piscina supports CommonJS, ESM and TypeScript, and requires Node.js 24 or later.
Key features
- 01Dispatches sync or async handler functions to a pool of Worker threads.
- 02Configurable minimum and maximum thread counts and idle timeouts.
- 03Task cancellation via AbortSignal or any EventEmitter emitting 'abort'.
- 04Optional queue size limit with drain events for backpressure.
- 05Run and wait time statistics, plus utilization metrics.
- 06Per-worker memory limits and optional Linux CPU nice priority.
Use cases
- Offloading CPU-heavy work such as hashing, image processing or parsing from a Node.js web server.
- Limiting concurrency of expensive jobs while queuing excess requests with backpressure.
- Running server-side rendering or other synchronous computation without stalling the event loop.
Quick start
- 1
Create main.js and worker.js as shown in the README Example section
- 2
Run main.js with Node.js to print the result
Things to know
- The README requires Node.js 24.x or higher.
- The repository metadata shows no clear license, although the README says MIT.
Topics
FAQ
- What is piscina?
- A Node.js worker thread pool for running CPU-heavy tasks off the main event loop, with queues, cancellation and run-time stats. Piscina is a worker thread pool for Node.js. It lets an application dispatch synchronous or async functions to a set of Worker threads, so CPU-bound work runs in parallel without blocking the main event loop. Each worker loads an exported handler from a separate file, and the pool returns the result as a Promise.
- Is piscina free to use? What license does it have?
- piscina is open source under the Other license. Check the license terms before using it in commercial products.
- Is piscina still maintained?
- Actively maintained. The last commit to piscina was on Oct 19, 2026.
- What can I use piscina for?
- Offloading CPU-heavy work such as hashing, image processing or parsing from a Node.js web server. Limiting concurrency of expensive jobs while queuing excess requests with backpressure. Running server-side rendering or other synchronous computation without stalling the event loop.
- How do I install piscina?
- Create main.js and worker.js as shown in the README Example section Run main.js with Node.js to print the result
- Where can I get piscina?
- The source code and installation instructions are on GitHub: https://github.com/piscinajs/piscina
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Go library that makes structured concurrency safer and simpler, with wait groups, bounded pools, ordered streams and panic propagation.
A Ruby gem offering concurrency primitives such as futures, promises, thread pools, agents, atoms, thread-safe collections and synchronization classes.
A Rust data-parallelism library that turns sequential iterators into parallel ones with a near drop-in API change.
Watt is a Node.js application server that runs any Node.js app in worker threads to improve CPU use, scaling and observability in containers.
Fast NumPy array expression evaluator that computes expressions like 3*a+4*b in chunks, using less memory and multiple cores.