Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to debug Node + Socket.io CPU Issues
    text
    copied!<p>We are running a Node Socket.io server with Express 3. The server is monitored using <a href="https://github.com/nodejitsu/forever" rel="noreferrer">Forever</a>. The service is running well, but the CPU grows throughout the day, until it reaches 90%+ and then suddenly drops back down to ~20%, as shown in the graphs below. I believe that the drop is caused by Forever restarting the app.</p> <p><img src="https://i.stack.imgur.com/jZhAt.png" alt="CPU Behaviour"></p> <p>What I would like to know is;</p> <ul> <li>What are the typical factors that could cause a Node.js app to behave like this? </li> <li>What tools / methods are available to debug memory leaks / cpu hogging in node apps?</li> </ul> <p>I think it could be something to do with Socket.io not cleaning up resources once users have disconnected, although the docs say that Socket.io will manage this automatically.</p> <p>Any help would be greatly appreciated, this issue is making managing our server very difficult. I have posted this question on Serverfault a week ago, but did not receive a response, so I think it may be better here.</p> <p><strong>Update:</strong> After more research, it appears that the CPU does not directly correlate with the number of connections. Our critical mass seems to be around ~1500 concurrent connections split up like so:</p> <ul> <li>xhr-polling: 767</li> <li>websocket: 692</li> <li>jsonppolling: 80</li> </ul> <p>Sometimes we could be at 100% CPU with only 500 connections, other times its 1500 connections. I'm aware that the rate of messages sent has a big affect, however the rate is fairly consistent.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload