Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node js cpu 100%

Tags:

node.js

We're having a problem where every once in a while one of our environments our node app runs on 100% CPU. The server isn't very active and usually runs on 0%-2% CPU. I was wondering what are the common issues that might cause this problem and what would be the best way to find out what causing this issue.

Server specs:

node version 0.8.14
ubuntu 11.10
Intel(R) Xeon(R) CPU E5645 @ 2.40GHz

Node packages used:

"express" : 2.5.x, "log" : "1.2.x", "redis" : "0.8.x", "socket.io" : "0.9.x", "mongodb": ">= 0.9.6-7", "passport" : "0.x.x", "passport-local" : "0.x.x", 
like image 488
dortzur Avatar asked Nov 14 '12 09:11

dortzur


People also ask

Why is my CPU usage at 100%?

If the CPU usage is around 100%, this means that your computer is trying to do more work than it has the capacity for. This is usually OK, but it means that programs may slow down a little. Computers tend to use close to 100% of the CPU when they are doing computationally-intensive things like running games.

Is NodeJS CPU-intensive?

js is single-threaded, CPU-intensive tasks will block all requests from completing, until the task is completed. Therefore Node. js isn't a good solution for CPU-intense tasks".

Can CPU usage go over 100 %?

This percentage is affected by the number of instances running across cores on the server. Multiple instances of a service running on one server or in a multi-core environment can produce CPU usage percentages well above 100%.

What is memory leak in node JS?

In simple terms, a Node. js memory leak is an orphan block of memory on the Heap that is no longer used by your app because it has not been released by the garbage collector. It's a useless block of memory. These blocks can grow over time and lead to your app crashing because it runs out of memory.


1 Answers

You can profile your app with node-tick.

  1. Install node-tick by npm -g install tick
  2. Run your app with enabled profile node --prof ./app.js
  3. After some time with CPU 100% usage stop your app
  4. You can see v8.log in your app directory, now you can read it with node-tick-processor
  5. Run node-tick-processor and explain results
like image 132
Vadim Baryshev Avatar answered Sep 20 '22 18:09

Vadim Baryshev