I need a huge help or advice, please. I need to stress the Node.js server - just high the CPU - because I need to test a monitoring tool of the market.
The cenario is: I need a button to start the stress and other to stop it.
I tried use the Loadtest, but when it started it didn't stop programatically, only if I close it manually (if anyone has any advice about it, please!). Then I tried to do a simple while loop, because I thought I could stop it, but it didn't worked..
var shouldRun = true;
app.get("/cpuup", (req, res) => {
var result = 0;
while (shouldRun) {
result += Math.random() * Math.random();
}
return result;
});
app.get("/cpudown", (req, res) => {
shouldRun = false;
});
Could anyone give me advice about another way to do it or I can't stop an asynchronous thread? Thanks!