Search code examples
javascriptnode.jsamazon-web-servicesamazon-ec2node-cluster

Load testing node.js app on Amazon EC2 instance


I am trying to load test my node.js application with endpoint as API hosted on an m4.large instance using JMeter with 1 master and 3 slaves. The 'server.js' file uses clustering in node.js as follows:

var C_NUM_CPU = 2;
// Listen for dying workers

if (cluster.isMaster) {
 for (var i =0; i < C_NUM_CPU; i ++)
  {
    cluster.fork();
  }
  cluster.on('exit', function (worker) {

// Replace the dead worker
console.log('Worker %d died :(', worker.id);
cluster.fork();

 });
  return;
}

When I tested keeping the 'var C_NUM_CPU=2', the max response time crossed 42s, however, on making it 6, the response time dropped to 1.7s! vCPU for m4.large is just 2, then how is the load being handled? Also, in such a case, how to determine the most optimal choice of an instance?


Solution

  • The issue was JMeter slaves. They were dying due to increased response time. Solved on increasing the number of slaves.