performant-nodejs
Installation
SKILL.md
Performant Node.js Skill
Goal
Build and maintain high-throughput, low-latency, and horizontally scalable Node.js systems using modern primitives and architectural patterns.
Capabilities
1. Concurrency & Parallelism
- Clustering: Scale vertically by spawning a process per CPU core using the
clustermodule. - Worker Threads: Offload CPU-intensive tasks (encryption, compression, heavy logic) to separate threads using
worker_threadsto avoid blocking the Event Loop. - Event Loop Management: Prevent starvation by avoiding long-running synchronous operations and heavy JSON parsing on the main thread.
2. Modern Standards & Async
- ES Modules (ESM): Favor ESM for new projects for better tree-shaking, top-level await, and future-proofing.
- AsyncLocalStorage: Use for context propagation (trace IDs, user sessions) across asynchronous boundaries without manual passing.
- Concurrency Control: Use libraries like
p-limitor custom semaphores to prevent resource exhaustion when calling external APIs or databases.
3. High-Performance Streams
- Backpressure Handling: Efficiently stream large files or data sets using
stream.pipelineto manage memory usage. - HTTP Streaming: Implement streaming responses for real-time data processing and low TTFB (Time To First Byte).