# piscinajs/piscina

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/piscinajs-piscina).**

5,053 stars · 156 forks · TypeScript · other

## Links

- GitHub: https://github.com/piscinajs/piscina
- Homepage: https://piscinajs.dev
- awesome-repositories: https://awesome-repositories.com/repository/piscinajs-piscina.md

## Topics

`multithreading` `nearform-research` `nodejs` `performance` `piscinajs` `pooling` `thread-pool` `worker-pool` `worker-threads`

## Description

Piscina is a Node.js worker thread pool that runs CPU-intensive JavaScript functions across multiple threads for parallel execution. It manages a dynamic pool of worker threads with configurable size, handling task submission, cancellation, and lifecycle management through a promise-based interface.

The pool supports AbortController-based task cancellation, enabling clean termination of submitted or running tasks without disrupting other work. It enforces per-worker memory limits through V8 resource caps and applies backpressure with a configurable maximum queue size that emits a drain event when capacity becomes available. Piscina allows pluggable queue ordering to replace the default FIFO behavior with custom priority or deadline logic, and supports pluggable load balancing algorithms for assigning tasks to workers. Transferable objects like binary buffers can be passed between threads with zero-copy messaging, reducing memory overhead during data transfer.

Additional capabilities include deferred worker readiness through an asynchronous initialization protocol, performance monitoring with run-time and wait-time histograms, thread priority control on Linux, and the ability to customize worker environment setup with native addon loading. Piscina exposes a straightforward API for submitting functions to workers and retrieving results, with documentation and install instructions available through its npm package.

## Tags

### DevOps & Infrastructure

- [Local Worker Pools](https://awesome-repositories.com/f/devops-infrastructure/worker-pool-management/local-worker-pools.md) — Provides a configurable thread pool for parallel execution of CPU-intensive JavaScript functions.
- [Task Lifecycle Management](https://awesome-repositories.com/f/devops-infrastructure/automation-orchestration/task-execution-frameworks/task-job-management/task-lifecycle-management.md) — Manages the full lifecycle of tasks from submission through cancellation and completion in a worker pool. ([source](https://piscinajs.dev/category/examples))
- [Worker Pool Management](https://awesome-repositories.com/f/devops-infrastructure/worker-pool-management.md) — Manages a dynamic pool of worker threads with configurable size for balancing throughput and resource usage. ([source](https://piscinajs.dev/))
- [Backpressure Controllers](https://awesome-repositories.com/f/devops-infrastructure/data-throughput-optimizers/backpressure-controllers.md) — Limits queued tasks with a configurable maximum size and emits a drain event when capacity becomes available. ([source](https://cdn.jsdelivr.net/gh/piscinajs/piscina@current/README.md))
- [Backpressure Queues](https://awesome-repositories.com/f/devops-infrastructure/job-queues/backpressure-queues.md) — Implements configurable queue size limits with a drain event for backpressure control.
- [Pluggable Ordering](https://awesome-repositories.com/f/devops-infrastructure/task-queues/pluggable-ordering.md) — Supports pluggable queue ordering to replace default FIFO with custom priority or deadline logic. ([source](https://cdn.jsdelivr.net/gh/piscinajs/piscina@current/README.md))
- [Worker Initialization Scripts](https://awesome-repositories.com/f/devops-infrastructure/task-worker-configurations/local-worker-execution/worker-initialization-scripts.md) — Provides a deferred worker readiness protocol that runs initialization tasks before accepting new work.

### Artificial Intelligence & ML

- [AbortController-Based Cancellations](https://awesome-repositories.com/f/artificial-intelligence-ml/agentic-task-orchestrators/task-cancellation-handlers/abortcontroller-based-cancellations.md) — Ships AbortController-based cancellation that cleanly terminates tasks without disrupting other workers. ([source](https://cdn.jsdelivr.net/gh/piscinajs/piscina@current/README.md))

### Development Tools & Productivity

- [Custom Parallel Task Execution](https://awesome-repositories.com/f/development-tools-productivity/parallel-execution/custom-parallel-task-execution.md) — Runs CPU-intensive tasks concurrently across multiple threads to improve throughput.

### Programming Languages & Runtimes

- [Inter-Thread Data Transfers](https://awesome-repositories.com/f/programming-languages-runtimes/inter-thread-data-transfers.md) — Supports zero-copy transfer of binary buffers and transferable objects between worker threads.
- [Node.js Worker Thread Pools](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-worker-thread-pools.md) — Provides a Node.js worker thread pool for parallel execution of CPU-intensive JavaScript functions.

### Software Engineering & Architecture

- [Task Execution Engines](https://awesome-repositories.com/f/software-engineering-architecture/task-execution-engines.md) — Runs user-defined functions on worker threads with configurable pool sizes and custom queues. ([source](https://cdn.jsdelivr.net/gh/piscinajs/piscina@current/README.md))
- [Parallel Task Executors](https://awesome-repositories.com/f/software-engineering-architecture/task-scheduling/parallel-task-executors.md) — Executes user-defined functions on separate worker threads with promise-based results.
- [V8 Resource Caps](https://awesome-repositories.com/f/software-engineering-architecture/memory-usage-analysis/memory-leak-prevention/worker-memory-monitors/v8-resource-caps.md) — Enforces per-worker memory limits through V8 resource caps to prevent memory exhaustion. ([source](https://piscinajs.github.io/piscina/))

### Web Development

- [Inter-Thread Communication](https://awesome-repositories.com/f/web-development/inter-thread-communication.md) — Provides zero-copy transfer of binary buffers between worker threads and the main process. ([source](https://piscinajs.dev/category/examples))

### Networking & Communication

- [Custom Load Balancers](https://awesome-repositories.com/f/networking-communication/custom-load-balancers.md) — Allows replacing the built-in load balancing algorithm with a custom strategy for assigning tasks to workers. ([source](https://piscinajs.dev/category/advanced-topics))

### Operating Systems & Systems Programming

- [Resource Limit Enforcements](https://awesome-repositories.com/f/operating-systems-systems-programming/per-task-indirect-reference-isolations/resource-limit-enforcements.md) — Enforces per-worker heap memory limits using V8 resource caps to prevent memory exhaustion.

### System Administration & Monitoring

- [Remote Task Cancellation](https://awesome-repositories.com/f/system-administration-monitoring/system-activity-monitoring/session-activity-monitors/workflow-cancellation-handlers/remote-task-cancellation.md) — Supports abort-signal-based cancellation of submitted or running tasks in the worker pool.
