Answer the question
In order to leave comments, you need to log in
What in a NodeJS script can load the CPU and how to track exactly where in the code this situation occurs?
Hello. I began to notice that one socket server script loads the processor very heavily. And if you disable this script, then the load on the processor will disappear. Tell me, please, what is the first thing to pay attention to.
Answer the question
In order to leave comments, you need to log in
Two relatively expensive operations that are often overlooked - console.log (and generally outputting somewhere) and JSON.parse/stringify - see if you don't use them often. Especially JSON parsing can be well optimized if you think about where and how the result is used.
First of all, run the node in the cluster.
Node.js 100% cpu 1st core 3400MHZ at 5000 connections. What's wrong? - Read what might help. and so it is necessary to look at the logic of what the script does and what is used.
Can be observed by calling the strace utility .
See also www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
There's also an example for Node.js profiling.
dtrace.org/blogs/dap/2012/01/05/where-does-your-no...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question