Hardware:
I'm running Ubuntu 20.04 virtual Machine on VMware Workstation with 4 core CPU and 6GB of RAM
Issue:
I've been searching for how to boost my NodeJS server and one of the solutions was to utilize all CPU cores of the processor which I'm doing right now.
So this is my entry file called server.js:
const express = require("express");
const app = express();
app.use("/", async (res, req) => {
req.status(200).send('success');
});
app.listen(4300);
With help of pm2 I'm spawning the maximum number of clusters pm2 start server.js -i max and I'm achieving this log:
With help of autocannon I'm targeting this server to kind of 'DDoS' to monitor how good it was to handle multiple concurrent requests.
Here is the code:
const cannon = require('autocannon')
const localHost = 'http://localhost:4300'
async function startMockUp() {
let result = await cannon({
url: localHost, // target url
connections: 10000,
pipelining: 1,
duration: 10 // seconds
})
console.log('request', result.requests)
}
startMockUp()
and here is the output for the first run:
Now I'm trying to make the same thing but with only one cluster running:
And getting this result:
So as you can see I'm not achieving x4 speed up running 4 concurrent clusters in addition to that single cluster was able to handle a bit more of requests.
Why is that happening?
Am I doing something wrong?
Is there a workaround to achieve better results?



