Halfpint
Halfpint

Reputation: 4079

Node.js how to check if some code is blocking in a server application

I've written a server application in node.js which receives inbound error messages from some hardware using socket.io and an RS232 wireless device.

My server has been receiving error messages perfectly for the past 2 months, but for the last 2 days the server has been randomly locking up and won't respond to any inbound messages until Ctrl + C is pressed in the terminal. I would normally expect this to shut the server down, but when the server blocks, Ctrl + C has been unblocking the event loop and then processing inbound messages that seemed to be queued whilst the event loop was blocked (this is only a theory).

I believe my theory to be correct because the console will hang at a message such as waiting for data... and then pressing Ctrl + C later will batch process 15 requests to push data to my back end.

Initially I can't spot any problems in my code and I'm more baffled due to the application running without problems for 2 months. My question here is, are there any easy to use profiling tools to see where exactly my server application is freezing?

Upvotes: 0

Views: 618

Answers (1)

yeiniel
yeiniel

Reputation: 2456

Maybe you can find the problem using flamegraphs http://www.brendangregg.com/flamegraphs.html. You can find more information here

Aditionally i recommend you to memory profile your application because problems appearing after some time is a common sign of that issue.

Upvotes: 1

Related Questions