https://github.com/rupachowrasia/nodejs-scaling-cluster
Scaling node.js app with cluster module
https://github.com/rupachowrasia/nodejs-scaling-cluster
app cluster cluster-module cpu-cores expressjs multiprocessing nodejs scaling
Last synced: 11 months ago
JSON representation
Scaling node.js app with cluster module
- Host: GitHub
- URL: https://github.com/rupachowrasia/nodejs-scaling-cluster
- Owner: rupachowrasia
- Created: 2025-05-06T13:03:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-06T15:20:42.000Z (about 1 year ago)
- Last Synced: 2025-06-04T17:42:20.375Z (12 months ago)
- Topics: app, cluster, cluster-module, cpu-cores, expressjs, multiprocessing, nodejs, scaling
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Scaling in node.js with Cluster
> We use cluster module to scale our application across multiple CPU cores by creating multiple Node.js processes that share the same server port.
## π When to use cluster module?
- Want to utilize all CPU cores on your machine.
- Your app is I/O-heavy (e.g., APIs, HTTP requests).
- You want automatic restarts of crashed workers.
## π How It Works
- The master (primary) process forks child processes (workers).
- All workers share the same port.
- The OS load-balances the incoming connections across them.
## π§ Limitations
- Workers donβt share memory.
- Itβs not true multithreading β it's multi-processing.
- Not suitable for CPU-heavy tasks β use worker_threads instead.
## π Tech Stack
- Node.js
- Express
- Node.js cluster module
## π¦ Installation
```bash
# Clone the repo
git clone https://github.com/rupachowrasia/nodejs-scaling-cluster.git
# Move into the project directory
cd nodejs-scaling-cluster
# Install dependencies
npm install
# Run the app
npm run start