PM2 Cluster Mode Load Balancing Discrepancy on Windows
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, node.js
Research direction
Start with the provided index.js Express reproduction on Windows and run it with pm2 start index.js -i 4, then compare the returned process IDs across parallel requests. Trace PM2's cluster-mode load-balancing entry point and verify that requests are distributed across the four instances as they are on Linux.
Written by the indexing model from the issue text.
Description
What's going wrong?
When utilizing PM2 in cluster mode on Windows servers, we observe a significant discrepancy in load balancing behavior compared to its behaviour on Linux. Unlike the expected round-robin load balancing on Linux, all incoming requests are directed to a single instance of the application on Windows,
How could we reproduce this issue?
On windows create a nodejs app that prints instance id. index.js:
`const express = require('express');
const process = require('process');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
const instanceInfo = {
message: 'Hello, this is Express app!',
instanceId: process.pid,
};
res.json(instanceInfo);
});
app.listen(port, () => {
console.log(Server is running on port ${port} with PID ${process.pid});
});`
Start multiple instances using pm2
pm2 start index.js.js -i 4
Call this API parallelly in multiple tabs. You will always get same instance id.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Unitech/pm2
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Errors Open
Difficulty 4/5 3-5 days Newbie friendliness 28/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100