Skip to content

Commit 1847278

Browse files
authored
Fix use the physical CPU count from NodeJS (#7985)
1 parent bb94cc2 commit 1847278

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

frameworks/JavaScript/nodejs/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const cluster = require('cluster');
2-
const numCPUs = require('os').cpus().length;
2+
const physicalCpuCount = require('physical-cpu-count')
33

44
process.env.NODE_HANDLER = 'mysql-raw';
55

@@ -17,7 +17,7 @@ if (cluster.isPrimary) {
1717
console.log(`Primary ${process.pid} is running`);
1818

1919
// Fork workers.
20-
for (let i = 0; i < numCPUs; i++) {
20+
for (let i = 0; i < physicalCpuCount; i++) {
2121
cluster.fork();
2222
}
2323

frameworks/JavaScript/nodejs/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
"mongoose": "5.7.5",
1010
"mysql": "2.16.0",
1111
"mysql2": "1.6.5",
12+
"node-cache": "4.1.1",
1213
"parseurl": "1.3.2",
1314
"pg": "8.5.0",
1415
"pg-hstore": "2.3.2",
15-
"sequelize": "5.15.1",
16-
"node-cache": "4.1.1"
16+
"physical-cpu-count": "^2.0.0",
17+
"sequelize": "5.15.1"
1718
},
1819
"main": "app.js"
1920
}

0 commit comments

Comments
 (0)