Search code examples
profilingload-testingpm2

NodeJS CPU utilisation statistics


NOTE: This is on Windows.

I have an application that is started as pm2 start index.js --name dvc -- config.json. Then, I started a new command window to monitor the application pm2 monit. To test the application, I am using the Runner option in Postman where, the number of iterations is set to 1000 with a delay of 0 ms.

In pm2 monit window, the CPU % remains between 0 and 11%. In Task Manager, the node.exe process shows CPU % in 20s. The Process Explorer shows the CPU utilisation close to values as reported by pm2 monit. So, I am not able to conclude exactly what is the CPU utilisation.

Can you please advise?


Solution

  • I would recommend looking into Windows Performance Monitor instead, it exposes more precise counters

    1. Start Performance Monitor (i.e. type perfmon in "Search" or "Run" boxes and click "Enter")
    2. Add a new Counter (click green plus sign)
    3. Choose Process from the "Available counters" and search for node
    4. You should see charts for different counters (including, but not limited to CPU usage)

      Windows PerfMon Counter


    Be aware of following:

    1. On multi-core processor systems you might need to monitor CPU usage for all cores in order to ensure that your application can be paralellised
    2. Your 1000 iterations don't really create any load as Postman waits for previous response prior to sending a new request therefore you always have only 1 request processed by your system which might be even cached. If you would like to load test your application I would recommend considering another tool capable of sending requests in multithreaded fashion, for example Apache JMeter would be a reasonable choice. Check out REST API Testing - How to Do it Right article for instructions on seting up JMeter for an API load testing.