Skip to content

Commit

Permalink
Fix use the physical CPU count from NestJS (TechEmpower#7987)
Browse files Browse the repository at this point in the history
  • Loading branch information
JHyeok authored Mar 7, 2023
1 parent fe2ff26 commit e0fa211
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions frameworks/TypeScript/nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"mongodb": "3.5.4",
"mysql2": "2.1.0",
"pg": "8.5.1",
"physical-cpu-count": "^2.0.0",
"point-of-view": "3.7.2",
"reflect-metadata": "0.1.13",
"rimraf": "3.0.2",
Expand Down
5 changes: 2 additions & 3 deletions frameworks/TypeScript/nest/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MongoModule } from './mongo/mongo.module';
import { join } from 'path';
import { SqlModule } from './sql/sql.module';
import cluster from 'cluster'
import os = require('os');
import physicalCpuCount from 'physical-cpu-count';

const port = process.env.PORT || 8080;

Expand Down Expand Up @@ -58,8 +58,7 @@ async function bootstrapFastify() {
}

if (cluster.isPrimary) {
const cpus = os.cpus().length;
for (let i = 0; i < cpus; i++) {
for (let i = 0; i < physicalCpuCount; i++) {
cluster.fork();
}

Expand Down

0 comments on commit e0fa211

Please sign in to comment.